|
2 | 2 | // check-agent-model-declared — asserts that every agent definition under |
3 | 3 | // .claude/agents/ declares a `model:` in its frontmatter (#6803). |
4 | 4 | // |
5 | | -// WHY THIS EXISTS. The Agent tool resolves a subagent's model in three steps: an |
6 | | -// explicit `model` argument on the dispatch call → the agent definition's |
7 | | -// frontmatter → **inherit from the parent session**. When the first two are absent |
8 | | -// the third always applies, silently. That makes "what model does this role run |
9 | | -// on" a property of whoever happened to dispatch it, at whatever moment their own |
10 | | -// session was on, rather than a property of the role — and it changes with no |
11 | | -// signal, mid-term, invisibly. |
| 5 | +// WHY THIS EXISTS. Claude Code resolves a subagent's model in four steps (verified |
| 6 | +// 2026-08-09 against the subagent documentation, "Claude Code resolves the |
| 7 | +// subagent's model in this order"): the `CLAUDE_CODE_SUBAGENT_MODEL` environment |
| 8 | +// variable, when set → an explicit `model` argument on the dispatch call → the |
| 9 | +// agent definition's frontmatter → **inherit from the parent session**. When the |
| 10 | +// first three are absent the last always applies, silently. That makes "what |
| 11 | +// model does this role run on" a property of whoever happened to dispatch it, at |
| 12 | +// whatever moment their own session was on, rather than a property of the role — |
| 13 | +// and it changes with no signal, mid-term, invisibly. (`CLAUDE_CODE_SUBAGENT_MODEL` |
| 14 | +// outranks every other step, including this gate's own pin — see |
| 15 | +// `.claude/agents/os-dev.md` for the full order and both adjacent traps.) |
| 16 | +// |
| 17 | +// A second, smaller nuance in that same order: a value blocked by the |
| 18 | +// organization's `availableModels` allowlist does NOT fall back to the frontmatter |
| 19 | +// pin below — it falls back to the INHERITED model, i.e. straight into the |
| 20 | +// silent-inheritance failure mode this gate exists to catch. |
12 | 21 | // |
13 | 22 | // That is measured, not theoretical, and it fails in a shape worth naming: |
14 | 23 | // |
|
0 commit comments