Agent Teams teammates ignore model/auth environment variables (incomplete fix from #23561)

Resolved 💬 5 comments Opened Mar 10, 2026 by cjpeterein Closed Apr 13, 2026

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:

  1. 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.
  2. 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.
  3. Any setup using ANTHROPIC_DEFAULT_OPUS_MODEL — the --model CLI 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_MODEL or ANTHROPIC_DEFAULT_OPUS_MODEL is set, the spawned teammate should use that value instead of the internal lookup table.
  • The --model flag 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

  1. 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"
``

  1. Enable agent teams:

``bash
export CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS=1
``

  1. Start Claude Code and prompt it to create a 2-agent team
  2. Observe that spawned teammates use --model claude-opus-4-6 (or a dated variant like claude-sonnet-4-5-20250929) from the internal lookup table, ignoring ANTHROPIC_DEFAULT_OPUS_MODEL
  3. If the proxy doesn't accept the resolved model ID, teammates fail with auth/model errors

Scenario B: Non-US Bedrock region

  1. 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"
``

  1. Enable agent teams and spawn teammates
  2. Teammates are spawned with --model us.anthropic.claude-opus-4-6-v1 (hardcoded US prefix)
  3. Bedrock rejects the request because us.anthropic.* is not valid in eu-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:

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):

  1. Propagate ANTHROPIC_MODEL in the spawn env and don't pass --model (let the env var control it), OR
  2. Pass the parent's actual model ID (from ANTHROPIC_MODEL or the resolved ARN) as the --model value 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.

View original on GitHub ↗

This issue has 5 comments on GitHub. Read the full discussion on GitHub ↗