mastra-ai/mastra · error · Error

Subconscious learn requires a configured knowledge storage d

Error message

Subconscious learn requires a configured knowledge storage domain.

What it means

The subconscious learn handler requires a 'knowledge' storage domain configured on the memory instance. Before doing any curation work it resolves the scope and calls memory.storage.getStore('knowledge'); if no such store is configured it aborts immediately. This is a fail-fast configuration guard: learning cannot persist curated knowledge without its dedicated storage domain.

Source

Thrown at packages/memory/src/processors/observational-memory/subconscious/learn.ts:168

    }
  };
}

export function createLearnerHandler(
  memory: Memory,
  subconscious: ResolvedSubconsciousConfig,
  learnerMemory = memory,
  options?: { omModel?: ObservationalMemoryModel },
): (context: ReflectionCommittedContext) => Promise<void> {
  const config = subconscious.reflection.find(agent => agent.name === LEARN_AGENT);
  if (!config) return async () => {};
  return async context => {
    let store: KnowledgeStorage | undefined;
    let scope: KnowledgeScope | undefined;
    try {
      scope = resolveScope(context);
      store = await memory.storage.getStore('knowledge');
      if (!store) throw new Error('Subconscious learn requires a configured knowledge storage domain.');
      const cursor = await store.getCurationCursor({ sourceThreadId: context.parentThreadId, agent: LEARN_AGENT });
      const worklist = await readWorklist(store, context.parentThreadId, scope, cursor?.lastKnowledgeId);
      if (!worklist.records.length) return;
      const agent = await createLearnerAgent(
        memory,
        learnerMemory,
        context,
        scope,
        worklist.records,
        config,
        subconscious,
        options?.omModel,
      );
      const result = await agent.generate(
        `Parent thread: ${context.parentThreadId}\nCurrent time: ${new Date().toISOString()}\nWorklist truncated: ${worklist.hasMore}\n\nFull pre-reflection observations:\n${context.observations}\n\nPending knowledge records:\n${JSON.stringify(worklist.records)}`,
        {
          requestContext: context.requestContext,
          abortSignal: context.abortSignal,

View on GitHub (pinned to 75dd419e61)

Solutions

  1. Add the 'knowledge' domain to the memory instance's storage configuration (memory.storage with a knowledge store)
  2. Verify with await memory.storage.getStore('knowledge') at startup and fail fast if undefined
  3. Check that the storage adapter in use supports the knowledge domain (older adapters may not)
  4. If subconscious learning is not wanted, disable the subconscious config rather than leaving it partially configured

Example fix

// before
const memory = new Memory({ storage: pgStorage });
// after: register the knowledge domain
const memory = new Memory({
  storage: pgStorage,
  options: { observationalMemory: { subconscious: { ... } } },
});
await pgStorage.registerDomain?.('knowledge'); // or configure the knowledge store per adapter docs
Defensive patterns

Strategy: validation

Validate before calling

const store = await memory.storage.getStore('knowledge');
if (!store) throw new Error('Configure the knowledge storage domain before running subconscious learn.');

Type guard

function hasKnowledgeStore(s) {
  return typeof s === 'object' && s !== null && typeof s.getKnowledge === 'function';
}

Try / catch

try {
  await learn(memory, context);
} catch (err) {
  if (err.message.includes('configured knowledge storage domain')) {
    // enable the knowledge domain on memory.storage, then retry
  } else throw err;
}

Prevention

When it happens

Trigger: Running the observational-memory subconscious learn step when memory.storage was configured without a 'knowledge' domain (getStore('knowledge') returns undefined).

Common situations: Enabling the subconscious/learner feature on an existing Memory whose storage config predates the knowledge domain; copying a minimal Memory config from docs that omits storage.domains.knowledge; upgrading @mastra/memory and not migrating storage config.

Related errors


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