mastra-ai/mastra · error

Subconscious requires a knowledge storage domain. Configure

Error message

Subconscious requires a knowledge storage domain. Configure a storage adapter that provides stores.knowledge.

What it means

After obtaining a Memory instance, capture requires the storage adapter to expose a 'knowledge' store via memory.storage.getStore('knowledge'). If the adapter doesn't implement the knowledge domain, capture throws because there is nowhere to persist knowledge records.

Source

Thrown at packages/memory/src/processors/observational-memory/subconscious/capture.ts:96

    throw new Error(
      'Subconscious requires requestContext.organizationId to derive scoped knowledge. Set organizationId on the request context for this conversation.',
    );
  }
  const resourceId = resolveKnowledgeResourceId(context.requestContext, context.resourceId);
  if (!resourceId) {
    throw new Error('Subconscious requires resourceId to derive scoped knowledge.');
  }
  if (!context.threadId) {
    throw new Error('Subconscious requires threadId to derive scoped knowledge.');
  }
  return [`org:${organizationId}`, `resource:${resourceId}`, `thread:${context.threadId}`];
}

async function getKnowledgeStore(context: ExtractorRuntimeContext): Promise<KnowledgeStorage> {
  if (!context.memory) throw new Error('Subconscious capture requires an active Memory instance.');
  const store = await context.memory.storage.getStore('knowledge');
  if (!store) {
    throw new Error(
      'Subconscious requires a knowledge storage domain. Configure a storage adapter that provides stores.knowledge.',
    );
  }
  return store;
}

function parseWhen(value: string | undefined): Date | undefined {
  if (!value) return undefined;
  const when = new Date(value);
  if (Number.isNaN(when.getTime())) throw new Error(`Invalid Subconscious record time: ${value}`);
  return when;
}

export interface CaptureExtractorOptions {
  config?: SubconsciousCaptureConfig;
  defaultScope: KnowledgeScopeLevel;
  maxScope?: KnowledgeScopeLevel;
  learnedGuidance: boolean;

View on GitHub (pinned to 75dd419e61)

Solutions

  1. Upgrade the storage adapter package to a version supporting the knowledge store (e.g. latest @mastra/libsql / @mastra/pg)
  2. Switch to a storage adapter that implements stores.knowledge
  3. Disable Subconscious capture if your storage backend can't support knowledge storage
  4. Implement getStore('knowledge') in custom adapters

Example fix

// before
storage: new LibSQLStore({ url: 'file:old.db' }) // pre-knowledge-domain version
// after
pnpm add @mastra/libsql@latest
storage: new LibSQLStore({ url: 'file:mastra.db' })
Defensive patterns

Strategy: validation

Validate before calling

const store = await memory.storage.getStore('knowledge'); if (!store) throw new Error('Storage adapter lacks knowledge domain');

Type guard

const supportsKnowledge = async (m: Memory) => !!(await m.storage.getStore('knowledge'));

Try / catch

try { await capture(ctx) } catch (e) { if (String(e).includes('knowledge storage domain')) { upgradeStorageOrDisable(); } else throw e; }

Prevention

When it happens

Trigger: Using a storage adapter that lacks the knowledge store (older/custom adapters) while Subconscious capture is enabled; adapter not migrated to support stores.knowledge.

Common situations: Upgrading @mastra/core memory processors without upgrading the storage package/version; custom storage adapters; libsql/pg adapters built before the knowledge domain existed.

Related errors


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