mastra-ai/mastra · critical · MastraError

WORKING_MEMORY_MISSING_STORAGE_ADAPTER

WORKING_MEMORY_MISSING_STORAGE_ADAPTER

Error message

Using Mastra Memory working memory requires a storage adapter but no attached adapter was detected.

What it means

When working memory is enabled (and not using state signals), the input processor pipeline needs a storage adapter to read/write working-memory blocks. getInputProcessors throws this MastraError (WORKING_MEMORY_MISSING_STORAGE_ADAPTER, category USER, domain STORAGE) when memoryStore is absent at processor-build time.

Source

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

    // Extract runtime memoryConfig from context if available
    const memoryContext = context?.get('MastraMemory') as MemoryRequestContext | undefined;
    const runtimeMemoryConfig = memoryContext?.memoryConfig;
    const effectiveConfig = runtimeMemoryConfig ? this.getMergedThreadConfig(runtimeMemoryConfig) : this.threadConfig;

    // Add working memory input processor if configured
    const isWorkingMemoryEnabled =
      typeof effectiveConfig.workingMemory === 'object' && effectiveConfig.workingMemory.enabled !== false;

    // When useStateSignals is opted in, the WorkingMemoryStateProcessor delivers
    // working memory via the state-signal lane. Skip the legacy system-message
    // injection so the model doesn't receive the WORKING_MEMORY_SYSTEM_INSTRUCTION
    // block alongside the signal.
    const useStateSignals =
      typeof effectiveConfig.workingMemory === 'object' && effectiveConfig.workingMemory.useStateSignals === true;

    if (isWorkingMemoryEnabled && !useStateSignals) {
      if (!memoryStore)
        throw new MastraError({
          category: 'USER',
          domain: ErrorDomain.STORAGE,
          id: 'WORKING_MEMORY_MISSING_STORAGE_ADAPTER',
          text: 'Using Mastra Memory working memory requires a storage adapter but no attached adapter was detected.',
        });

      // Check if user already manually added WorkingMemory
      const hasWorkingMemory = configuredProcessors.some(p => !isProcessorWorkflow(p) && p.id === 'working-memory');

      if (!hasWorkingMemory) {
        // Convert string template to WorkingMemoryTemplate format
        let template: { format: 'markdown' | 'json'; content: string } | undefined;
        if (typeof effectiveConfig.workingMemory === 'object' && effectiveConfig.workingMemory.template) {
          template = {
            format: 'markdown',
            content: effectiveConfig.workingMemory.template,
          };
        }

View on GitHub (pinned to 75dd419e61)

Solutions

  1. Attach a storage adapter: storage: new LibSQLStore({ url: 'file:memory.db' }) in the Memory config.
  2. Or configure storage on the Mastra instance so Memory inherits it.
  3. If working memory content should flow via state signals instead, set workingMemory.useStateSignals: true.

Example fix

// before
const memory = new Memory({ options: { workingMemory: { template: 'Facts: {{facts}}' } } });

// after
const memory = new Memory({
  storage: new LibSQLStore({ url: 'file:memory.db' }),
  options: { workingMemory: { template: 'Facts: {{facts}}' } },
});
Defensive patterns

Strategy: validation

Validate before calling

function assertWorkingMemoryStorage(memoryConfig) {
  const wmEnabled = !!memoryConfig?.options?.workingMemory;
  if (wmEnabled && !memoryConfig?.storage) {
    throw new Error('workingMemory requires a storage adapter on Memory (or inherited from Mastra)');
  }
}

Prevention

When it happens

Trigger: Configuring workingMemory in Memory options and sending an input through an agent's input processors while the Memory instance has no storage adapter attached (nor inherited).

Common situations: Standalone Memory with workingMemory enabled but no storage; Mastra instance without storage while Memory relies on inheritance; tests constructing Memory with only options.

Related errors


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