Claude Code 2.1.179: Three Gateway Reliability Fixes Every Operator Running a Custom API Endpoint Must Know

Claude Code 2.1.179 patches three silent failure modes that specifically affect teams routing through a custom API gateway: a 401 auth regression in claude agents workers, compaction ignoring the configured fallback model, and mid-stream response loss on connection drops.

TheRouter Newsroomvia Anthropic
A data routing diagram showing Claude Code connecting through a custom API gateway endpoint, with authentication tokens and fallback model chains highlighted

When Claude Code 2.1.179 shipped on June 16, the headline fixes read like a maintenance release: scroll regressions, UI glitches, survey bugs. But buried in the list are three regressions that have been silently breaking setups for teams running Claude Code through a custom API gateway — and those fixes matter far more than any UX tweak.

What changed in 2.1.179

The three gateway-critical fixes:

1. claude agents workers 401 with custom ANTHROPIC_BASE_URL

If you started the Claude Code daemon from a shell where ANTHROPIC_BASE_URL and ANTHROPIC_AUTH_TOKEN were set — the standard way to point Claude Code at a self-hosted gateway, a corporate proxy, or an AI routing layer — claude agents workers would fail with 401 Invalid bearer token. The daemon inherited the custom endpoint but background workers authenticated against Anthropic's origin instead of the configured base URL.

This is the exact scenario operators use when routing Claude through a multi-provider gateway, a private VPC proxy, or a compliance-scoped endpoint. The 401 was silent; agents appeared to start but failed on first API call.

2. Compaction ignoring --fallback-model

Claude Code's auto-compaction kicks in when the context window approaches capacity — it summarizes earlier turns to free up space. If that compaction call hit a rate limit or model-availability error, it was supposed to use the --fallback-model chain. It didn't. Compaction was bypassing the configured fallback entirely, leaving sessions stranded when the primary model was overloaded.

For teams using TheRouter or any AI gateway with a fallback policy, this meant the fallback chain worked for normal requests but silently failed during compaction — one of the highest-stakes moments in a long coding session.

3. Stale cached auth after credential refresh

If API credentials were refreshed outside the running session (a common pattern with token rotation, short-lived JWT auth, or gateway-issued ephemeral tokens), Claude Code would continue using the stale cached request configuration and fail with auth errors — even though valid credentials were available. The session had to be restarted to pick up the new credentials.

Why these three bugs matter for routing teams

These failures share a pattern: they surface specifically in production gateway deployments, not in the default api.anthropic.com path.

The ANTHROPIC_BASE_URL 401 is invisible if you test Claude Code against Anthropic's own API. You discover it when you deploy to a team that routes through a shared gateway, only to find workers silently dropping requests.

The compaction fallback skip is intermittent. It only fires when your primary model is overloaded at the exact moment context fills up. In routing setups with aggressive fallback policies, this happens more often because the primary model may be rate-limited while the session is still running.

The stale credential cache is most painful for teams using workload identity federation, time-limited API tokens, or gateway-issued credentials that rotate on a schedule. Anthropic now ships workload identity federation for Claude, making token rotation patterns more common — and the stale cache bug more likely to trigger.

The router/operator angle

If your team runs Claude Code behind a gateway layer — whether that's a self-hosted proxy, a cloud-native AI gateway, or a multi-provider routing service — here's what to check after upgrading to 2.1.179:

Auth regression audit: Verify that claude agents (background workers) correctly hit your custom base URL. Start a worker session, inspect request logs on your gateway, and confirm the Authorization header contains the token issued by your gateway rather than a stale Anthropic-origin token.

Compaction fallback validation: Configure a session with a known-busy primary model and let auto-compaction fire. Confirm your fallback model receives the compaction request on your gateway logs. This is now fixed in 2.1.179, but validate it in your environment since compaction timing varies.

Credential rotation handling: If you rotate API keys or use short-lived tokens, test the refresh path. In 2.1.179, a credentials refresh outside the session should now be picked up without a daemon restart. Confirm this behavior against your token rotation cadence.

Fallback model in managed settings: If you deploy Claude Code enterprise-wide via managed settings (managedSettings.json), ensure fallbackModel is configured at the org level. The compaction fix means this setting will now actually be respected during high-load compaction events.

What TheRouter users should watch

Teams routing Claude Code through TheRouter benefit from TheRouter's provider routing and fallback policies for normal inference requests. The 2.1.179 compaction fix closes the gap that was bypassing gateway fallback during auto-compaction — meaning your fallback configuration is now honored end-to-end, not just on primary request paths.

If you previously saw compaction errors when primary models were rate-limited under your routing policy, upgrading Claude Code to 2.1.179 should resolve those sessions stalling out. Monitor your gateway request logs during long coding sessions to verify compaction requests flow through the expected fallback path.

The ANTHROPIC_BASE_URL fix is critical for any deployment where Claude Code workers are expected to route through a custom endpoint: verify the daemon is started in the same shell environment where your gateway credentials are set.

Upgrade path

Update via npm:

npm install -g @anthropic-ai/claude-code@latest
claude --version  # should show 2.1.179

The three reliability fixes are not gated behind any feature flag. Upgrading is sufficient.

Help & contact