Agent team teammates don't inherit Bedrock model ARN from env overrides
Description
When using agent teams with AWS Bedrock (CLAUDE_CODE_USE_BEDROCK=1), teammates spawned via tmux do not use the Bedrock model ARN configured through ANTHROPIC_DEFAULT_*_MODEL environment variables. Instead, they default to canonical Anthropic model IDs (e.g., claude-opus-4-6) which fail against the Bedrock endpoint.
Environment
- Claude Code with
CLAUDE_CODE_USE_BEDROCK=1 teammateMode: "tmux"CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS=1- Model configured via
settings.jsonenv block:
``json``
{
"ANTHROPIC_MODEL": "arn:aws:bedrock:us-west-2:XXXX:application-inference-profile/XXXX",
"ANTHROPIC_DEFAULT_OPUS_MODEL": "arn:aws:bedrock:us-west-2:XXXX:application-inference-profile/XXXX",
"ANTHROPIC_DEFAULT_SONNET_MODEL": "arn:aws:bedrock:us-west-2:XXXX:application-inference-profile/XXXX",
"ANTHROPIC_DEFAULT_HAIKU_MODEL": "arn:aws:bedrock:us-west-2:XXXX:application-inference-profile/XXXX"
}
Steps to Reproduce
- Configure Claude Code for Bedrock with env overrides in
settings.json - Enable agent teams:
CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS=1,teammateMode: "tmux" - Create a team with
TeamCreate - Spawn teammates using
Tasktool withteam_nameparameter (without specifyingmodel) - Observe the team config file at
~/.claude/teams/<team-name>/config.json
Expected Behavior
Teammates should resolve the model through the same ANTHROPIC_DEFAULT_*_MODEL env var chain and use the Bedrock ARN, matching the team lead's model resolution.
Actual Behavior
- Team lead correctly uses:
arn:aws:bedrock:us-west-2:XXXX:application-inference-profile/XXXX - Teammates default to:
claude-opus-4-6 - Teammates fail with API errors because
claude-opus-4-6is not valid for the Bedrock endpoint
From the team config:
{
"members": [
{
"name": "team-lead",
"model": "arn:aws:bedrock:us-west-2:XXXX:application-inference-profile/XXXX" // correct
},
{
"name": "sysinfo-agent",
"model": "claude-opus-4-6" // wrong - should be Bedrock ARN
}
]
}
Analysis
The teammate spawning logic appears to resolve the model to its canonical Anthropic name (claude-opus-4-6) before checking the ANTHROPIC_DEFAULT_*_MODEL env var overrides. The env vars set in settings.json may not be propagated to the tmux panes where teammates run.
Workaround
TBD - exporting env vars in shell profile may help if tmux panes source the profile.
🤖 Generated with Claude Code
16 Comments
Found 1 possible duplicate issue:
This issue will be automatically closed as a duplicate in 3 days.
🤖 Generated with Claude Code
This is not a duplicate of #23561. While both involve Bedrock model resolution for agent teams, the root cause and fix scope are different:
| | #23561 | This issue (#29660) |
|---|---|---|
| Model type | Standard Bedrock model IDs (
us.anthropic.claude-opus-4-6-v1) | Custom Bedrock application inference profile ARNs (arn:aws:bedrock:...:application-inference-profile/...) || Root cause |
--modelflag hardcodes API-format name instead of Bedrock-qualified ID |ANTHROPIC_DEFAULT_*_MODELenv var overrides are not propagated to teammate processes; model resolution ignores env var chain || Fix needed | Map model alias → standard Bedrock model ID | Propagate
ANTHROPIC_DEFAULT_*_MODELenv vars to tmux panes and resolve through the env var chain before writing to team config |Even if #23561's proposed fix (mapping
claude-opus-4-6→us.anthropic.claude-opus-4-6-v1) is implemented, it would not solve this issue, because custom application inference profile ARNs cannot be derived from model name mapping alone — they must come from theANTHROPIC_DEFAULT_*_MODELenvironment variables.This is a separate bug in the env propagation / model resolution path for agent team teammates.
Workaround Found
After deep-diving into the minified
cli.jssource, I found the root cause and a working local patch.Root Cause
In the teammate spawning function (
KZYin minified code), the default model for teammates is set by:Where
XvA = aA1.firstPartywhich resolves to the hardcoded string"claude-opus-4-6". When no model is explicitly specified for a teammate, this default is used and passed as--model claude-opus-4-6on the CLI command to the tmux pane.The teammate process receives this literal model name via the
--modelCLI flag, which bypasses theANTHROPIC_DEFAULT_OPUS_MODELenv var resolution (theib()function that checks env vars is only called when resolving aliases like"opus", not when a full model name is provided directly).Fix (local patch to cli.js)
Apply two patches to
/opt/homebrew/lib/node_modules/@anthropic-ai/claude-code/cli.js(or equivalent path):Patch 1 — Change the default teammate model from the hardcoded name to the alias:
This changes the default from
"claude-opus-4-6"to"opus". When the teammate receives--model opus, it resolves throughib()→ checksprocess.env.ANTHROPIC_DEFAULT_OPUS_MODEL→ uses the Bedrock ARN.Patch 2 — Fix the Task tool's model alias map:
This ensures that when a user explicitly passes
model: "opus"in the Task tool, it stays as the alias rather than being expanded to the Anthropic API name.Prerequisites
The teammate's shell environment must have the
ANTHROPIC_DEFAULT_OPUS_MODELenv var set (e.g., via.zshrcsourcing credentials). This is needed so the teammate process can resolve"opus"→ Bedrock ARN.Result
--model claude-opus-4-6→ 400 error on Bedrock--model opus→ resolved via env var to Bedrock ARN → worksNote
These patches are overwritten on
npm update. Re-apply after upgrading Claude Code. One-liner:Suggested Proper Fix
The teammate spawning code should either:
"opus") instead of the resolved model name, letting each teammate resolve it via its own env varsib()/ok()/t_()at spawn time (which checksANTHROPIC_DEFAULT_*_MODELenv vars) and pass the Bedrock ARN directly@GingerJiang714 Do you have any idea what the workaround would look like for windows? I think the js file is in the exe
Any update? This is causing major issues for the people in my company given no mitigation listed for Windows. Also due to it being proprietary in the part creating the EXE I couldn't fix it directly from the Claude Code source. Claude code said it would require change to the closed source portion.
https://github.com/anthropics/claude-code/blob/main/CHANGELOG.md#2172
2.1.72 fix the bug, but I haven't verified it yet.
I tested it and I'm sure it didn't fix it.
Also to be clear I am using
--model opusplannotopusv2.1.74 maybe fix it, i tested it
@MasterXue Just tried and no dice still see
Indeed, someone have reported that there are still problems, and I need to check it again.
Actually I removed Oh My claude code to make sure that wasn't the issue and it looks like it is working on that version as well. I will focus on them.
@GingerJiang714 — this is exactly the problem I solved. The root cause is that
ANTHROPIC_DEFAULT_*_MODELenv vars from settings.json aren't loaded until after the alias resolver builds its lookup tables at module init. So Bedrock ARNs never make it to the resolver.claude-alias-patch fixes this chicken-and-egg timing issue by overriding the env var whitelist and adding a fallback resolver. Your Bedrock ARNs will be resolved correctly for both the main session and teammates.
Single install script — auto-patches your instance. No re-patching needed when you change model ARNs.
@East-rayyy Thanks for providing the script, I will try it out.
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.