Claude Code 2.1.203: The ANTHROPIC_BASE_URL Drop That Was Silently Routing to the Wrong Endpoint

Claude Code 2.1.203 fixes a critical background-agent bug that silently dropped ANTHROPIC_BASE_URL, sending API keys to Anthropic's default endpoint and failing with 401. Any team routing Claude Code through a custom AI gateway must audit and upgrade.

Published via Anthropic Claude Code

Archive item produced with AI assistance from the cited source and published without individual review. Editor of record: Joe Werner.

Abstract diagram of a routing path reconnecting after a broken link, on a muted dark background with subtle network lines

If your team runs Claude Code through a custom AI gateway — using ANTHROPIC_BASE_URL to point at a proxy, local forwarder, or another endpoint — version 2.1.203 contains a fix that directly affects you. Background and agent-view sessions were silently dropping a shell-exported ANTHROPIC_BASE_URL, routing API requests to Anthropic's default endpoint instead of your configured one. The result: 401 errors that look like key problems but are actually routing problems.

The fix landed in 2.1.203 alongside 30+ other reliability improvements targeting background agents and worktree-isolated subagents. The scope of this release is unusual — it addresses a cluster of daemon, session, and subagent lifecycle bugs that have accumulated since the background-agent architecture matured.

What happened

Claude Code 2.1.203 was released on July 8, 2026. The changelog lists corrections for background session behavior, daemon reliability, PATH inheritance, worktree isolation, and subagent lifecycle management.

The operationally critical item: background and agent-view sessions were dropping a shell-exported ANTHROPIC_BASE_URL, sending API requests to the default endpoint and failing with 401. This is a silent regression — no error message points at the routing misconfiguration. Teams may have attributed 401s to key rotation or expiry issues rather than a gateway routing failure.

A second issue compounds this: background agents were inheriting a stale PATH from the daemon instead of the dispatching shell. For teams using custom gateway binaries or wrapper scripts that are only present in the user's shell PATH, background agents silently fell back to system defaults, missing required tools entirely.

Also fixed: the daemon's session token going stale caused sessions to become permanently unresponsive — unable to attach, reply, or stop — until manually killed. The fix adds automatic recovery.

Why it matters for AI engineering teams

The ANTHROPIC_BASE_URL drop is the highest-severity item for any team operating a custom AI gateway or proxy layer. The failure pattern is subtle:

  1. Developer exports ANTHROPIC_BASE_URL=https://my-gateway.internal/v1 in their shell.
  2. They launch a background agent session from that shell.
  3. The background session does not inherit the exported variable.
  4. All API calls go to https://api.anthropic.com instead.
  5. The gateway never sees the request. The 401 error appears to be a key problem.

This means an entire class of background agent runs may have been bypassing your routing policy, cost controls, observability layer, or custom fallback logic — depending on what your gateway provides.

For teams using worktree-isolated subagents, two additional bugs are patched: subagents sometimes ran shell commands in the parent checkout instead of their isolated worktree, and worktree creation rejected nested repositories, preventing background sessions from isolating at all in multi-repo workspaces.

Subagent delegation is also improved: agents are now less likely to re-delegate their entire task to another subagent — a behavior that inflated token spend and blurred responsibility in multi-agent workflows.

The router/operator angle

The ANTHROPIC_BASE_URL drop is a gateway hygiene problem, not just a Claude Code bug. The fix in 2.1.203 is necessary, but teams should also audit whether prior background runs bypassed their routing infrastructure.

Checklist for operators after upgrading to 2.1.203:

  1. Audit recent background-agent logs for 401 errors. If you see 401s on requests that should have gone to your gateway, those requests hit Anthropic directly. Review what data they contained and whether your usage accounting is accurate for that period.
  2. Verify gateway traffic volume. Compare your gateway's request count against what your API key consumption reports. A discrepancy suggests some runs bypassed the gateway.
  3. Re-test ANTHROPIC_BASE_URL inheritance in background sessions. After upgrading, launch a background agent and confirm it still routes through your configured endpoint.
  4. Check PATH dependencies. If your gateway wrapper or any required CLI tool is only in the user shell PATH, test that background agents pick it up correctly after the 2.1.203 fix.
  5. Review worktree-isolation configs. Teams using WorktreeCreate hooks for background session isolation should re-run their setup in multi-repo workspaces to verify nested-repository creation no longer fails.

The daemon session-token stale recovery is also relevant for long-running gateway deployments. Previously, a stale daemon token could make sessions permanently unresponsive without visible error. With 2.1.203, recovery is automatic — operators no longer need to monitor for ghost sessions.

What TheRouter users should watch or try

Teams routing Claude Code through TheRouter's gateway endpoint should upgrade to 2.1.203 immediately and re-validate that ANTHROPIC_BASE_URL is respected in background agent sessions. If you were experiencing unexplained 401 errors or seeing usage outside your gateway's ledger, this upgrade is the likely fix.

The underlying pattern — shell-exported environment variables not propagating to daemon-launched background processes — is a category of bug that can recur across any similar architecture. The operator response is to add explicit environment variable validation to your CI/CD pipeline for background agent deployments, rather than assuming shell export is sufficient.

For context: the companion release 2.1.204 (also July 8) adds a single targeted fix — hook events were not streaming during SessionStart hooks in headless sessions, which could cause remote workers to be idle-reaped mid-hook. Teams running headless gateway deployments with SessionStart hooks should apply both 2.1.203 and 2.1.204.

See the full CHANGELOG for the complete list of 2.1.203 changes.

Help & contact