[BUG] Agent teams teammates don't inherit ANTHROPIC_* env vars when spawned in tmux panes
Bug description
When agent teams spawns teammates in tmux split panes, the teammate command only explicitly passes CLAUDECODE=1 and CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS=1 as environment variables. Critical authentication variables (ANTHROPIC_AUTH_TOKEN, ANTHROPIC_BASE_URL, ANTHROPIC_CUSTOM_HEADERS, ANTHROPIC_CUSTOM_HEADERS_B64) are not forwarded from the lead's environment to the teammate's tmux pane.
This causes immediate 401 authentication errors for any setup that uses custom API endpoints or proxy services (e.g., Portkey, Azure AI Foundry, corporate API gateways) where authentication relies on ANTHROPIC_CUSTOM_HEADERS or ANTHROPIC_CUSTOM_HEADERS_B64.
Steps to reproduce
- Set
ANTHROPIC_BASE_URLto a custom API endpoint (e.g., a Portkey proxy) - Set
ANTHROPIC_CUSTOM_HEADERSwith authentication headers for the proxy - Launch Claude Code (team lead authenticates successfully)
- Create an agent team with
TeamCreate - Spawn a teammate with
Tasktool usingteam_nameparameter - Observe: teammate gets
401authentication errors on every API call
Expected behavior
Teammates should inherit the lead's ANTHROPIC_* environment variables, or all ANTHROPIC_* vars should be explicitly passed in the teammate spawn command sent to the tmux pane.
Actual behavior
The teammate spawn command sent to the tmux pane is:
cd /path && env CLAUDECODE=1 CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS=1 \
/path/to/.local/share/claude/versions/X.Y.Z \
--agent-id name@team --agent-name name --team-name team ...
Only CLAUDECODE and CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS are explicitly set. The new tmux pane inherits from tmux's global environment, which typically doesn't have the ANTHROPIC_* variables.
Workaround
Setting CLAUDE_CODE_TEAMMATE_COMMAND to a wrapper script that sets up auth before launching the binary works. However, this requires users to know about this undocumented env var.
A more complete fix would be to forward all ANTHROPIC_* environment variables from the lead process to the teammate spawn command.
Environment
- Claude Code version: 2.1.44
- OS: macOS (Darwin 25.2.0)
- Display mode: tmux split panes (
teammateMode: auto) - Auth: Custom API endpoint via
ANTHROPIC_BASE_URL+ANTHROPIC_CUSTOM_HEADERS
Related
- Similar issue pattern to #23716 / #25079 (agent teams ignoring
ANTHROPIC_DEFAULT_*_MODELenv vars) CLAUDE_CODE_TEAMMATE_COMMANDenv var exists but is not documented in the agent teams docs or troubleshooting section
This issue has 4 comments on GitHub. Read the full discussion on GitHub ↗