Claude Code 2.1.266 Fixes a Gateway-Breakage Regression: Who Is Affected and What to Do

2.1.265 silently broke all gateway and proxy setups that had CLAUDE_CODE_USE_GATEWAY set alongside an API key or custom auth. Here's the exact affected configuration, the error, and what the release adds for gateway operators.

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.

Claude Code gateway authentication error and version upgrade fix diagram

If your Claude Code sessions began failing with "Not signed in to the Cloud gateway" after upgrading to 2.1.265, the cause is a regression in how the CLAUDE_CODE_USE_GATEWAY environment variable is evaluated. Version 2.1.266, released September 9, reverts the behavior. No configuration change is required — updating is the only action needed.

What broke in 2.1.265

CLAUDE_CODE_USE_GATEWAY is an undocumented environment variable. Before 2.1.265, it was ignored unless both ANTHROPIC_BASE_URL and ANTHROPIC_AUTH_TOKEN were present. Some operators set it anyway as a defensive measure or to signal intent for future gateway routing. That was harmless until 2.1.265 changed the evaluation logic.

In 2.1.265, the variable became sufficient on its own to trigger Cloud-gateway sign-in. That meant any configuration that included CLAUDE_CODE_USE_GATEWAY together with a plain API key (ANTHROPIC_API_KEY), an apiKeyHelper function, or custom auth headers immediately hit the Cloud-gateway authentication flow — and failed, because those credentials don't satisfy it.

The exact failure mode: every request returned "Not signed in to the Cloud gateway", with no fallback to the configured credential path.

Affected configurations follow a specific pattern: CLAUDE_CODE_USE_GATEWAY is set AND the primary credential is something other than ANTHROPIC_AUTH_TOKEN. If you run a custom AI gateway (proxying Claude through your own endpoint with ANTHROPIC_BASE_URL set to your gateway URL and authenticating via API key or a helper), and you had this env var set, 2.1.265 broke every session.

What 2.1.266 fixes

The evaluation logic returns to the pre-2.1.265 behavior: CLAUDE_CODE_USE_GATEWAY is ignored unless both ANTHROPIC_BASE_URL and ANTHROPIC_AUTH_TOKEN are simultaneously present. If your gateway setup uses an API key as the primary credential — which is the common pattern for operators routing through a third-party AI gateway or their own proxy — the variable is now inert again.

No config change is needed. Updating to 2.1.266 (or later) is the complete fix.

What 2.1.265 adds for gateway operators

The regression overshadows a genuinely useful release for gateway operators. Two changes in 2.1.265 are worth configuring after you update:

User identity in gateway telemetry. Claude Desktop and Cowork sessions now include user.email and user.groups in the telemetry they send through a Claude apps gateway. Terminal sessions already sent this. Operators running a gateway for cost attribution, per-team quota enforcement, or audit logging now get the same identity fields from all session types. If your gateway's telemetry processor filters by session origin, update those filters before upgrading to 2.1.265 or you'll miss the new fields.

Plugin-dir folder loading. The --plugin-dir flag now accepts a directory containing multiple plugin folders instead of a single plugin path. Each child folder with a valid manifest loads at startup, and plugins added or removed while Claude Code is running are picked up without a restart. For operators maintaining a shared plugin repository across teams, this eliminates the per-user installation step.

1 GB disk cap on tool results. Tool results saved to disk are now capped at 1 GB. The in-conversation preview indicates when a file was truncated. This is relevant for gateway operators running agents over large repositories or file systems — runaway tool results that previously filled disk silently are now bounded.

Prompt-cache reuse fixes for subagent pipelines

Several fixes in 2.1.265 close prompt-cache reuse gaps that would have appeared in gateway cost data as unexpectedly high input token counts on multi-agent runs:

  • Resuming a foreground-spawned subagent no longer changes its tool list and system prompt prefix, which previously invalidated the prompt cache for that agent every time.
  • Agent teammates and resumed subagents no longer move SubagentStart hook context and preloaded skills out of the prompt prefix on later turns — another cache-busting pattern.
  • Resuming after the previous process died mid-tool-run no longer rewrites the last prompt, keeping the cache prefix intact.

Operators routing multi-agent Claude Code workloads through a gateway and monitoring cache ratios per session should expect measurably better cache hit rates after upgrading.

What TheRouter users should watch

If you're routing Claude Code sessions through a custom AI gateway and have CLAUDE_CODE_USE_GATEWAY in your environment, the 2.1.265→2.1.266 upgrade path is straightforward: update, no config edits. The user identity fields added in 2.1.265 align directly with per-team cost attribution at the gateway level — check whether your gateway's telemetry schema accepts user.email and user.groups from all session types and adjust if not.

Version audit checklist:

  • Check claude --version across all deployment environments.
  • If any are on 2.1.265, update to 2.1.266 immediately.
  • Verify CLAUDE_CODE_USE_GATEWAY is or isn't set in your deployment environment; if it's set without ANTHROPIC_AUTH_TOKEN, it was always a no-op before 2.1.265 and is again now.
  • After upgrade, monitor cache hit ratios in gateway logs — the subagent cache fixes in 2.1.265 should improve them.
Help & contact