mastra-ai/mastra · error
Subconscious semantic knowledge requires both a vector store
Error message
Subconscious semantic knowledge requires both a vector store and an embedder.
What it means
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.
Source
Thrown at packages/memory/src/index.ts:534
throw new Error('Subconscious semantic knowledge requires a vector store. Pass a `vector` option to Memory.');
}
if (!this.embedder) {
throw new Error('Subconscious semantic knowledge requires an embedder. Pass an `embedder` option to Memory.');
}
}
}
private async getKnowledgeStore(): Promise<KnowledgeStorage> {
const store = await this.storage.getStore('knowledge');
if (!store) {
throw new Error(`Knowledge storage domain is not available on ${this.storage.constructor.name}`);
}
return store;
}
public async getKnowledgeSemanticIndex(): Promise<KnowledgeSemanticIndexCoordinator> {
if (!this.vector || !this.embedder) {
throw new Error('Subconscious semantic knowledge requires both a vector store and an embedder.');
}
this._knowledgeSemanticIndex ??= this.getKnowledgeStore().then(
knowledge =>
new KnowledgeSemanticIndexCoordinator({
knowledge,
vector: this.vector!,
embedder: this.embedder!,
embedderOptions: this.embedderOptions,
}),
);
return this._knowledgeSemanticIndex;
}
public async drainKnowledgeSemanticIndex(scope?: KnowledgeScope): Promise<number> {
return (await this.getKnowledgeSemanticIndex()).drain(scope);
}
/**View on GitHub (pinned to 75dd419e61)
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
Example fix
// before
await memory.drainKnowledgeSemanticIndex(); // Memory built without vector/embedder
// after
new Memory({ storage, vector: new LibSQLVector({ connectionUrl: url }), embedder: new FastEmbed(), ... });
await memory.drainKnowledgeSemanticIndex(); Defensive patterns
Strategy: try-catch
Validate before calling
if (!memoryHasVectorAndEmbedder(memory)) {
console.warn('Skipping semantic knowledge indexing: vector/embedder not configured');
} else {
await memory.drainKnowledgeSemanticIndex();
} Type guard
function canSemanticIndex(m: Memory): boolean {
return 'vector' in m && 'embedder' in m && Boolean((m as any).vector) && Boolean((m as any).embedder);
} Try / catch
try {
await memory.drainKnowledgeSemanticIndex();
} catch (err) {
if (err instanceof Error && err.message.includes('requires both a vector store and an embedder')) {
// degrade gracefully: skip semantic indexing or lazily configure vector+embedder
} else throw err;
} Prevention
- 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
When it happens
Trigger: 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).
Common situations: 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.
Related errors
- Tried to create embedding index but no vector db is attached
- SEMANTIC_RECALL_MISSING_EMBEDDER
- VECTOR_INVALID_ID
- `retrieval: { vector: true }` requires a vector store. Pass
- `retrieval: { vector: true }` requires an embedder. Pass an
AI-assisted analysis of mastra-ai/mastra@75dd419e61 (2026-08-30).
Data as JSON: /api/errors/695627848630f689.
Report an issue: GitHub.