{"record":{"id":"ad6e7b7820500318","repo":"mastra-ai/mastra","slug":"subconscious-phase-agent-name-is-required","errorCode":null,"errorMessage":"Subconscious ${phase} agent name is required.","messagePattern":"Subconscious (.+?) agent name is required\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/memory/src/processors/observational-memory/subconscious/index.ts","lineNumber":37,"sourceCode":"/**\n * Curation walks a worklist that can reach hundreds of records, and its completion marker is\n * fail-closed: a curator that runs out of steps advances no cursor at all. It gets a much larger\n * default budget than the other agents, which each handle a single bounded prompt.\n */\nconst DEFAULT_MAX_STEPS_BY_AGENT: Record<string, number> = { curate: 200 };\nconst MAX_MAX_STEPS = 500;\nconst DEFAULT_RECENT_UPDATES = 10;\nconst MAX_RECENT_UPDATES = 100;\n\nfunction entryName(entry: string | { name: string }): string {\n  return typeof entry === 'string' ? entry : entry.name.trim();\n}\n\nfunction assertUniqueNames(entries: Array<string | { name: string }>, phase: string): void {\n  const seen = new Set<string>();\n  for (const entry of entries) {\n    const name = entryName(entry);\n    if (!name) throw new Error(`Subconscious ${phase} agent name is required.`);\n    if (seen.has(name)) throw new Error(`Duplicate Subconscious ${phase} agent: ${name}`);\n    seen.add(name);\n  }\n}\n\nfunction boundedSteps(entry: { maxSteps?: number } | undefined, fallback: number): number {\n  const steps = entry?.maxSteps ?? fallback;\n  if (!Number.isInteger(steps) || steps < 1 || steps > MAX_MAX_STEPS) {\n    throw new Error(`Subconscious maxSteps must be an integer between 1 and ${MAX_MAX_STEPS}.`);\n  }\n  return steps;\n}\n\nfunction resolveExtractor(entry: SubconsciousObservationEntry): ResolvedSubconsciousAgent {\n  const config = typeof entry === 'string' ? undefined : entry;\n  const name = entryName(entry);\n  return {\n    name,","sourceCodeStart":19,"sourceCodeEnd":55,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/packages/memory/src/processors/observational-memory/subconscious/index.ts#L19-L55","documentation":"The Subconscious constructor validates that every observation/reflection agent entry (string name or config object) has a non-empty name via assertUniqueNames. An entry without a name cannot be addressed or deduplicated, so the constructor throws early. This is a fail-fast config validation.","triggerScenarios":"Passing a Subconscious observation or reflection entry as an object with name: undefined/'' (e.g. { maxSteps: 5 } or { model } only) instead of a string or a named config.","commonSituations":"Copy-pasting an agent entry and deleting the name field; programmatically building entries where a lookup for the name fails; renaming an agent and leaving an empty string.","solutions":["Give every observation/reflection entry a name: either a plain string or an object with a non-empty name property.","Validate config objects before constructing Subconscious.","Use string shorthand entries when no per-agent options are needed."],"exampleFix":"// before\nnew Subconscious({ observation: [{ maxSteps: 5 }] })\n// after\nnew Subconscious({ observation: [{ name: 'observer', maxSteps: 5 }] })","handlingStrategy":"validation","validationCode":"for (const e of [...observation, ...reflection]) {\n  const name = typeof e === 'string' ? e : e?.name;\n  if (!name) throw new Error('Every Subconscious agent entry needs a non-empty name');\n}","typeGuard":"function isNamedEntry(e: unknown): e is { name: string } & Record<string, unknown> {\n  return typeof e === 'object' && e !== null && typeof (e as { name?: unknown }).name === 'string' && (e as { name: string }).name.trim().length > 0;\n}","tryCatchPattern":"try {\n  const sub = new Subconscious(config);\n} catch (err) {\n  if (err.message.includes('agent name is required')) {\n    throw new ConfigError('Invalid Subconscious config: an observation/reflection entry is missing a name');\n  } else throw err;\n}","preventionTips":["Use string shorthand entries unless per-agent options are needed.","Type config with a discriminated union requiring name on object entries.","Validate config at the edge (env/JSON parsing) before constructing."],"tags":["configuration","validation","subconscious"],"backgroundTag":"schema-validation-failed","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}