[BUG] Task tool model parameter silently ignored for in-process team teammates
Preflight Checklist
- [x] I have searched existing issues and this hasn't been reported
- [x] I can reproduce this on the latest version of Claude Code
Bug Description
When spawning teammates via the Task tool with team_name + name parameters, the model parameter is silently ignored. All in-process teammates inherit the leader's model regardless of what model is explicitly specified. The same model parameter works correctly for non-team subagent dispatches.
Reproduction
Setup
- Claude Code v2.1.37
- Parent session running on Opus 4.6
- Custom agent definitions in
~/.claude/agents/withmodel:frontmatter (e.g.,model: haikufor a lightweight agent)
Test 1: Subagent dispatch (works correctly)
Task(subagent_type="geth", model="haiku", prompt="Report your model ID from system prompt")
→ Reports: "Claude Haiku 4.5 (claude-haiku-4-5-20251001)" ✅
Task(subagent_type="edi", model="sonnet", prompt="Report your model ID from system prompt")
→ Reports: "Claude Sonnet 4.5 (claude-sonnet-4-5-20250929)" ✅
Test 2: Teammate dispatch (model ignored)
TeamCreate(team_name="model-test")
Task(subagent_type="geth", model="haiku", name="geth-1", team_name="model-test",
prompt="Report your model ID from system prompt")
→ Reports: "Opus 4.6 (claude-opus-4-6)" ❌ Expected haiku
Task(subagent_type="edi", model="sonnet", name="edi-1", team_name="model-test",
prompt="Report your model ID from system prompt")
→ Reports: "Opus 4.6 (claude-opus-4-6)" ❌ Expected sonnet
Test 3: Teammate dispatch without model param (also all Opus)
Same result — all teammates report Opus regardless of whether model is specified, omitted, or set to a different value.
Expected Behavior
Teammates should respect the model parameter on the Task tool, just as subagents do. Task(model="haiku", team_name="my-team", name="geth-1") should spawn a Haiku teammate, not inherit the leader's Opus.
Root Cause Analysis (from source inspection)
We traced through the bundled CLI source (cli.js v2.1.37) and identified two issues:
Bug 1: In-process teammate spawner drops model parameter
In the handleSpawnInProcess function (minified as zZY), the model is correctly resolved:
let O = A.model ?? XvA; // O contains correct model value
But when calling the runner function (xj6), the model field is not included in the arguments object:
xj6({
identity: {...},
taskId: P.taskId,
prompt: w,
description: A.description,
agentDefinition: W,
teammateContext: P.teammateContext,
toolUseContext: q,
abortController: P.abortController
// model: O ← MISSING — model is computed but never passed
});
Compare with the InProcessBackend.spawn() method (minified as bI4), which correctly includes model:
xj6({
identity: {...},
model: A.model, // ← correctly included here
...
});
The fix is adding model: O to the xj6 call in zZY.
Bug 2: Pane-based teammates override agent definition model
For tmux/iTerm2 backends, the fallback A.model ?? XvA always fills in the system default model when no model is specified. This means --model <default> is always added to the CLI command, overriding whatever the agent definition's model: frontmatter would specify. The subagent path correctly consults the agent definition's model field via resolveSubagentModel (S46), but the teammate path does not.
Impact
- Token cost: Teams intended to use cheaper models (Haiku for simple tasks, Sonnet for standard work) silently run everything at the leader's model tier. For Opus leaders, every teammate burns Opus tokens.
- Silent failure: No error, warning, or indication that the model parameter was ignored. The agent's system prompt shows the actual model, but this requires the agent to self-report.
- Workaround: None for in-process teammates. The model parameter is silently dropped regardless of how it's specified.
Environment
- Claude Code version: 2.1.37
- OS: macOS (Darwin 24.6.0)
- Node: v24.3.0
- Teammate backend: in-process (tested), pane-based (analyzed from source)
Related Issues
- #24316 — Feature request for teammates to inherit full agent definition properties
- #18784 — Agent frontmatter constraints ignored (includes comment about model field)
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗