fix(anthropic): use claude-code/ UA prefix for OAuth to avoid 404 (#48534)#48580
Open
liuhao1024 wants to merge 1 commit into
Open
fix(anthropic): use claude-code/ UA prefix for OAuth to avoid 404 (#48534)#48580liuhao1024 wants to merge 1 commit into
liuhao1024 wants to merge 1 commit into
Conversation
Anthropic now blocks the `claude-cli/` User-Agent prefix on the OAuth token endpoint (returns 404 for all versions). Switch to `claude-code/` which is the upstream CLI's own prefix and is not blocked. Three call sites updated: - build_anthropic_client OAuth header - refresh_anthropic_oauth_pure token refresh - run_hermes_oauth_login_pure token exchange Fixes NousResearch#48534
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.
What does this PR do?
Changes the User-Agent prefix in all OAuth HTTP requests from
claude-cli/toclaude-code/. Anthropic now blocks theclaude-cli/prefix on the OAuth token endpoint, returning 404 for all versions.Related Issue
Fixes #48534
Type of Change
Changes Made
agent/anthropic_adapter.py: Changedclaude-cli/toclaude-code/in User-Agent headers at 3 OAuth call sites (build_anthropic_client, refresh_anthropic_oauth_pure, run_hermes_oauth_login_pure)tests/agent/test_anthropic_oauth_ua_prefix.py: 4 regression tests verifyingclaude-cli/is not used in OAuth headersHow to Test
pytest tests/agent/test_anthropic_oauth_ua_prefix.py -v— all 4 tests should passclaude-cli/remains in OAuth headers:grep "claude-cli/" agent/anthropic_adapter.pyshould return nothinghermes auth add anthropic --type oauth— token exchange should succeed (no 404)Checklist
Code
fix(scope):,feat(scope):, etc.)pytest tests/ -qand all tests passDocumentation & Housekeeping
docs/, docstrings) — or N/Acli-config.yaml.exampleif I added/changed config keys — or N/ACONTRIBUTING.mdorAGENTS.mdif I changed architecture or workflows — or N/ACode Intelligence
agent/anthropic_adapter.py(3 call sites: lines 811, 1008, 1357)claude-code/UA already used at line 782 for Kimi's /coding endpoint