mastra-ai/mastra · error · Error

Subconscious curate requires the main agent to resolve its m

Error message

Subconscious curate requires the main agent to resolve its model.

What it means

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.

Source

Thrown at packages/memory/src/processors/observational-memory/subconscious/curate.ts:151

  };
}

async function createCuratorAgent(
  memory: Memory,
  curatorMemory: Memory,
  context: ReflectionCommittedContext,
  scope: KnowledgeScope,
  config: ResolvedSubconsciousAgent,
  subconscious: ResolvedSubconsciousConfig,
  omModel?: ObservationalMemoryModel,
): Promise<Agent> {
  const model = await resolveSubconsciousAgentModel({
    config,
    omModel,
    mainAgent: context.mainAgent,
    requestContext: context.requestContext,
  });
  if (!model) throw new Error('Subconscious curate requires the main agent to resolve its model.');
  return new Agent({
    id: `subconscious-curate-${context.parentThreadId}`,
    name: 'Subconscious Curate',
    instructions: [
      DEFAULT_INSTRUCTIONS,
      subconscious.pins ? PINNED_INSTRUCTIONS : undefined,
      config.instructions?.trim(),
    ]
      .filter(Boolean)
      .join('\n\n'),
    model,
    memory: curatorMemory,
    tools: {
      ...createKnowledgeTools(memory),
      ...createKnowledgeWriteTools(memory, {
        scope,
        sourceThreadId: context.parentThreadId,
        defaultScope: subconscious.defaultScope,

View on GitHub (pinned to 75dd419e61)

Solutions

  1. Set model explicitly in the observational-memory subconscious/om config.
  2. Ensure the processor is wired to an Agent so context.mainAgent is provided with a resolvable model.
  3. Verify the main agent's model constructor receives valid API keys/env so resolveModel does not return undefined.
  4. Check resolveSubconsciousAgentModel precedence (omModel > mainAgent.model) and that none of the sources is undefined.

Example fix

// before
new Memory({ options: { observationalMemory: { provider: myOmProcessor } } })
// after
new Memory({ options: { observationalMemory: { provider: myOmProcessor, model: openai('gpt-4o-mini') } } })
Defensive patterns

Strategy: validation

Validate before calling

const model = await resolveSubconsciousAgentModel({ config, omModel, mainAgent: context.mainAgent, requestContext: context.requestContext });
if (!model) throw new Error('Configure omConfig.model or ensure the main agent has a resolvable model before curate.');

Type guard

function hasResolvableModel(m: unknown): m is LanguageModel {
  return !!m && (typeof m === 'object' || typeof m === 'function') && 'doGenerate' in (m as object);
}

Try / catch

try {
  await curate(context);
} catch (err) {
  if (err.message.includes('resolve its model')) {
    logger.error('No model for subconscious curator; check omConfig.model / mainAgent wiring');
  } else throw err;
}

Prevention

When it happens

Trigger: 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).

Common situations: 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.

Related errors


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