-
Type:
Improvement
-
Resolution: Unresolved
-
Priority:
Major - P3
-
None
-
Affects Version/s: None
-
Component/s: ABX
-
Not Needed
-
None
-
2
-
None
-
None
-
None
-
None
-
None
-
None
TL;DR
When a Mastra Memory uses MongoDBVector with Automated Embedding, semantic recall should let MongoDB embed messages and queries server-side instead of requiring a client-side embedder. Today the docs and code both require an embedder, and the SemanticRecall processor always embeds client-side and passes a numeric queryVector, so it can't benefit from server-side embedding. Depends on NODE-7734.
Context
What semantic recall is. Mastra's Memory can retrieve past messages by meaning ("semantic recall") rather than recency. Each saved message gets an embedding (a numeric vector) stored in a vector store; at query time the incoming text is embedded and used to find nearby vectors. See the live docs: https://mastra.ai/docs/memory/semantic-recall.
How it works today. Both the docs and the code require a client-side embedder:
- The docs Quickstart states you must "provide a vector store and embedder," and every example (including the MongoDB tab) passes one.
- The SemanticRecall processor (packages/core/src/processors/memory/semantic-recall.ts) does the embedding itself on both sides: on save it embeds each message client-side and upserts the resulting vectors; on recall it embeds the query client-side and calls the store's {{query(
{ queryVector }
)}}. It reaches the store through the generic MastraVector interface, so this is not MongoDB-specific plumbing.
- The public recall() method (with vectorSearchString) is a second entry point that flows through the same processor.
The problem. NODE-7734 adds MongoDB Automated Embedding, where the database embeds text server-side (no client-side embedder needed). But Memory still requires an embedder when semanticRecall is enabled and always passes a precomputed queryVector. A MongoDB user who wants server-side embedding is forced to also configure and pay for a client-side embedder that does redundant work.
Desired User Experience
Before — client-side embedder required (current, documented):
import { Memory } from '@mastra/memory'; import { MongoDBStore, MongoDBVector } from '@mastra/mongodb'; import { ModelRouterEmbeddingModel } from '@mastra/core/llm'; const memory = new Memory({ storage: new MongoDBStore({ id: 'mem', uri: process.env.MONGODB_URI!, dbName: 'app' }), vector: new MongoDBVector({ id: 'vec', uri: process.env.MONGODB_URI!, dbName: 'app' }), embedder: new ModelRouterEmbeddingModel('openai/text-embedding-3-small'), // required today options: { semanticRecall: { topK: 3, messageRange: 2 } }, });
After — MongoDB embeds server-side (desired):
import { Memory } from '@mastra/memory'; import { MongoDBStore, MongoDBVector } from '@mastra/mongodb'; const memory = new Memory({ storage: new MongoDBStore({ id: 'mem', uri: process.env.MONGODB_URI!, dbName: 'app' }), // Store configured for Automated Embedding (per NODE-7734) — no client-side embedder needed. vector: new MongoDBVector({ id: 'vec', uri: process.env.MONGODB_URI!, dbName: 'app' }), options: { semanticRecall: { topK: 3, messageRange: 2 } }, // no `embedder` }); // The explicit recall() entry point works the same way — MongoDB embeds the search string server-side. const { messages } = await memory.recall({ threadId: 'thread-123', vectorSearchString: 'What did we decide about the deadline?', threadConfig: { semanticRecall: true }, });
Task
Goals
- Let Memory semantic recall work with a server-embedding store, without a client-side embedder.
- Keep the existing client-side embedder path working unchanged for all other stores.
Where
- Recall processor: packages/core/src/processors/memory/semantic-recall.ts
- Memory config/validation: packages/core/src/memory/memory.ts
- Docs to update (live): https://mastra.ai/docs/memory/semantic-recall — source docs/.../memory/semantic-recall.mdx (Quickstart MongoDB tab + "Embedder configuration" section)
Acceptance Criteria
- [ ] A user can enable semanticRecall with MongoDBVector (Automated Embedding) without configuring an embedder, and recall works end-to-end — both via an agent and via the explicit recall( { vectorSearchString }) method.
- [ ] The existing client-side embedder path is unchanged for all stores that don't embed server-side; embedder remains required for those.
- [ ] Memory raises a clear, actionable error if semanticRecall is enabled with neither a client-side embedder nor a server-embedding store.
- [ ] Integration tests cover MongoDB Automated Embedding recall (save + recall, both entry points) and confirm existing client-side recall tests still pass.
- [ ] A follow-up documentation ticket is created (or the semantic-recall page is updated) to add a no-embedder MongoDB configuration and adjust the "embedder is required" framing.
Additional Context
- Depends on NODE-7734: the store must first support text-based upsert and text-based query.
- The docs' latency rationale for disabling recall ("each call converts messages into embeddings") is reduced on the server-side path, since embedding no longer costs a client round-trip — the doc update should reflect this.
References
- NODE-7734 (MongoDB Automated Embedding in the vector store): https://jira.mongodb.org/browse/NODE-7734
- is blocked by
-
NODE-7734 [Mastra] support Automated Embeddings
-
- Backlog
-