{"record":{"id":"21df6d72ce7ad626","repo":"coleam00/Archon","slug":"duplicate-model-binding-name","errorCode":null,"errorMessage":"Duplicate --model binding '${name}'.","messagePattern":"Duplicate --model binding '(.+?)'\\.","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/workflows/src/model-validation.ts","lineNumber":439,"sourceCode":"  const tiers: Partial<Record<TierName, string>> = {};\n  const aliases: Record<string, string> = {};\n  const seen = new Set<string>();\n\n  for (const assignment of assignments) {\n    const equals = assignment.indexOf('=');\n    if (equals <= 0 || equals === assignment.length - 1) {\n      throw new Error(\n        `Invalid --model '${assignment}'. Expected <small|medium|large|@alias>=<model>.`\n      );\n    }\n    const name = assignment.slice(0, equals).trim();\n    const spec = assignment.slice(equals + 1).trim();\n    if (name.length === 0 || spec.length === 0) {\n      throw new Error(\n        `Invalid --model '${assignment}'. Expected <small|medium|large|@alias>=<model>.`\n      );\n    }\n    if (seen.has(name)) throw new Error(`Duplicate --model binding '${name}'.`);\n    seen.add(name);\n\n    if (isTierName(name)) {\n      tiers[name] = spec;\n    } else {\n      assertNotReserved(name);\n      assertCustomAliasPrefix(name);\n      aliases[name] = spec;\n    }\n  }\n\n  return {\n    ...(Object.keys(tiers).length > 0 ? { tiers } : {}),\n    ...(Object.keys(aliases).length > 0 ? { aliases } : {}),\n  };\n}\n\nexport function hasRunModelOverrides(overrides: ResolvedRunModelOverrides): boolean {","sourceCodeStart":421,"sourceCodeEnd":457,"githubUrl":"https://github.com/coleam00/Archon/blob/0773b9745896ef0612e709c80845a0f7db315b19/packages/workflows/src/model-validation.ts#L421-L457","documentation":"parseRunModelAssignments parses CLI --model flags of the form <small|medium|large|@alias>=<model>. This error means the same tier or alias name was assigned more than once in one invocation, which would make the resolved model configuration ambiguous, so the parser rejects it instead of letting a later flag silently win.","triggerScenarios":"Passing --model small=gpt-4o-mini --model small=claude-haiku (or a repeated @alias binding) in a single run command; the same name appearing twice in an assignments array passed to parseRunModelAssignments (or modelOverrides).","commonSituations":"Shell scripts that accumulate --model flags from multiple config sources and concatenate duplicates; copy-pasting a flag into a run command that already contained it; wrapper tooling building the flag list programmatically without deduplication.","solutions":["Remove the duplicate --model flag so each tier/alias name appears exactly once","Deduplicate the assignments list before invoking (keep the last intended value or merge sources)","If merging config layers is intended, resolve duplicates in the layering code before passing to modelOverrides"],"exampleFix":"// before\n--model small=gpt-4o-mini --model medium=gpt-4o --model small=claude-haiku\n// after\n--model small=claude-haiku --model medium=gpt-4o","handlingStrategy":"validation","validationCode":"function validateModelAssignments(assignments: string[]): void {\n  const seen = new Set<string>();\n  for (const a of assignments) {\n    const eq = a.indexOf('=');\n    if (eq === -1) throw new Error(`Invalid --model '${a}'. Expected <small|medium|large|@alias>=<model>.`);\n    const name = a.slice(0, eq).trim();\n    if (name.length === 0 || a.slice(eq + 1).trim().length === 0) throw new Error(`Invalid --model '${a}'.`);\n    if (seen.has(name)) throw new Error(`Duplicate --model binding '${name}'.`);\n    seen.add(name);\n  }\n}","typeGuard":null,"tryCatchPattern":"try {\n  parseRunModelAssignments(args);\n} catch (err) {\n  if (err instanceof Error && err.message.includes('Duplicate --model binding')) {\n    console.error('Each tier/alias may be bound at most once. Fix the --model flags.');\n    process.exitCode = 2;\n  } else throw err;\n}","preventionTips":["Build --model flags from a single deduplicated map (Object.entries of name->model) instead of concatenating lists","When merging config layers, resolve duplicate keys at the merge point before producing flags","Add a shell/tooling check that no --model name appears twice before launching a run"],"tags":["cli","configuration","model-binding"],"backgroundTag":"duplicate-config-key","analyzedSha":"0773b9745896ef0612e709c80845a0f7db315b19","analyzedAt":"2026-09-01T02:28:07.064Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}