Team agent --model ignores ANTHROPIC_DEFAULT_*_MODEL and CLAUDE_CODE_SUBAGENT_MODEL env vars
Resolved 💬 2 comments Opened Apr 28, 2026 by rickzeke Closed Jun 3, 2026
Description
When spawning team agents via the Agent tool, the agent process receives a hardcoded --model claude-opus-4-7 CLI argument that overrides all environment-based model configuration.
Steps to reproduce
- Configure Claude Code with a non-default API backend:
{
"env": {
"ANTHROPIC_BASE_URL": "https://api.deepseek.com/anthropic",
"ANTHROPIC_MODEL": "deepseek-v4-pro[1m]",
"ANTHROPIC_DEFAULT_OPUS_MODEL": "deepseek-v4-pro",
"ANTHROPIC_DEFAULT_SONNET_MODEL": "deepseek-v4-pro",
"ANTHROPIC_DEFAULT_HAIKU_MODEL": "deepseek-v4-flash",
"CLAUDE_CODE_SUBAGENT_MODEL": "deepseek-v4-pro"
}
}
- Create a team and spawn a
general-purposeagent:
TeamCreate → Agent(subagent_type="general-purpose", team_name="test")
- Inspect the spawned agent process:
ps e -p <agent_pid> | tr ' ' '\n' | grep -E "model|ANTHROPIC"
Actual behavior
Agent process is launched with:
--model claude-opus-4-7
Despite env vars being correctly set in the agent process environment:
CLAUDE_CODE_SUBAGENT_MODEL=deepseek-v4-pro
ANTHROPIC_DEFAULT_OPUS_MODEL=deepseek-v4-pro
ANTHROPIC_MODEL=deepseek-v4-pro[1m]
The --model flag takes precedence over env vars. This causes the agent to send requests with model name claude-opus-4-7 to a non-Anthropic backend that doesn't recognize it, which triggers an error in the Ink rendering layer and crashes the agent's TUI. The agent process stays alive as a zombie but is unresponsive.
Expected behavior
Team agent spawn should:
- Respect
CLAUDE_CODE_SUBAGENT_MODELenv var for model selection, OR - Resolve the agent definition's model (
claude-opus-4-7) throughANTHROPIC_DEFAULT_OPUS_MODELmapping before passing--model, OR - At minimum not pass
--modelat all, letting the env vars take effect
Environment
- Claude Code version: 2.1.119
- OS: macOS 15.x (Darwin 25.3.0)
- Backend: DeepSeek API (Anthropic-compatible endpoint)
- The model resolution works correctly for the main session — only team agents are affected.
This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗