Skip to content

Keep relayed launch out of Claude Code gateway login mode - #535

Closed
masonc08 wants to merge 1 commit into
mainfrom
masonc08/relayed-fix-gateway-login
Closed

Keep relayed launch out of Claude Code gateway login mode#535
masonc08 wants to merge 1 commit into
mainfrom
masonc08/relayed-fix-gateway-login

Conversation

@masonc08

@masonc08 masonc08 commented Sep 9, 2026

Copy link
Copy Markdown
Collaborator

Problem

Users on Claude Max/Enterprise using ucode relayed MPS report that after Claude Code auto-updated to 2.1.265, the session loops on /login: OAuth completes on Anthropic's side but the session still insists it needs to log in. A session on the previous version keeps working. (Reported in the AIGW coding-agents thread.)

Root cause

Claude Code 2.1.261+ changed gateway login mode to ignore a claude.ai subscription login and demand a gateway /login. ucode's relayed launch is the only config that mixes:

  • gateway mode (CLAUDE_CODE_USE_GATEWAY=1, set unconditionally in render_overlay), and
  • no gateway credential — relayed deliberately writes no apiKeyHelper/API key and relies on Claude Code's own subscription OAuth as the Authorization, while the loopback proxy swaps the Databricks token in by header.

So gateway login mode now rejects the very credential relayed depends on → the loop. The api-key MPS and normal gateway paths are unaffected because they carry an apiKeyHelper, which matches "only Enterprise/relayed broke."

Fix

Set CLAUDE_CODE_USE_GATEWAY only for credentialed (non-relayed) launches, and add it to CLAUDE_CONDITIONAL_ENV_KEYS so a value a prior non-relayed launch wrote is pruned when a relayed launch omits it. Requests still route through the gateway via ANTHROPIC_BASE_URL without the flag — per Claude Code's LLM-gateway docs, a custom base URL alone (no gateway credential) keeps the subscription login active.

Testing

  • test_relayed_omits_use_gateway (overlay omits the flag + it's not in the managed keys), test_relayed_prunes_stale_use_gateway (a relayed write drops a stale value). Existing non-relayed assertions unchanged. Full test_agent_claude.py 133/133; ruff clean.
  • Not yet validated against a live relayed session on 2.1.265 — needs a subscription box, and CLAUDE_CODE_USE_GATEWAY is undocumented so the exact lever is inferred from the changelog + behavior. Validate before rollout.

This pull request and its description were written by Isaac.

Claude Code 2.1.261+ changed gateway login mode to ignore a claude.ai subscription
login and demand a gateway `/login`. ucode's relayed (Claude Max/Enterprise
subscription-relay) launch is the only path with no gateway credential -- it relies
on Claude Code's own subscription OAuth as the Authorization credential while the
loopback proxy swaps in the Databricks token by header. So after the client
auto-updated to 2.1.265, relayed sessions loop on `/login`: the OAuth completes on
Anthropic's side but gateway login mode never accepts it. The api-key MPS and normal
gateway paths are unaffected because they carry an apiKeyHelper.

Set CLAUDE_CODE_USE_GATEWAY only for credentialed (non-relayed) launches, and add it
to CLAUDE_CONDITIONAL_ENV_KEYS so a value a prior non-relayed launch wrote is pruned
when a relayed launch omits it. Requests still route through the gateway via
ANTHROPIC_BASE_URL without the flag (per Claude Code's LLM-gateway docs:
base-URL-alone keeps the subscription login active).

NOT yet validated against a live relayed session on 2.1.265 (needs a subscription
box; CLAUDE_CODE_USE_GATEWAY is undocumented, so the exact lever is inferred from the
changelog + behavior). Validate before rollout.

Co-authored-by: Isaac <no-reply@databricks.com>
@masonc08 masonc08 closed this Sep 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant