mastra-ai/mastra · error · MastraError

SEMANTIC_RECALL_MISSING_STORAGE_ADAPTER

SEMANTIC_RECALL_MISSING_STORAGE_ADAPTER

Error message

Using Mastra Memory semantic recall requires a storage adapter but no attached adapter was detected.

What it means

Mastra Memory's semantic recall feature retrieves past messages similar to the current input, which requires persisting messages and embeddings. When building input processors, Mastra checks that a storage adapter is attached to the Memory instance (or Mastra instance). If `effectiveConfig.semanticRecall` is enabled but `memoryStore` is undefined, this MastraError is thrown before any processing begins.

Source

Thrown at packages/core/src/memory/memory.ts:820

      const hasObservationalMemory =
        configuredProcessors.some(p => !isProcessorWorkflow(p) && p.id === 'observational-memory') ||
        isObservationalMemoryEnabled(effectiveConfig.observationalMemory);

      // Skip MessageHistory input processor if ObservationalMemory handles message loading
      if (!hasMessageHistory && !hasObservationalMemory) {
        processors.push(
          new MessageHistory({
            storage: memoryStore,
            lastMessages: typeof lastMessages === 'number' ? lastMessages : undefined,
          }),
        );
      }
    }

    // Add semantic recall input processor if configured
    if (effectiveConfig.semanticRecall) {
      if (!memoryStore)
        throw new MastraError({
          category: 'USER',
          domain: ErrorDomain.STORAGE,
          id: 'SEMANTIC_RECALL_MISSING_STORAGE_ADAPTER',
          text: 'Using Mastra Memory semantic recall requires a storage adapter but no attached adapter was detected.',
        });

      if (!this.vector)
        throw new MastraError({
          category: 'USER',
          domain: ErrorDomain.MASTRA_VECTOR,
          id: 'SEMANTIC_RECALL_MISSING_VECTOR_ADAPTER',
          text: 'Using Mastra Memory semantic recall requires a vector adapter but no attached adapter was detected.',
        });

      if (!this.embedder)
        throw new MastraError({
          category: 'USER',
          domain: ErrorDomain.MASTRA_VECTOR,

View on GitHub (pinned to 75dd419e61)

Solutions

  1. Pass a storage adapter when constructing Memory: `new Memory({ storage: new PgStore({...}), options: { semanticRecall: {...} } })`.
  2. If the agent is standalone, pass storage directly to Memory rather than relying on the Mastra instance; or attach the Memory+storage to `new Mastra({ storage })`.
  3. If semantic recall is not needed, remove/disable `semanticRecall` in the memory config or the runtime `memoryConfig` passed to generate/stream.

Example fix

// before
const memory = new Memory({ options: { semanticRecall: { topK: 5 } } });
// after
const memory = new Memory({
  storage: new LibSQLStore({ url: 'file:./mastra.db' }),
  options: { semanticRecall: { topK: 5 } },
});
Defensive patterns

Strategy: validation

Validate before calling

function assertSemanticRecallReady(memory) {
  if (memory.threadConfig?.semanticRecall && !memory.hasOwnStorage) {
    throw new Error('semanticRecall enabled but no storage adapter attached to Memory');
  }
}

Type guard

function hasStorage(m): m is MastraMemory & { storage: NonNullable<MastraMemory['storage']> } {
  return Boolean((m as any).storage ?? (m as any).hasOwnStorage);
}

Prevention

When it happens

Trigger: Calling getInputProcessors (directly or via agent.stream/generate) on a Memory instance where `threadConfig.semanticRecall` (or a runtime memoryConfig.semanticRecall) is truthy while no storage adapter was registered via `new Memory({ storage: ... })` or `mastra.attachStorage(...)`.

Common situations: Constructing `new Memory({ options: { semanticRecall: { topK: 5 } } })` without a `storage` key; enabling semanticRecall through a per-request `memoryConfig` on a standalone agent that was never attached to a Mastra instance with storage; upgrading Mastra where storage used to be optional for recall.

Related errors


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