fix: Add warning for embedding configuration mismatch #55
+22
−14
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem
When configuring OpenMemory with an external embedding provider (Gemini, OpenAI, etc.), there's a critical configuration mismatch that causes semantic search to completely fail:
embedMultiSectorwhich respectsOM_EMBED_MODE→ uses external provider (768d vectors)embedForSectorwhich respectsOM_TIER→ defaults to "hybrid" (256d synthetic vectors)This vector space mismatch results in all similarity scores being ~0, making semantic search non-functional.
Root Cause Analysis
The issue occurs because:
embedMultiSector(storage) checksenv.embed_modeto decide embedding methodembedForSector(query) checkstiervariable to decide embedding methodOM_TIER=hybridcauses queries to usegen_syn_emb()(synthetic)OM_EMBEDDINGS=gemini, storage uses actual Gemini embeddingsThese are incompatible vector spaces - cosine similarity between them produces essentially random/zero results.
Solution
This PR adds:
OM_TIER=deepembedding-001totext-embedding-004Example Warning Output
Testing
Verified fix by:
OM_TIER=deepwithOM_EMBEDDINGS=geminiAlternative Approaches Considered
embedForSectorrespectOM_EMBED_MODE- More invasive change, might break intentional hybrid setupsOM_TIER- Breaking change for existing usersThe warning approach is safest and most backwards-compatible while clearly informing users of the issue.
🤖 Generated with Claude Code