Agent subprocesses always get 200K context instead of 1M — --model flag bypasses plan entitlement
Description
When the orchestrator spawns agent subprocesses (teammates/subagents), Claude Code always passes --model claude-opus-4-6 to the subprocess command. This selects the explicit 200K Opus variant instead of the "Default (recommended)" option which is Opus 4.6 with 1M context.
The main/orchestrator session correctly gets 1M context through plan entitlement auto-detection (when no "model" is set in settings.json). But agent subprocesses never get a chance to auto-detect because --model is always injected.
Environment
- Claude Code v2.1.87
- Team plan with premium seat
- macOS (Darwin)
Steps to Reproduce
- Remove
"model": "opus"from.claude/settings.json(this fixes the main session — it correctly shows "Opus 4.6 (1M context)") - Start a session with Agent Teams enabled (
CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS=1) - Spawn any agent (teammate or subagent)
- Check the subprocess command — it always includes
--model claude-opus-4-6 - Run
/modelinside the agent pane — it shows "Opus 4.6" (option 5) selected, NOT "Default (recommended)" (option 1, which has 1M context)
Subprocess Command
env CLAUDECODE=1 CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS=1 /Users/zain/.local/share/claude/versions/2.1.87 --agent-id alpha\@demo-team --agent-name alpha --team-name demo-team --agent-color blue --parent-session-id 938a1938-a6ed-4df4-a07e-998c7d04c520 --model claude-opus-4-6
Note: --model claude-opus-4-6 is the 200K variant. The 1M variant would be claude-opus-4-6[1m].
/model Menu Inside Agent Pane
1. Default (recommended) Opus 4.6 with 1M context · Most capable for complex work
2. Sonnet Sonnet 4.6 · Best for everyday tasks
3. Sonnet (1M context) Sonnet 4.6 with 1M context · Billed as extra usage
4. Haiku Haiku 4.5 · Fastest for quick answers
5. Opus 4.6 ✓ Newer version available · select Opus for Opus 4.6 (with 1M context)
Option 5 (200K) is selected instead of option 1 (1M).
Related: Settings.json Has the Same Bug (With Known Fix)
Setting "model": "opus" in .claude/settings.json also forces the main session to 200K. Removing the model key entirely fixes it — the main session then auto-detects the plan entitlement and gets 1M. This is documented in #34435.
The agent subprocess issue is the same root cause but has no workaround — Claude Code always injects --model claude-opus-4-6 regardless of whether the orchestrator passes a model parameter.
Expected Behavior
When no explicit model override is requested, agent subprocesses should either:
- Not pass
--modelto the subprocess (let it use "Default" = Opus 4.6 with 1M) - Pass the 1M-aware model ID (
claude-opus-4-6[1m]) when the parent session has 1M context
Workaround Attempted (Did Not Work)
- Setting
ANTHROPIC_DEFAULT_OPUS_MODEL=claude-opus-4-6[1m]in settings.json env block — not passed through to subprocess - Omitting
modelparameter in Agent tool calls — Claude Code still injects--model claude-opus-4-6into subprocess command - Removing
modelfrom agent definition frontmatter — same result
15 Comments
Found 3 possible duplicate issues:
This issue will be automatically closed as a duplicate in 3 days.
🤖 Generated with Claude Code
This is NOT a duplicate of the suggested issues. Here's why:
Tested on v2.1.87 (latest) — all three suggested duplicates are on older versions (v2.1.76, v2.1.80, v2.1.81). The bug persists on the latest version.
Community patches don't work on v2.1.87 — the binary patch from #34421 (gist by keyur2maru) targets minified function names that have changed in v2.1.87. No working workaround exists for the current version.
Additional finding from testing:
team_name) DO inherit 1M correctly — confirmedclaude-opus-4-6[1m]via system promptteam_name, spawned via TeamCreate) get 200K — subprocess command always has--model claude-opus-4-6without[1m]Unique evidence in this issue:
--model claude-opus-4-6(without[1m])/modelmenu inside teammate pane showing option 5 (Opus 4.6, 200K) selected instead of option 1 (Default, 1M)"model": "opus"also caps the main session to 200K (related but separate angle)ANTHROPIC_DEFAULT_OPUS_MODEL,CLAUDE_CODE_SUBAGENT_MODEL)If this is still considered a duplicate of #34421, that issue needs attention — it's been open for 16 days with no official response while the community writes binary patches to work around it.
Additional testing: all known workarounds fail on v2.1.87
I reviewed all three suggested duplicate issues (#34421, #36670, #39047) in detail and tested every workaround mentioned across their threads. None work on the current version.
Workarounds tested and results:
| Workaround | Source | Result on v2.1.87 |
|------------|--------|-------------------|
| Binary patch (gist by @keyur2maru) | #34421 | Failed — minified function names changed between v2.1.76 and v2.1.87, patch targets don't exist |
|
ANTHROPIC_DEFAULT_OPUS_MODEL=claude-opus-4-6[1m]env var | #36670 | Failed — env var is not passed through to teammate subprocess ||
CLAUDE_CODE_SUBAGENT_MODEL=opus[1m]env var | #36670 | Failed — only works for standalone subagents, not teammates ||
"model": "opus[1m]"in settings.json | #36670 | Failed — teammate spawn command still strips[1m]|| Omitting
modelparameter in Agent tool calls | Own testing | Failed — Claude Code still injects--model claude-opus-4-6into teammate subprocess regardless || Removing
modelfrom agent definition frontmatter | Own testing | Failed — same result |What DOES work (for reference):
| Scenario | Context Window | How |
|----------|---------------|-----|
| Main session | 1M | Remove
"model"from settings.json entirely — plan entitlement auto-detects || Standalone subagents (Agent tool, no
team_name) | 1M | Inherits from parent correctly — confirmedclaude-opus-4-6[1m]in system prompt || Teammates (TeamCreate + Agent with
team_name) | 200K | No fix available —--model claude-opus-4-6is always hardcoded in the tmux spawn command |Root cause (confirmed via subprocess inspection):
The teammate spawn path always constructs the command with
--model claude-opus-4-6(200K). The[1m]suffix is stripped during model resolution before the tmux command is built. This is the same root cause as #34421 but confirmed still present through v2.1.87.The standalone subagent path (in-process) correctly inherits the full model ID including
[1m]. The teammate path (out-of-process via tmux) does not. The divergence is in how these two spawn paths resolve the model string.Impact:
Agent Teams is the recommended way to run multi-agent work with visible tmux panes — but every teammate is silently running at 1/5th the context window. Users paying for 1M context on Team/Max plans don't get it on teammates, with no indication that context was downgraded.
This is a significant issue for Team plan users. While the root cause needs a fix upstream (subprocesses should inherit the plan's context entitlement), there are a couple of workarounds:
1. PreToolUse hook to warn on thin subagent prompts:
If subagents get 200K instead of 1M, they need more focused prompts. A hook can catch this:
2. Use CLAUDE.md instruction to compensate:
Add to your project's CLAUDE.md:
Neither workaround gives subagents 1M context, but they help mitigate the quality impact by ensuring subagents receive sufficient context in their prompts.
I've just updated the patch gist and tested it on v2.1.81 and v2.1.87. Only thing to keep in mind is that you must instruct team lead to spawn teammates without specifying model so that it inherits model name from the team lead
https://gist.github.com/keyur2maru/0d2e4e728d7537aa7c36cbc936b2b6b4
Thanks for the updated patch — confirming it works on v2.1.87 is valuable since older patches broke with minified name changes between releases.
https://github.com/anthropics/claude-code/issues/34421#issuecomment-4167530041
Tested both workarounds on v2.1.89, sharing results:
@Reasonably
"teammateDefaultModel": nullin~/.claude.json— no dice on v2.1.89. Teammates still spawn with 200K.@keyur2maru your patch approach works. Adapted it for v2.1.89 and teammates are getting 1M now. Thanks for the gist 👊
Minified names changed again (shocker). Updated mappings for anyone patching v2.1.89:
| Component | v2.1.81 | v2.1.87 | v2.1.89 |
|-----------|---------|---------|-------------|
| Default model fn |
Wg7()|Ex7()|$__()|| Model table |
sY_|cD_|LXH|| Lead session model fn |
mh()|Gh()|yG()|Don't forget
codesign -f -s -after patching on macOS. Gets nuked on every update obviously.<img width="1655" height="78" alt="Image" src="https://github.com/user-attachments/assets/3166aaac-d673-47ed-999e-2e879a99175d" />
I think you maybe instruct to orchestrator spawn specific models.
Claude code don't modify model param only if
"teammateDefaultModel": nulland use default(inherit from orchestrator)Edited
/model opus[1m])Workaround found (Claude Code v2.1.90): Setting
CLAUDE_CODE_SUBAGENT_MODELtoclaude-opus-4-6[1m]successfully gives subagents/teammates the full 1M context window.Critical detail: Do NOT pass the
modelparameter on the Agent tool invocation. When Claude passesmodel: "opus"explicitly, it overrides the env var and resolves to standard 200K Opus. The env var only takes effect when no explicit model is passed.Tested with Agent Teams (teammates spawned via
CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS=1) - confirmed 1M context on the spawned teammate.Confirmed still broken on v2.1.91 — teammate tmux path never checks
CLAUDE_CODE_SUBAGENT_MODELTraced the minified CLI binary on v2.1.91 to confirm the root cause. The teammate (tmux) model resolution and the standalone subagent (in-process) model resolution are two completely separate code paths, and only the in-process path checks the env var.
v2.1.91 model resolution paths
In-process subagents (standalone
Agenttool, noteam_name):Tmux teammates (
TeamCreate+Agentwithteam_name):jDK()/j17()never callIy6()and never checkCLAUDE_CODE_SUBAGENT_MODEL. The env var is completely bypassed for tmux teammates.Why @regimantasm's env var fix may be a false positive
The
CLAUDE_CODE_SUBAGENT_MODELenv var only works throughIy6(), which is the in-process runner path. If @regimantasm tested with a standaloneAgentcall (noteam_name), it would work. Tmux teammates spawned viaTeamCreatewill still get 200K.Minified function name mapping (v2.1.91)
| Concept | v2.1.89 | v2.1.91 |
|---------|---------|---------|
| Teammate default model resolver |
eXK()|jDK()|| Teammate model resolver |
U67()|j17()|| Base model ID (200K) |
J18()|D78()|| Model table (returns
"claude-opus-4-6") |vZ6| same || Subagent model resolver (has env var check) |
oN6()|Iy6()|| Lead session model getter |
gx()| same pattern |Suggested fix
jDK()(teammate default model) should checkCLAUDE_CODE_SUBAGENT_MODELthe same wayIy6()does, orj17()should delegate toIy6()instead of having a separate resolution chain.Community workaround — regex-based binary patch (works on v2.1.87 through v2.1.91)
Unlike patches that target hardcoded minified function names (which break every release), this regex approach finds the
--model ${FUNC([VAR])}pattern regardless of what the minified names are, and injects a ternary to force[1m]:Tested across v2.1.87, v2.1.89, and v2.1.91 — patches 6 tmux spawn points each time without needing to update minified variable names. Must re-run after every
npm install -g @anthropic-ai/claude-code.Confirming @Reasonably's workaround works on v2.1.92 (latest). Steps:
"teammateDefaultModel": null\in \~/.claude.json\/model opus[1m]\in the lead session (NOT "Default")model\when spawning teammatesTeammates correctly show "Opus 4.6 (1M context)" in tmux after this. Posted full details with before/after on #34421.
Also noting: this bug is tmux-specific. In-process mode (iTerm2 without tmux, Ghostty) gives teammates 1M without any workaround.
Same behavior on our end at BluMint — orchestrator-spawned subagents land on the 200K variant regardless of configuration attempts. Our parent session auto-resolves to
claude-opus-4-7[1m]correctly via Max plan entitlement, but subagent subprocesses never get that inheritance because--model claude-opus-4-Xis always injected into the spawn command.Our workflow is multi-agent research/planning across a large monorepo — 200K subagents compact mid-investigation and lose their reasoning chain. The context-window delta is load-bearing for us.
Both your proposed fixes would work — ideally "don't inject
--model" so subagents inherit the same entitlement-based auto-detection the parent uses, or at minimum pass through the[1m]suffix when the parent has it. Would very much appreciate movement here; this is a recurring blocker.Closing for now — inactive for too long. Please open a new issue if this is still relevant.
This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.