{"record":{"id":"815943849837dedf","repo":"mastra-ai/mastra","slug":"subconscious-curate-requires-the-main-agent-to-res","errorCode":null,"errorMessage":"Subconscious curate requires the main agent to resolve its model.","messagePattern":"Subconscious curate requires the main agent to resolve its model\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/memory/src/processors/observational-memory/subconscious/curate.ts","lineNumber":151,"sourceCode":"  };\n}\n\nasync function createCuratorAgent(\n  memory: Memory,\n  curatorMemory: Memory,\n  context: ReflectionCommittedContext,\n  scope: KnowledgeScope,\n  config: ResolvedSubconsciousAgent,\n  subconscious: ResolvedSubconsciousConfig,\n  omModel?: ObservationalMemoryModel,\n): Promise<Agent> {\n  const model = await resolveSubconsciousAgentModel({\n    config,\n    omModel,\n    mainAgent: context.mainAgent,\n    requestContext: context.requestContext,\n  });\n  if (!model) throw new Error('Subconscious curate requires the main agent to resolve its model.');\n  return new Agent({\n    id: `subconscious-curate-${context.parentThreadId}`,\n    name: 'Subconscious Curate',\n    instructions: [\n      DEFAULT_INSTRUCTIONS,\n      subconscious.pins ? PINNED_INSTRUCTIONS : undefined,\n      config.instructions?.trim(),\n    ]\n      .filter(Boolean)\n      .join('\\n\\n'),\n    model,\n    memory: curatorMemory,\n    tools: {\n      ...createKnowledgeTools(memory),\n      ...createKnowledgeWriteTools(memory, {\n        scope,\n        sourceThreadId: context.parentThreadId,\n        defaultScope: subconscious.defaultScope,","sourceCodeStart":133,"sourceCodeEnd":169,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/packages/memory/src/processors/observational-memory/subconscious/curate.ts#L133-L169","documentation":"createCuratorAgent resolves the curator's model via resolveSubconsciousAgentModel, falling back through omModel config, the main agent's model, etc. If no model can be resolved from any source it throws, because the curator agent cannot be constructed without one. This typically means the omConfig has no model and the processor context did not receive a main agent with a usable model.","triggerScenarios":"Running the curate processor without an explicit omConfig.model and where context.mainAgent is undefined or its model cannot be resolved (e.g. agent constructed without a model or with a lazy resolver returning undefined).","commonSituations":"ObservationalMemory processor used outside an Agent (no mainAgent in context); main agent configured with a provider that failed to initialize; missing model env vars so the resolver returns undefined.","solutions":["Set model explicitly in the observational-memory subconscious/om config.","Ensure the processor is wired to an Agent so context.mainAgent is provided with a resolvable model.","Verify the main agent's model constructor receives valid API keys/env so resolveModel does not return undefined.","Check resolveSubconsciousAgentModel precedence (omModel > mainAgent.model) and that none of the sources is undefined."],"exampleFix":"// before\nnew Memory({ options: { observationalMemory: { provider: myOmProcessor } } })\n// after\nnew Memory({ options: { observationalMemory: { provider: myOmProcessor, model: openai('gpt-4o-mini') } } })","handlingStrategy":"validation","validationCode":"const model = await resolveSubconsciousAgentModel({ config, omModel, mainAgent: context.mainAgent, requestContext: context.requestContext });\nif (!model) throw new Error('Configure omConfig.model or ensure the main agent has a resolvable model before curate.');","typeGuard":"function hasResolvableModel(m: unknown): m is LanguageModel {\n  return !!m && (typeof m === 'object' || typeof m === 'function') && 'doGenerate' in (m as object);\n}","tryCatchPattern":"try {\n  await curate(context);\n} catch (err) {\n  if (err.message.includes('resolve its model')) {\n    logger.error('No model for subconscious curator; check omConfig.model / mainAgent wiring');\n  } else throw err;\n}","preventionTips":["Always set an explicit model in the observational-memory config for background phases.","Verify main agent model env keys at startup.","Smoke-test the processor outside a server context where mainAgent may be absent."],"tags":["configuration","model-resolution","observational-memory"],"backgroundTag":"model-not-configured","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}