Agent team teammates don't inherit Bedrock model ARN from env overrides

Resolved 💬 16 comments Opened Feb 28, 2026 by GingerJiang714 Closed Apr 15, 2026

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.json env 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

  1. Configure Claude Code for Bedrock with env overrides in settings.json
  2. Enable agent teams: CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS=1, teammateMode: "tmux"
  3. Create a team with TeamCreate
  4. Spawn teammates using Task tool with team_name parameter (without specifying model)
  5. 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-6 is 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

View original on GitHub ↗

16 Comments

github-actions[bot] · 4 months ago

Found 1 possible duplicate issue:

  1. https://github.com/anthropics/claude-code/issues/23561

This issue will be automatically closed as a duplicate in 3 days.

  • If your issue is a duplicate, please close it and 👍 the existing issue instead
  • To prevent auto-closure, add a comment or 👎 this comment

🤖 Generated with Claude Code

GingerJiang714 · 4 months ago

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 | --model flag hardcodes API-format name instead of Bedrock-qualified ID | ANTHROPIC_DEFAULT_*_MODEL env 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_*_MODEL env 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-6us.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 the ANTHROPIC_DEFAULT_*_MODEL environment variables.

This is a separate bug in the env propagation / model resolution path for agent team teammates.

GingerJiang714 · 4 months ago

Workaround Found

After deep-diving into the minified cli.js source, I found the root cause and a working local patch.

Root Cause

In the teammate spawning function (KZY in minified code), the default model for teammates is set by:

let _ = A.model ?? XvA;

Where XvA = aA1.firstParty which 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-6 on the CLI command to the tmux pane.

The teammate process receives this literal model name via the --model CLI flag, which bypasses the ANTHROPIC_DEFAULT_OPUS_MODEL env var resolution (the ib() 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:

sed -i.bak 's/XvA=aA1\.firstParty/XvA="opus"/' cli.js

This changes the default from "claude-opus-4-6" to "opus". When the teammate receives --model opus, it resolves through ib() → checks process.env.ANTHROPIC_DEFAULT_OPUS_MODEL → uses the Bedrock ARN.

Patch 2 — Fix the Task tool's model alias map:

sed -i '' 's/juA={opus:"claude-opus-4-6",sonnet:"claude-sonnet-4-5-20250929",haiku:"claude-haiku-4-5-20251001"}/juA={opus:"opus",sonnet:"sonnet",haiku:"haiku"}/' cli.js

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_MODEL env var set (e.g., via .zshrc sourcing credentials). This is needed so the teammate process can resolve "opus" → Bedrock ARN.

Result

  • Before: teammates get --model claude-opus-4-6 → 400 error on Bedrock
  • After: teammates get --model opus → resolved via env var to Bedrock ARN → works

Note

These patches are overwritten on npm update. Re-apply after upgrading Claude Code. One-liner:

cd /opt/homebrew/lib/node_modules/@anthropic-ai/claude-code && \
sed -i.bak 's/XvA=aA1\.firstParty/XvA="opus"/' cli.js && \
sed -i '' 's/juA={opus:"claude-opus-4-6",sonnet:"claude-sonnet-4-5-20250929",haiku:"claude-haiku-4-5-20251001"}/juA={opus:"opus",sonnet:"sonnet",haiku:"haiku"}/' cli.js

Suggested Proper Fix

The teammate spawning code should either:

  1. Pass the alias ("opus") instead of the resolved model name, letting each teammate resolve it via its own env vars
  2. Or resolve the model through ib()/ok()/t_() at spawn time (which checks ANTHROPIC_DEFAULT_*_MODEL env vars) and pass the Bedrock ARN directly
jrgleason · 4 months ago

@GingerJiang714 Do you have any idea what the workaround would look like for windows? I think the js file is in the exe

jrgleason · 4 months ago

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.

MasterXue · 4 months ago

https://github.com/anthropics/claude-code/blob/main/CHANGELOG.md#2172

  • Fixed team agents to inherit the leader's model

2.1.72 fix the bug, but I haven't verified it yet.

MasterXue · 4 months ago
https://github.com/anthropics/claude-code/blob/main/CHANGELOG.md#2172 * Fixed team agents to inherit the leader's model 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.

jrgleason · 4 months ago

Also to be clear I am using --model opusplan not opus

MasterXue · 4 months ago

v2.1.74 maybe fix it, i tested it

jrgleason · 4 months ago

@MasterXue Just tried and no dice still see

@team-lead❯ Implement secure authentication
  ⎿  API Error (claude-opus-4-6): 400 The provided model identifier is invalid.. Try /model to switch to
     us.anthropic.claude-opus-4-1-20250805-v1:0.
❯ /status

────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
  Settings:  Status   Config   Usage  (←/→ or tab to cycle)

  Version: 2.1.74
  Session name: /rename to add a name
  Session ID: ....
  cwd: ...
  API provider: AWS Bedrock
  AWS region: us-east-2
  Additional CA cert(s): ....
MasterXue · 4 months ago
@MasterXue Just tried and no dice still see `` @team-lead❯ Implement secure authentication ⎿  API Error (claude-opus-4-6): 400 The provided model identifier is invalid.. Try /model to switch to us.anthropic.claude-opus-4-1-20250805-v1:0. ` ` ❯ /status ──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── Settings: Status Config Usage (←/→ or tab to cycle) Version: 2.1.74 Session name: /rename to add a name Session ID: .... cwd: ... API provider: AWS Bedrock AWS region: us-east-2 Additional CA cert(s): .... ``

Indeed, someone have reported that there are still problems, and I need to check it again.

jrgleason · 4 months ago

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.

East-rayyy · 4 months ago

@GingerJiang714 — this is exactly the problem I solved. The root cause is that ANTHROPIC_DEFAULT_*_MODEL env 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.

GingerJiang714 · 4 months ago

@East-rayyy Thanks for providing the script, I will try it out.

github-actions[bot] · 3 months ago

Closing for now — inactive for too long. Please open a new issue if this is still relevant.

github-actions[bot] · 2 months ago

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.