{"record":{"id":"695627848630f689","repo":"mastra-ai/mastra","slug":"subconscious-semantic-knowledge-requires-both-a-ve","errorCode":null,"errorMessage":"Subconscious semantic knowledge requires both a vector store and an embedder.","messagePattern":"Subconscious semantic knowledge requires both a vector store and an embedder\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/memory/src/index.ts","lineNumber":534,"sourceCode":"        throw new Error('Subconscious semantic knowledge requires a vector store. Pass a `vector` option to Memory.');\n      }\n      if (!this.embedder) {\n        throw new Error('Subconscious semantic knowledge requires an embedder. Pass an `embedder` option to Memory.');\n      }\n    }\n  }\n\n  private async getKnowledgeStore(): Promise<KnowledgeStorage> {\n    const store = await this.storage.getStore('knowledge');\n    if (!store) {\n      throw new Error(`Knowledge storage domain is not available on ${this.storage.constructor.name}`);\n    }\n    return store;\n  }\n\n  public async getKnowledgeSemanticIndex(): Promise<KnowledgeSemanticIndexCoordinator> {\n    if (!this.vector || !this.embedder) {\n      throw new Error('Subconscious semantic knowledge requires both a vector store and an embedder.');\n    }\n    this._knowledgeSemanticIndex ??= this.getKnowledgeStore().then(\n      knowledge =>\n        new KnowledgeSemanticIndexCoordinator({\n          knowledge,\n          vector: this.vector!,\n          embedder: this.embedder!,\n          embedderOptions: this.embedderOptions,\n        }),\n    );\n    return this._knowledgeSemanticIndex;\n  }\n\n  public async drainKnowledgeSemanticIndex(scope?: KnowledgeScope): Promise<number> {\n    return (await this.getKnowledgeSemanticIndex()).drain(scope);\n  }\n\n  /**","sourceCodeStart":516,"sourceCodeEnd":552,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/packages/memory/src/index.ts#L516-L552","documentation":"getKnowledgeSemanticIndex lazily creates a KnowledgeSemanticIndexCoordinator that performs semantic search over knowledge. Because this requires embedding knowledge into a vector store, it asserts that both `this.vector` and `this.embedder` exist and throws this combined error when either is missing. Unlike the constructor checks, this one fires lazily at call time via drainKnowledgeSemanticIndex or semanticCandidates.","triggerScenarios":"Calling drainKnowledgeSemanticIndex or semanticCandidates (which call getKnowledgeSemanticIndex) on a Memory that has knowledge storage but was constructed without a `vector` option or an `embedder` option (or either).","commonSituations":"Constructor-time subconscious validation skipped (feature enabled via merged thread config or a code path bypassing constructor checks), so the failure surfaces later at index time; partially configured Memory where only vector or only embedder was set.","solutions":["Pass both `vector` and `embedder` options to the Memory constructor","Avoid calling drainKnowledgeSemanticIndex/semanticCandidates when semantic indexing is not configured","Guard with checks (memory has vector && embedder) before invoking semantic index APIs"],"exampleFix":"// before\nawait memory.drainKnowledgeSemanticIndex(); // Memory built without vector/embedder\n// after\nnew Memory({ storage, vector: new LibSQLVector({ connectionUrl: url }), embedder: new FastEmbed(), ... });\nawait memory.drainKnowledgeSemanticIndex();","handlingStrategy":"try-catch","validationCode":"if (!memoryHasVectorAndEmbedder(memory)) {\n  console.warn('Skipping semantic knowledge indexing: vector/embedder not configured');\n} else {\n  await memory.drainKnowledgeSemanticIndex();\n}","typeGuard":"function canSemanticIndex(m: Memory): boolean {\n  return 'vector' in m && 'embedder' in m && Boolean((m as any).vector) && Boolean((m as any).embedder);\n}","tryCatchPattern":"try {\n  await memory.drainKnowledgeSemanticIndex();\n} catch (err) {\n  if (err instanceof Error && err.message.includes('requires both a vector store and an embedder')) {\n    // degrade gracefully: skip semantic indexing or lazily configure vector+embedder\n  } else throw err;\n}","preventionTips":["Only call drainKnowledgeSemanticIndex/semanticCandidates on fully configured Memory instances","Gate semantic indexing behind a config check (vector && embedder present)","Construct Memory via a factory that guarantees vector+embedder when knowledge features are on","Add integration tests that exercise semantic indexing with real vector+embedder config"],"tags":["vector-store","embedder","semantic-index","configuration"],"backgroundTag":"missing-vector-store","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T08:17:16.595Z"}