Max Plan subscribers billed through API key when subagents dispatch - $152 unexpected charges

Resolved 💬 4 comments Opened Mar 27, 2026 by tciovacco Closed May 26, 2026

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_KEY set in ~/.env for 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:

  1. Detected ANTHROPIC_API_KEY in my environment
  2. Routed their API calls through the API key instead of my Max Plan subscription
  3. Generated hundreds of Sonnet 4.6 API requests (100K-166K input tokens each)
  4. 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, Standard service 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

  1. Subagent processes should inherit the parent's Max Plan authentication, not fall back to environment API keys
  2. OR: Claude Code should unset/ignore ANTHROPIC_API_KEY in subagent environments when the user is on Max Plan
  3. OR: At minimum, warn the user if an API key is detected and subagents will use it instead of the subscription

Reproduction

  1. Be a Max Plan subscriber
  2. Have ANTHROPIC_API_KEY set in your shell environment (e.g., via ~/.env)
  3. Use Claude Code and dispatch subagents via the Agent tool
  4. Check your Anthropic API console - the subagent requests appear as API charges, not Max Plan usage

View original on GitHub ↗

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