Repository navigation
fix(mcp): embed memory_query search text as a query - #861
Merged
akitaonrails merged 2 commits intoSep 24, 2026
Merged
Conversation
Google's embedder implements embed() as embed_document (RETRIEVAL_DOCUMENT), the same task type used when indexing wiki pages. memory_query called that generic method for search text, so hybrid retrieval compared a document vector to document vectors. Call embed_query instead so the vector stream uses RETRIEVAL_QUERY. Symmetric embedders are unchanged.
akitaonrails
added a commit
that referenced
this pull request
Sep 24, 2026
Forward-merge the 2.4.x fixes (#875, #824, #861, #873, #866, #871, #872) so main stays a subset of release/2.5. Co-Authored-By: Claude Opus 4.8 <[email protected]> Claude-Session: https://claude.ai/code/session_01MDbhmszrjG9s5MrPrTuNtm # Conflicts: # CHANGELOG.md # crates/ai-memory-cli/src/commands/serve.rs # crates/ai-memory-mcp/src/server.rs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What changed
memory_queryembedded search text with the genericEmbedder::embed()method. Google's embedder implements that asembed_document(RETRIEVAL_DOCUMENT), the same task type used when indexing wiki pages, so hybrid search compared a document vector to document vectors.The query-side helper now calls
embed_query(RETRIEVAL_QUERY). Indexed writes still useembed_document. Symmetric embedders (OpenAI, Voyage, local) already return the same vector fromembed()andembed_query(), so their results are unchanged.Why
Hybrid retrieval is only useful when the query vector is in the same task space as the indexed pages expect for queries. With Google embeddings configured, the vector stream could not separate query from passage because both sides used
RETRIEVAL_DOCUMENT.Test plan
cargo fmt --all -- --checkpassesgit diff --checkpassescargo clippy -p ai-memory-mcp --all-targets -- -D warningspassescargo test -p ai-memory-mcp --lib memory_query— 23 passed, includingmemory_query_embeds_search_text_as_a_query_not_a_documentembed_querywas never called (query_calls == 0). After the fix it is called once andembed()/embed_documentstay unused.Commit attribution
any unintended identity before requesting merge. See
commit attribution guidance.
Author:
kevin9327 <[email protected]>Release impact
new agent harness or provider
breaking MCP schema change, called out in "What changed" above
CHANGELOG (merge gate)
CHANGELOG.md[Unreleased]entry.response shape) is called out explicitly in "What changed" above.
No default changed; only Google (and other query/document-asymmetric
embedders) get the correct query task type.
Notes for reviewers
The one-line production change is in
AiMemoryServer::embed_query. Wiki page writes already callembed_document; this only corrects the search-text helper that feeds hybridmemory_query.AI-assisted (Grok)