Skip to content

fix(anthropic): use claude-code/ UA prefix for OAuth to avoid 404 (#48534)#48580

Open
liuhao1024 wants to merge 1 commit into
NousResearch:mainfrom
liuhao1024:fix/anthropic-oauth-ua-prefix
Open

fix(anthropic): use claude-code/ UA prefix for OAuth to avoid 404 (#48534)#48580
liuhao1024 wants to merge 1 commit into
NousResearch:mainfrom
liuhao1024:fix/anthropic-oauth-ua-prefix

Conversation

@liuhao1024

Copy link
Copy Markdown
Contributor

What does this PR do?

Changes the User-Agent prefix in all OAuth HTTP requests from claude-cli/ to claude-code/. Anthropic now blocks the claude-cli/ prefix on the OAuth token endpoint, returning 404 for all versions.

Related Issue

Fixes #48534

Type of Change

  • 🐛 Bug fix (non-breaking change that fixes an issue)

Changes Made

  • agent/anthropic_adapter.py: Changed claude-cli/ to claude-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 verifying claude-cli/ is not used in OAuth headers

How to Test

  1. Run pytest tests/agent/test_anthropic_oauth_ua_prefix.py -v — all 4 tests should pass
  2. Verify no claude-cli/ remains in OAuth headers: grep "claude-cli/" agent/anthropic_adapter.py should return nothing
  3. Test OAuth flow: hermes auth add anthropic --type oauth — token exchange should succeed (no 404)

Checklist

Code

  • I've read the Contributing Guide
  • My commit messages follow Conventional Commits (fix(scope):, feat(scope):, etc.)
  • I searched for existing PRs to make sure this isn't a duplicate
  • My PR contains only changes related to this fix/feature (no unrelated commits)
  • I've run pytest tests/ -q and all tests pass
  • I've added tests for my changes (required for bug fixes, strongly encouraged for features)
  • I've tested on my platform: macOS

Documentation & Housekeeping

  • I've updated relevant documentation (README, docs/, docstrings) — or N/A
  • I've updated cli-config.yaml.example if I added/changed config keys — or N/A
  • I've updated CONTRIBUTING.md or AGENTS.md if I changed architecture or workflows — or N/A
  • I've considered cross-platform impact (Windows, macOS) per the compatibility guide — or N/A
  • I've updated tool descriptions/schemas if I changed tool behavior — or N/A

Code Intelligence

  • Analyzed: agent/anthropic_adapter.py (3 call sites: lines 811, 1008, 1357)
  • Blast radius: LOW — only affects OAuth User-Agent header, no control flow changes
  • Related patterns: claude-code/ UA already used at line 782 for Kimi's /coding endpoint

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
@alt-glitch alt-glitch added type/bug Something isn't working P1 High — major feature broken, no workaround comp/agent Core agent loop, run_agent.py, prompt builder provider/anthropic Anthropic native Messages API area/auth Authentication, OAuth, credential pools labels Jun 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/auth Authentication, OAuth, credential pools comp/agent Core agent loop, run_agent.py, prompt builder P1 High — major feature broken, no workaround provider/anthropic Anthropic native Messages API type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Anthropic Max OAuth fails: token exchange 404s because Anthropic now blocks the claude-cli/ User-Agent

2 participants