{"record":{"id":"986f43e4905aa870","repo":"mastra-ai/mastra","slug":"duplicate-subconscious-phase-agent-name","errorCode":null,"errorMessage":"Duplicate Subconscious ${phase} agent: ${name}","messagePattern":"Duplicate Subconscious (.+?) agent: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/memory/src/processors/observational-memory/subconscious/index.ts","lineNumber":38,"sourceCode":" * 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,\n    instructions: config?.instructions,","sourceCodeStart":20,"sourceCodeEnd":56,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/packages/memory/src/processors/observational-memory/subconscious/index.ts#L20-L56","documentation":"assertUniqueNames rejects duplicate names among the Subconscious observation/reflection agent entries. Names are the identity used for bookkeeping and cursor scoping (e.g. CURATION_AGENT), so duplicates are ambiguous and throw at construction time. The message includes the phase (observation/reflection) and the offending name.","triggerScenarios":"Constructing Subconscious with two entries in the same phase sharing a name, e.g. observation: ['observe', { name: 'observe', model: x }] or two reflection entries both named 'reflect'.","commonSituations":"Merging config arrays from defaults and user overrides without deduplication; copy-pasted entries with the same name but different options; spreading multiple config sources into one array.","solutions":["Rename one of the duplicate entries so names are unique within each phase.","Deduplicate or merge config arrays before constructing Subconscious.","If two agents genuinely differ, give them distinct descriptive names."],"exampleFix":"// before\nnew Subconscious({ observation: [{ name: 'watch', model: a }, { name: 'watch', model: b }] })\n// after\nnew Subconscious({ observation: [{ name: 'watch-a', model: a }, { name: 'watch-b', model: b }] })","handlingStrategy":"validation","validationCode":"const names = [...observation, ...reflection].map(e => typeof e === 'string' ? e : e?.name);\nconst dupes = names.filter((n, i) => n && names.indexOf(n) !== i);\nif (dupes.length) throw new Error(`Duplicate Subconscious agent names: ${[...new Set(dupes)].join(', ')}`);","typeGuard":null,"tryCatchPattern":"try {\n  const sub = new Subconscious(config);\n} catch (err) {\n  if (err.message.startsWith('Duplicate Subconscious')) {\n    throw new ConfigError(`Subconscious config has duplicate agent names: ${err.message}`);\n  } else throw err;\n}","preventionTips":["Deduplicate/merge default and user config arrays by name before constructing.","Key merged entries in a Map<name, entry> so overrides replace rather than duplicate.","Add a unit test asserting unique names for shipped default configs."],"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"}