{"record":{"id":"3319307f0b78cc8f","repo":"mastra-ai/mastra","slug":"subconscious-learn-requires-a-configured-knowledge","errorCode":null,"errorMessage":"Subconscious learn requires a configured knowledge storage domain.","messagePattern":"Subconscious learn requires a configured knowledge storage domain\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/memory/src/processors/observational-memory/subconscious/learn.ts","lineNumber":168,"sourceCode":"    }\n  };\n}\n\nexport function createLearnerHandler(\n  memory: Memory,\n  subconscious: ResolvedSubconsciousConfig,\n  learnerMemory = memory,\n  options?: { omModel?: ObservationalMemoryModel },\n): (context: ReflectionCommittedContext) => Promise<void> {\n  const config = subconscious.reflection.find(agent => agent.name === LEARN_AGENT);\n  if (!config) return async () => {};\n  return async context => {\n    let store: KnowledgeStorage | undefined;\n    let scope: KnowledgeScope | undefined;\n    try {\n      scope = resolveScope(context);\n      store = await memory.storage.getStore('knowledge');\n      if (!store) throw new Error('Subconscious learn requires a configured knowledge storage domain.');\n      const cursor = await store.getCurationCursor({ sourceThreadId: context.parentThreadId, agent: LEARN_AGENT });\n      const worklist = await readWorklist(store, context.parentThreadId, scope, cursor?.lastKnowledgeId);\n      if (!worklist.records.length) return;\n      const agent = await createLearnerAgent(\n        memory,\n        learnerMemory,\n        context,\n        scope,\n        worklist.records,\n        config,\n        subconscious,\n        options?.omModel,\n      );\n      const result = await agent.generate(\n        `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)}`,\n        {\n          requestContext: context.requestContext,\n          abortSignal: context.abortSignal,","sourceCodeStart":150,"sourceCodeEnd":186,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/packages/memory/src/processors/observational-memory/subconscious/learn.ts#L150-L186","documentation":"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.","triggerScenarios":"Running the observational-memory subconscious learn step when memory.storage was configured without a 'knowledge' domain (getStore('knowledge') returns undefined).","commonSituations":"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.","solutions":["Add the 'knowledge' domain to the memory instance's storage configuration (memory.storage with a knowledge store)","Verify with await memory.storage.getStore('knowledge') at startup and fail fast if undefined","Check that the storage adapter in use supports the knowledge domain (older adapters may not)","If subconscious learning is not wanted, disable the subconscious config rather than leaving it partially configured"],"exampleFix":"// before\nconst memory = new Memory({ storage: pgStorage });\n// after: register the knowledge domain\nconst memory = new Memory({\n  storage: pgStorage,\n  options: { observationalMemory: { subconscious: { ... } } },\n});\nawait pgStorage.registerDomain?.('knowledge'); // or configure the knowledge store per adapter docs","handlingStrategy":"validation","validationCode":"const store = await memory.storage.getStore('knowledge');\nif (!store) throw new Error('Configure the knowledge storage domain before running subconscious learn.');","typeGuard":"function hasKnowledgeStore(s) {\n  return typeof s === 'object' && s !== null && typeof s.getKnowledge === 'function';\n}","tryCatchPattern":"try {\n  await learn(memory, context);\n} catch (err) {\n  if (err.message.includes('configured knowledge storage domain')) {\n    // enable the knowledge domain on memory.storage, then retry\n  } else throw err;\n}","preventionTips":["Register the knowledge storage domain whenever subconscious features are enabled","Add a startup assertion for getStore('knowledge')","Keep storage config and memory feature flags in sync in one place","Test storage setup in CI with the same config used in production"],"tags":["configuration","storage","observational-memory"],"backgroundTag":"missing-storage-domain","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}