Repository navigation
fix(anthropic): resolve claude-code version at runtime for OAuth user-agent (fixes #94716) - #95205
Darren2030 wants to merge 3 commits into
Conversation
|
Codex review: needs changes before merge. Reviewed July 3, 2026, 10:52 AM ET / 14:52 UTC. Summary PR surface: Source +98, Tests +76, Other +73. Total +247 across 6 files. Reproducibility: yes. from source: current main and v2026.6.11 still send Review metrics: 3 noteworthy metrics.
Stored data model Root-cause cluster Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Rank-up moves:
Risk before merge
Maintainer options:
Copy recommended automerge instructionNext step before merge
Security Review findings
Review detailsBest possible solution: Keep the two-call-site stale-header fix, but prepare and cache a cross-platform Claude Code version at an owned setup or provider boundary before OAuth request construction. Do we have a high-confidence way to reproduce the issue? Yes from source: current main and v2026.6.11 still send Is this the best way to solve the issue? No: fixing both OAuth builders is the right scope, but synchronous first-on-PATH CLI discovery during header construction is not the safest owner boundary. A prepared and cached cross-platform version source before request construction is the better fix. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against e272da5c5579. Label changesLabel justifications:
Evidence reviewedPR surface: Source +98, Tests +76, Other +73. Total +247 across 6 files. View PR surface stats
Security concerns:
Acceptance criteria:
What I checked:
Likely related people:
What the crustacean ranks mean
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics. How this review workflow works
|
|
@clawsweeper re-review Updated real behavior proof from a fresh run on this branch: Environment: Linux x64, Node.js v22.x, openclaw/openclaw@main + this PR Reproduction script ( Unit / integration tests: Lint / format / build: The reproduction uses a real temporary |
|
🦞🧹 I asked ClawSweeper to review this item again. |
|
Updated the implementation and proof for #94716. Key change since the last review: the resolver now prefers The resolver still never silently falls back to the stale hardcoded Fresh verification:
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. |
|
@clawsweeper re-review Addressed the P1 finding about resolver ownership:
Updated real behavior proof:
Also added unit coverage for the CLI output parser and the non-digit-leading string validation. |
Summary
Fixes #94716. The Anthropic OAuth bearer path in both the legacy SDK provider and the native messages transport hardcoded the Claude Code user-agent version to
2.1.75. Anthropic now rejects that stale version, causingauthentication_error: Invalid bearer tokenfor users on newer Claude Code CLI installs.This change reads the installed
@anthropic-ai/claude-codepackage version at runtime and uses it in theuser-agent: claude-cli/<version>header. If the package cannot be resolved or its version is invalid, the helper throws a clear configuration error instead of silently sending a stale fallback.Changes
src/llm/utils/claude-code-version.ts: new helper that resolves the installed Claude Code version and builds the OAuth user-agent header.src/llm/providers/anthropic.ts: replace hardcodedclaudeCodeVersion = "2.1.75"with the runtime helper.src/agents/anthropic-transport-stream.ts: replace hardcodedCLAUDE_CODE_VERSIONconstant with the runtime helper.src/llm/utils/claude-code-version.test.ts: unit tests for version resolution, user-agent formatting, and invalid-value handling.src/agents/anthropic-transport-stream.test.ts: set a test resolver and assert the exact OAuth user-agent value.scripts/repro/issue-94716-claude-code-user-agent.mts: standalone reproduction script that simulates an installed Claude Code version and verifies the resolved user-agent.Real behavior proof
node --import tsx scripts/repro/issue-94716-claude-code-user-agent.mtspnpm test src/llm/utils/claude-code-version.test.ts --runpnpm test src/agents/anthropic-transport-stream.test.ts --runpnpm test src/llm/providers/anthropic.test.ts --runpnpm buildUnit tests:
claude-cli/2.1.177from a simulated installed package, confirming the header follows the installed CLI version. Existing Anthropic transport tests pass with the new runtime resolver.Verification
node --import tsx scripts/repro/issue-94716-claude-code-user-agent.mts→ PASSpnpm test src/llm/utils/claude-code-version.test.ts --run→ 5 passedpnpm test src/agents/anthropic-transport-stream.test.ts --run→ 76 passedpnpm test src/llm/providers/anthropic.test.ts --run→ 35 passednpx oxlint --import-plugin --config .oxlintrc.json <changed files>→ cleanpnpm format:check <changed files>→ cleanpnpm build→ success