mastra-ai/mastra · error · Error

`retrieval: { vector: true }` requires a vector store. Pass

Error message

`retrieval: { vector: true }` requires a vector store. Pass a `vector` option to your Memory instance.

What it means

Observational memory's retrieval can be configured with `retrieval: { vector: true }`, which performs semantic retrieval against a vector store. The Memory constructor validates this at construction time and throws immediately if no `vector` store was provided to the Memory instance, failing fast instead of at query time.

Source

Thrown at packages/memory/src/index.ts:504

    const mergedConfig = this.getMergedThreadConfig({
      workingMemory: config.options?.workingMemory || {
        // these defaults are now set inside @mastra/core/memory in getMergedThreadConfig.
        // In a future release we can remove it from this block - for now if we remove it
        // and someone bumps @mastra/memory without bumping @mastra/core the defaults wouldn't exist yet
        enabled: false,
        template: this.defaultWorkingMemoryTemplate,
      },
      observationalMemory: config.options?.observationalMemory as ObservationalMemoryOptions | boolean | undefined,
    });
    this.assertWorkingMemoryStateSignalsCompatibility(mergedConfig);
    this.threadConfig = mergedConfig;

    // Validate retrieval vector config at construction time
    const omConfig = normalizeObservationalMemoryConfig(mergedConfig.observationalMemory);
    if (omConfig?.retrieval && typeof omConfig.retrieval === 'object' && omConfig.retrieval.vector) {
      if (!this.vector) {
        throw new Error(
          '`retrieval: { vector: true }` requires a vector store. Pass a `vector` option to your Memory instance.',
        );
      }
      if (!this.embedder) {
        throw new Error(
          '`retrieval: { vector: true }` requires an embedder. Pass an `embedder` option to your Memory instance.',
        );
      }
    }
    if (omConfig?.experimental_subconscious) {
      if (!this.vector) {
        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.');
      }
    }
  }

View on GitHub (pinned to 75dd419e61)

Solutions

  1. Pass a `vector` option (e.g. `new LibSQLVector(...)` or `new PGVector(...)`) to the Memory constructor
  2. Set `retrieval.vector: false` (or omit retrieval) if semantic vector retrieval is not needed
  3. Ensure the vector store dependency is installed and its connection config is valid

Example fix

// before
new Memory({ options: { observationalMemory: { retrieval: { vector: true } } } })
// after
new Memory({ vector: new LibSQLVector({ connectionUrl: process.env.DB_URL }), options: { observationalMemory: { retrieval: { vector: true } } } })
Defensive patterns

Strategy: validation

Validate before calling

if (memoryOptions.options?.observationalMemory?.retrieval?.vector && !memoryOptions.vector) {
  throw new Error('retrieval.vector=true requires a vector option on Memory');
}

Try / catch

try {
  const memory = new Memory(opts);
} catch (err) {
  if (err instanceof Error && err.message.includes('requires a vector store')) {
    // construct a vector store and rebuild Memory
  } else throw err;
}

Prevention

When it happens

Trigger: Creating `new Memory({ ..., options: { observationalMemory: { retrieval: { vector: true } } } })` without a `vector` option (e.g. LibSQLStore/PGVector) in the Memory constructor options.

Common situations: Enabling vector retrieval after initially building Memory without a vector store; copying an example config but omitting the vector option; environment where vector storage is disabled or not yet provisioned.

Related errors


AI-assisted analysis of mastra-ai/mastra@75dd419e61 (2026-08-30). Data as JSON: /api/errors/1ea8f0c3c63909c4. Report an issue: GitHub.