fix: prevent 401s when claude-code drops oauth-2025-04-20 from anthropic-beta#3
Open
daniel-rudaev wants to merge 1 commit intoKarpelesLab:masterfrom
Open
fix: prevent 401s when claude-code drops oauth-2025-04-20 from anthropic-beta#3daniel-rudaev wants to merge 1 commit intoKarpelesLab:masterfrom
daniel-rudaev wants to merge 1 commit intoKarpelesLab:masterfrom
Conversation
…pic-beta Claude Code 2.1.121+ has an upstream regression where its request-builder occasionally omits `oauth-2025-04-20` from the outgoing `anthropic-beta` header — most reliably on large requests (~280 KB body) with full tool loadout in interactive sessions. When this happens, the Anthropic API responds 401 with the misleading "OAuth authentication is currently not supported" message. teamclaude faithfully forwards what claude-code sent, so the failure surfaces here. Refs: anthropics/claude-code#54235, OpenClaw #41444 (Object.assign source- order merge clobbers the OAuth gate). Anthropic shipped a partial fix in 2.1.123 and refactored the beta system in 2.1.126, but real-world load still reproduces the 401. This patch defends teamclaude users from the upstream bug: on OAuth-account requests, ensure `oauth-2025-04-20` is present in `anthropic-beta` before forwarding. Idempotent (no-op when claude-code includes it correctly). Gated on `isOAuth=true` so x-api-key flows are untouched. 14 LOC including an 8-line comment block. Validation in production: - Pre-patch: first VS Code session request reproduced the 401. - Post-patch: 4/5 consecutive responses 200 (the 5th was a 429 rate-limit, unrelated). Outbound `anthropic-beta` now consistently shows `oauth-2025-04-20,claude-code-20250219,context-1m-2025-08-07,...`.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Claude Code 2.1.121+ has an upstream regression where its request-builder occasionally omits
oauth-2025-04-20from the outgoinganthropic-betaheader — most reliably on large requests (~280 KB body) with full tool loadout in interactive sessions. When this happens, the Anthropic API responds 401 with the misleading"OAuth authentication is currently not supported"body. teamclaude faithfully forwards what claude-code sent, so the failure surfaces here.References:
Object.assignsource-order merge clobbers the OAuth gate)Anthropic shipped a partial fix in 2.1.123 and refactored the beta system in 2.1.126, but real-world load still reproduces the 401.
Fix
On OAuth-account requests, ensure
oauth-2025-04-20is present inanthropic-betabefore forwarding upstream. Idempotent — no-op when claude-code includes it correctly. Gated onisOAuth === truesox-api-keyflows are untouched. 14 lines (including an 8-line comment block).Validation
Reproduced + fix verified in production (D1DX):
anthropic-betawas missingoauth-2025-04-20:Synthetic-load tests (
claude -p "..."with small bodies) did not reliably trigger the bug — only real interactive workloads with large bodies + full tool loadout did. Reproduce with a non-trivial VS Code session if you'd like to verify locally.Notes
D1DX:mastersince our git-managed workflow is single-branch. Happy to rebase to a feature branch if preferred.