mastra-ai/mastra · error
Tried to embed message content but this Memory instance does
Error message
Tried to embed message content but this Memory instance doesn't have an attached embedder.
What it means
Memory semantic recall needs to convert message content into vectors, but the Memory instance was constructed without an embedder. The library refuses to guess an embedding provider, so embedding lookups throw. Note the cache-check happens first, so this only fires on cache misses.
Source
Thrown at packages/memory/src/index.ts:1292
usage?: { tokens: number };
dimension: number | undefined;
}
>({ max: DEFAULT_EMBEDDING_CACHE_MAX_SIZE });
private firstEmbed: Promise<any> | undefined;
protected async embedMessageContent(content: string) {
// Key by the content hash (not the content itself) to keep keys small. Use the
// 64-bit hash: h32 is only 32 bits, so distinct contents collide after ~tens of
// thousands of entries, which would return another message's cached embeddings.
const key = (await this.hasher).h64(content);
const cached = this.embeddingCache.get(key);
if (cached) {
this.logger.debug('Embedding cache hit', { contentHash: key.toString(), chunks: cached.chunks.length });
return cached;
}
const chunks = this.chunkText(content);
if (typeof this.embedder === `undefined`) {
throw new Error(`Tried to embed message content but this Memory instance doesn't have an attached embedder.`);
}
// for fastembed multiple initial calls to embed will fail if the model hasn't been downloaded yet.
const isFastEmbed = this.embedder.provider === `fastembed`;
if (isFastEmbed && this.firstEmbed instanceof Promise) {
// so wait for the first one
await this.firstEmbed;
}
let embedFn: typeof embedMany | typeof embedManyV5 | typeof embedManyV6;
const specVersion = this.embedder.specificationVersion;
switch (specVersion) {
case 'v3':
embedFn = embedManyV6;
break;
case 'v2':
embedFn = embedManyV5;
break;View on GitHub (pinned to 75dd419e61)
Solutions
- Pass an embedder: new Memory({ storage, embedder: new FastEmbed() }) (or a compatible FastEmbed/OpenAI/etc. embedder from @mastra/rag).
- If you do not need semantic recall, disable it in the Memory config so embeddings are never requested.
- Ensure the embedder option is actually spread into the constructor and not lost behind a conditional config builder.
Example fix
// before
const memory = new Memory({ storage });
// after
import { Memory } from '@mastra/memory';
import { FastEmbed } from '@mastra/rag';
const memory = new Memory({ storage, embedder: new FastEmbed() }); Defensive patterns
Strategy: validation
Validate before calling
if (!memory['embedder'] && memoryConfig.semanticRecall) {
throw new Error('semanticRecall requires an embedder on the Memory instance');
} Type guard
function hasEmbedder(m: Memory): boolean {
return typeof (m as unknown as { embedder?: unknown }).embedder !== 'undefined';
} Try / catch
try {
await memory.remember({ threadId, resourceId, messages });
} catch (e) {
if (e instanceof Error && e.message.includes("doesn't have an attached embedder")) {
console.error('Add an embedder (e.g. new FastEmbed()) to the Memory options.');
}
throw e;
} Prevention
- Always pass embedder together with storage when semanticRecall is enabled.
- Centralize Memory construction in one factory so required options are never dropped.
- Add an integration test that calls remember() with cache-busting content to catch missing embedder early.
When it happens
Trigger: Creating new Memory({ storage }) without options.embedder while semantic recall is enabled (embedder is required for semanticRecall), then calling remember()/query() or recall() on content not present in the embedding cache.
Common situations: Following docs examples that omit the embedder for brevity; assuming storage alone is enough; removing an embedder during a refactor while semanticRecall stays enabled in config.
Related errors
- SEMANTIC_RECALL_MISSING_EMBEDDER
- sendStateSignal requires Mastra memory
- Storage is not configured on this AgentController
- Storage does not have a memory domain configured
- Memory is not configured on this AgentController
AI-assisted analysis of mastra-ai/mastra@75dd419e61 (2026-08-30).
Data as JSON: /api/errors/c2a6f4a41c4c816b.
Report an issue: GitHub.