Max Plan subscribers billed through API key when subagents dispatch - $152 unexpected charges
Bug: Claude Code subagents use API key instead of Max Plan subscription
Summary
I'm a Max Plan subscriber ($200/month). Claude Code's subagent dispatches (via the Agent tool) are silently routing through my Anthropic API key instead of the Max Plan subscription, resulting in $152 in unexpected API charges this month that should have been $0.
Environment
- Claude Code CLI (latest, Windows 11)
- Anthropic Max Plan ($200/month subscription)
ANTHROPIC_API_KEYset in~/.envfor use by a separate desktop application- Claude Opus 4.6 model
What Happened
During normal Claude Code development sessions, I used the Agent tool to dispatch specialized subagents (e.g., engineering-backend-architect, Explore, code-reviewer). These subagents:
- Detected
ANTHROPIC_API_KEYin my environment - Routed their API calls through the API key instead of my Max Plan subscription
- Generated hundreds of Sonnet 4.6 API requests (100K-166K input tokens each)
- Billed $152.04 to my API account
Evidence
The Anthropic Console logs show:
- ~800+ API requests over 5 development sessions on March 25-26
- All requests are
claude-sonnet-4-6,Streaming,Standardservice tier - Input tokens range from 50K to 166K per request, growing incrementally (tool-use pattern)
- Multiple parallel streams at the same timestamps (2-3 concurrent subagents)
- Request frequency: every 3-10 seconds, matching subagent tool-use loops
- Total cost: $152.04 on a single API key
Expected Behavior
All Claude Code processes (including subagents spawned by the Agent tool) should route through the Max Plan subscription when the user is a Max Plan subscriber. The presence of ANTHROPIC_API_KEY in the environment should NOT cause subagents to bypass the Max Plan.
Actual Behavior
Subagent child processes find ANTHROPIC_API_KEY in the environment and use it for direct API calls instead of the Max Plan auth. The parent Claude Code process correctly uses Max Plan, but its child processes do not inherit this routing.
Impact
- Financial: $152 in charges that should have been $0 under Max Plan
- Trust: Users set API keys for legitimate purposes (other applications). They should not need to remove their API key to prevent Claude Code from billing through it
- Silent failure: No warning, no prompt, no indication that subagents are using the API key instead of the subscription
Suggested Fix
- Subagent processes should inherit the parent's Max Plan authentication, not fall back to environment API keys
- OR: Claude Code should unset/ignore
ANTHROPIC_API_KEYin subagent environments when the user is on Max Plan - OR: At minimum, warn the user if an API key is detected and subagents will use it instead of the subscription
Reproduction
- Be a Max Plan subscriber
- Have
ANTHROPIC_API_KEYset in your shell environment (e.g., via~/.env) - Use Claude Code and dispatch subagents via the Agent tool
- Check your Anthropic API console - the subagent requests appear as API charges, not Max Plan usage
This issue has 4 comments on GitHub. Read the full discussion on GitHub ↗