{"record":{"id":"c2a6f4a41c4c816b","repo":"mastra-ai/mastra","slug":"tried-to-embed-message-content-but-this-memory-ins","errorCode":null,"errorMessage":"Tried to embed message content but this Memory instance doesn't have an attached embedder.","messagePattern":"Tried to embed message content but this Memory instance doesn't have an attached embedder\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/memory/src/index.ts","lineNumber":1292,"sourceCode":"      usage?: { tokens: number };\n      dimension: number | undefined;\n    }\n  >({ max: DEFAULT_EMBEDDING_CACHE_MAX_SIZE });\n  private firstEmbed: Promise<any> | undefined;\n  protected async embedMessageContent(content: string) {\n    // Key by the content hash (not the content itself) to keep keys small. Use the\n    // 64-bit hash: h32 is only 32 bits, so distinct contents collide after ~tens of\n    // thousands of entries, which would return another message's cached embeddings.\n    const key = (await this.hasher).h64(content);\n    const cached = this.embeddingCache.get(key);\n    if (cached) {\n      this.logger.debug('Embedding cache hit', { contentHash: key.toString(), chunks: cached.chunks.length });\n      return cached;\n    }\n    const chunks = this.chunkText(content);\n\n    if (typeof this.embedder === `undefined`) {\n      throw new Error(`Tried to embed message content but this Memory instance doesn't have an attached embedder.`);\n    }\n    // for fastembed multiple initial calls to embed will fail if the model hasn't been downloaded yet.\n    const isFastEmbed = this.embedder.provider === `fastembed`;\n    if (isFastEmbed && this.firstEmbed instanceof Promise) {\n      // so wait for the first one\n      await this.firstEmbed;\n    }\n\n    let embedFn: typeof embedMany | typeof embedManyV5 | typeof embedManyV6;\n    const specVersion = this.embedder.specificationVersion;\n\n    switch (specVersion) {\n      case 'v3':\n        embedFn = embedManyV6;\n        break;\n      case 'v2':\n        embedFn = embedManyV5;\n        break;","sourceCodeStart":1274,"sourceCodeEnd":1310,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/packages/memory/src/index.ts#L1274-L1310","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\nconst memory = new Memory({ storage });\n// after\nimport { Memory } from '@mastra/memory';\nimport { FastEmbed } from '@mastra/rag';\nconst memory = new Memory({ storage, embedder: new FastEmbed() });","handlingStrategy":"validation","validationCode":"if (!memory['embedder'] && memoryConfig.semanticRecall) {\n  throw new Error('semanticRecall requires an embedder on the Memory instance');\n}","typeGuard":"function hasEmbedder(m: Memory): boolean {\n  return typeof (m as unknown as { embedder?: unknown }).embedder !== 'undefined';\n}","tryCatchPattern":"try {\n  await memory.remember({ threadId, resourceId, messages });\n} catch (e) {\n  if (e instanceof Error && e.message.includes(\"doesn't have an attached embedder\")) {\n    console.error('Add an embedder (e.g. new FastEmbed()) to the Memory options.');\n  }\n  throw e;\n}","preventionTips":["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."],"tags":["memory","embedder","configuration"],"backgroundTag":"missing-embedder-configuration","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T08:17:16.595Z"}