[BUG] Agent teams teammates don't inherit ANTHROPIC_* env vars when spawned in tmux panes

Resolved 💬 4 comments Opened Mar 4, 2026 by NickREdwards Closed Mar 5, 2026

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

  1. Set ANTHROPIC_BASE_URL to a custom API endpoint (e.g., a Portkey proxy)
  2. Set ANTHROPIC_CUSTOM_HEADERS with authentication headers for the proxy
  3. Launch Claude Code (team lead authenticates successfully)
  4. Create an agent team with TeamCreate
  5. Spawn a teammate with Task tool using team_name parameter
  6. Observe: teammate gets 401 authentication 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_*_MODEL env vars)
  • CLAUDE_CODE_TEAMMATE_COMMAND env var exists but is not documented in the agent teams docs or troubleshooting section

View original on GitHub ↗

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