Agent Teams teammates ignore model/auth environment variables (incomplete fix from #23561)
Preflight Checklist
- [x] I have searched existing issues and this hasn't been reported yet
- [x] This is a single bug report
- [x] I am using the latest version of Claude Code
What's Wrong?
Agent Teams teammates do not respect ANTHROPIC_DEFAULT_OPUS_MODEL, ANTHROPIC_MODEL, or CLAUDE_CODE_SUBAGENT_MODEL environment variables. When spawning teammates via tmux, the --model CLI flag is hardcoded from an internal lookup table that only contains Anthropic API model IDs (e.g., claude-opus-4-6) or US-prefixed Bedrock IDs (e.g., us.anthropic.claude-opus-4-6-v1).
This was originally reported in #23561 and partially fixed in v2.1.45 (Bedrock env vars are now propagated to child processes). However, the model ID resolution remains broken for:
- Custom API proxies (
ANTHROPIC_BASE_URL+ANTHROPIC_AUTH_TOKEN) — proxies that don't accept dated model identifiers (e.g.,claude-sonnet-4-5-20250929) get 401 errors because the spawn path resolves to dated versions instead of using the configured model name. - Non-US Bedrock regions — the internal lookup table only contains
us.anthropic.*prefixed IDs, so EU/AP cross-region inference profiles fail with HTTP 400. - Any setup using
ANTHROPIC_DEFAULT_OPUS_MODEL— the--modelCLI flag on the spawned process overrides this env var entirely.
The spawned teammate command looks like:
cd /path/to/project && \
CLAUDECODE=1 \
CLAUDE_CODE_USE_BEDROCK=1 \
CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS=1 \
/path/to/claude \
--agent-id teammate@team-name \
--model claude-opus-4-6 \ # <-- hardcoded, ignores env vars
...
What Should Happen?
Teammate processes should use the same model ID as the parent session. Specifically:
- If
ANTHROPIC_MODELorANTHROPIC_DEFAULT_OPUS_MODELis set, the spawned teammate should use that value instead of the internal lookup table. - The
--modelflag should not override user-configured env vars, or the spawn path should pass through the parent's resolved model ID rather than normalizing it. - For Bedrock users, the region prefix (e.g.,
eu.,ap.,us.) from the parent's model ARN/ID should be preserved.
Error Messages/Logs
Custom proxy setup:
API Error: 401 key not allowed to access model. Tried to access claude-sonnet-4-5-20250929
Bedrock non-US region:
API Error (us.anthropic.claude-opus-4-6-v1): 400 The provided model identifier is invalid.
Non-Bedrock proxy:
Not logged in · Please run /login
Steps to Reproduce
Scenario A: Custom API proxy
- Set environment variables:
``bash``
export ANTHROPIC_BASE_URL="https://your-proxy.example.com"
export ANTHROPIC_AUTH_TOKEN="your-token"
export ANTHROPIC_DEFAULT_OPUS_MODEL="us.anthropic.claude-opus-4-6-v1"
- Enable agent teams:
``bash``
export CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS=1
- Start Claude Code and prompt it to create a 2-agent team
- Observe that spawned teammates use
--model claude-opus-4-6(or a dated variant likeclaude-sonnet-4-5-20250929) from the internal lookup table, ignoringANTHROPIC_DEFAULT_OPUS_MODEL - If the proxy doesn't accept the resolved model ID, teammates fail with auth/model errors
Scenario B: Non-US Bedrock region
- Configure Bedrock with a non-US inference profile:
``bash``
export CLAUDE_CODE_USE_BEDROCK=1
export ANTHROPIC_MODEL="arn:aws:bedrock:eu-west-1:ACCOUNT:inference-profile/eu.anthropic.claude-opus-4-6-v1"
- Enable agent teams and spawn teammates
- Teammates are spawned with
--model us.anthropic.claude-opus-4-6-v1(hardcoded US prefix) - Bedrock rejects the request because
us.anthropic.*is not valid ineu-west-1
Claude Model
Opus
Is this a regression?
No. Agent Teams have always been broken when using a proxy. #23561 was marked as fixed in v2.1.45 but the fix was incomplete.
Last Working Version
N/A — the model resolution part was never fully fixed.
Claude Code Version
2.1.72 (Claude Code)
Platform
Other (affects AWS Bedrock, custom proxies via ANTHROPIC_BASE_URL, and any non-direct Anthropic API setup)
Operating System
macOS, Linux, Windows
Terminal/Shell
wezterm
Additional Information
Prior issues:
- #23561 — original report, partially fixed in v2.1.45 (env var propagation added, model resolution still broken)
- #25193 — duplicate focused on Bedrock, contains a workaround using
CLAUDE_CODE_TEAMMATE_COMMAND
Root cause (from @vladskiy's analysis in #23561):
The internal model lookup table is hardcoded with US Bedrock IDs:
Ki = { firstParty: "claude-opus-4-6", bedrock: "us.anthropic.claude-opus-4-6-v1", ... }
The spawn path uses this table instead of the parent session's actual resolved model ID. The --model CLI flag on the child process then overrides any env var the user has set.
Suggested fix (either approach):
- Propagate
ANTHROPIC_MODELin the spawn env and don't pass--model(let the env var control it), OR - Pass the parent's actual model ID (from
ANTHROPIC_MODELor the resolved ARN) as the--modelvalue instead of using the lookup table
Current workaround:
A wrapper script via CLAUDE_CODE_TEAMMATE_COMMAND that rewrites the --model argument before exec-ing the real binary. See the gist by @trhinehart-attentive.
This issue has 5 comments on GitHub. Read the full discussion on GitHub ↗