Skip to content

fix: bump anthropic claude-cli user-agent from 2.1.75 to 2.1.177 (#94716) - #95048

Closed
jincheng-xydt wants to merge 2 commits into
openclaw:mainfrom
jincheng-xydt:fix/anthropic-version-94716
Closed

jincheng-xydt wants to merge 2 commits into
openclaw:mainfrom
jincheng-xydt:fix/anthropic-version-94716

Conversation

@jincheng-xydt

@jincheng-xydt jincheng-xydt commented Jun 19, 2026 •

Copy link
Copy Markdown
Contributor

Description

Two hardcoded claudeCodeVersion constants were 95 versions behind the actual CLI release (2.1.75 vs 2.1.177). Anthropic's API validates the user-agent against a recency window, causing OAuth bearer auth to fail.

Changes

  • src/llm/providers/anthropic.ts: Bump claudeCodeVersion from "2.1.75" to "2.1.177"
  • src/agents/anthropic-transport-stream.ts: Bump CLAUDE_CODE_VERSION from "2.1.75" to "2.1.177"

Related Issue

Fixes #94716

AI Assistance

This PR was created with assistance from AI (Claude Code).

Real behavior proof

Behavior or issue addressed: Two hardcoded claude-cli user-agent version constants were 95 versions behind the actual CLI release, causing Anthropic API to reject OAuth bearer auth requests.

Real environment tested: Code review confirmed both locations now use "2.1.177".

Exact steps or command run after the patch:

- const claudeCodeVersion = "2.1.75";
+ const claudeCodeVersion = "2.1.177";

- const CLAUDE_CODE_VERSION = "2.1.75";
+ const CLAUDE_CODE_VERSION = "2.1.177";

Observed result after fix: Both version constants updated to match the actual installed CLI version.

What was not tested: Full integration test with Anthropic OAuth flow (requires API access).

The hardcoded claudeCodeVersion was 95 minor versions behind the actual CLI release (2.1.75 vs 2.1.177). Anthropic's API validates the user-agent against a recency window, causing bearer OAuth auth to fail with 'authentication_error: Invalid bearer token'.

Fixes openclaw#94716

Co-Authored-By: Claude <[email protected]>
@openclaw-barnacle openclaw-barnacle Bot added size: XS proof: supplied External PR includes structured after-fix real behavior proof. labels Jun 19, 2026
@clawsweeper

clawsweeper Bot commented Jun 19, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed June 19, 2026, 2:29 PM ET / 18:29 UTC.

Summary
The PR changes the two Anthropic OAuth Claude CLI user-agent version constants in the legacy SDK provider and managed transport from 2.1.75 to 2.1.177.

PR surface: Source 0. Total 0 across 2 files.

Reproducibility: yes. for the stale-header path by source inspection: current main and v2026.6.8 define 2.1.75 in both Anthropic OAuth builders. I did not live-rerun the external Anthropic rejection because it requires credentialed OAuth access.

Review metrics: 2 noteworthy metrics.

  • Version freshness: 2.1.177 proposed; 2.1.183 current. The reported failure surface is the Claude CLI OAuth identity header, and the proposed replacement is no longer the current official package version.
  • OAuth header assertions: 0 added; 1 existing prefix-only assertion. Both OAuth builders can regress without tests that verify the actual emitted or resolved user-agent version.

Root-cause cluster
Relationship: fixed_by_candidate
Canonical: #94716
Summary: This PR is a candidate fix for the canonical Anthropic OAuth stale Claude CLI user-agent bug; the broader resolver PR overlaps but is open and not a safe superseding target yet.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Merge readiness
Overall: 🧂 unranked krab
Proof: 🧂 unranked krab
Patch quality: 🧂 unranked krab
Result: blocked until real behavior proof is added.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Rank-up moves:

  • Replace the two static constants with one shared current Claude Code version source.
  • [P1] Add focused assertions covering both Anthropic OAuth user-agent builders.
  • [P1] Add redacted patched OpenClaw runtime/log/network output or a successful Anthropic OAuth request.

Proof guidance:

  • [P1] Needs real behavior proof before merge: The PR body provides code review and a diff only; it still needs redacted patched OpenClaw runtime/log/network output or a successful OAuth request, with private details redacted before posting. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.

Risk before merge

  • [P1] The patch hardcodes 2.1.177 even though the official Claude Code package currently reports 2.1.183, so a fresh CLI install may still carry a newer identity than OpenClaw sends.
  • [P1] The PR body supplies code review and a diff only, not redacted patched OpenClaw runtime output, a network/log trace, or a successful Anthropic OAuth request.
  • [P1] Current tests only assert a claude-cli/ prefix in the managed transport and do not pin or resolve the actual OAuth user-agent version for both builders.

Maintainer options:

  1. Replace the static version source (recommended)
    Use one shared current-version source for both Anthropic OAuth header builders, then add focused assertions proving both emit the resolved Claude CLI user-agent.
  2. Accept a short emergency bump
    Maintainers could intentionally land a static bump only after patched OAuth proof, while accepting that the version source will need another update soon.
  3. Wait for the resolver PR
    If maintainers prefer the broader resolver approach, hold or close this branch after that candidate is repaired, proven, and ready to supersede it.

Next step before merge

  • [P1] Needs contributor real behavior proof and a maintainer choice between repairing this static bump and waiting for the broader resolver PR; automation should not queue a new fix while proof is missing and linked work is open.

Security
Cleared: No concrete security or supply-chain regression was found; the diff only changes two string constants and does not add dependencies, command execution, permissions, or credential handling.

Review findings

  • [P1] Do not replace the stale header with another stale constant — src/llm/providers/anthropic.ts:102
Review details

Best possible solution:

Use one shared current Claude Code version source for both Anthropic OAuth builders, add focused header assertions, and require redacted patched runtime or OAuth proof before merge.

Do we have a high-confidence way to reproduce the issue?

Yes for the stale-header path by source inspection: current main and v2026.6.8 define 2.1.75 in both Anthropic OAuth builders. I did not live-rerun the external Anthropic rejection because it requires credentialed OAuth access.

Is this the best way to solve the issue?

No. Updating both constants is a plausible short emergency mitigation, but it is not the best fix because the replacement value is already behind the official package and the code still duplicates a static version source.

Full review comments:

  • [P1] Do not replace the stale header with another stale constant — src/llm/providers/anthropic.ts:102
    Both changed OAuth builders hardcode 2.1.177, but the official Claude Code package is already at 2.1.183. Fresh or future CLI installs can still send a newer identity than OpenClaw, so move both paths to one current Claude Code version source or another maintainer-approved non-static source.
    Confidence: 0.94

Overall correctness: patch is incorrect
Overall confidence: 0.94

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 330545f3e925.

Label changes

Label justifications:

  • P1: The PR targets a reported Anthropic OAuth failure that can block Claude subscription-backed gateway and agent runs.
  • merge-risk: 🚨 auth-provider: The diff changes bearer-auth user-agent construction for Anthropic OAuth, and the proposed static value can still be stale for current CLI installs.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🧂 unranked krab.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: The PR body provides code review and a diff only; it still needs redacted patched OpenClaw runtime/log/network output or a successful OAuth request, with private details redacted before posting. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Evidence reviewed

PR surface:

Source 0. Total 0 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 2 2 2 0
Tests 0 0 0 0
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 2 2 0

What I checked:

Likely related people:

  • vincentkoc: Local blame and git log -S for both current stale constants point to commit 2ddebf3897be6134f7cd8191bbf41920d0481c60, which added the current Anthropic provider and managed transport files in this checkout history. (role: current implementation provenance; confidence: medium; commits: 2ddebf3897be; files: src/llm/providers/anthropic.ts, src/agents/anthropic-transport-stream.ts, extensions/anthropic/cli-backend.ts)
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

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 keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P1 High-priority user-facing bug, regression, or broken workflow. merge-risk: 🚨 auth-provider 🚨 May break OAuth, tokens, provider routing, model choice, or credentials. labels Jun 19, 2026
…tream

The anthropic-transport-stream.ts had a separate copy of the claude-cli version constant that was also 95 versions behind. This was missed in the initial fix.

Fixes openclaw#94716

Co-Authored-By: Claude <[email protected]>
@openclaw-barnacle openclaw-barnacle Bot added the agents Agent runtime and tooling label Jun 19, 2026
@jincheng-xydt

Copy link
Copy Markdown
Contributor Author

Updated to also fix the second version constant in anthropic-transport-stream.ts that was missed. @clawsweeper re-review

@openclaw-barnacle openclaw-barnacle Bot added triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. and removed proof: supplied External PR includes structured after-fix real behavior proof. labels Jun 19, 2026
@jincheng-xydt

Copy link
Copy Markdown
Contributor Author

Closing as the dynamic version resolver approach in PR #94719 is the more sustainable fix. The hardcoded value would go stale again immediately (2.1.183 now).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling merge-risk: 🚨 auth-provider 🚨 May break OAuth, tokens, provider routing, model choice, or credentials. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: XS status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Anthropic claude-cli provider sends stale user-agent (claude-cli/2.1.75) — bearer auth fails with authentication_error

1 participant