Skip to content

fix(anthropic): avoid stale client version rejections on OAuth - #154098

Merged
steipete merged 2 commits into
mainfrom
upd/anthropic-client-version
Sep 21, 2026
Merged

steipete merged 2 commits into
mainfrom
upd/anthropic-client-version

Conversation

@steipete

@steipete steipete commented Sep 20, 2026 •

Copy link
Copy Markdown
Contributor

Closes #94716. Related: #154016. Supersedes #150790 with credit to @KrasimirKralev; that PR remains open for maintainer follow-up.

What Problem This Solves

Direct Anthropic subscription/OAuth requests advertise Claude Code 2.1.75, which Anthropic rejects for newer models with HTTP 400 claude_code_version_too_old. The reporters' controlled comparison requires at least 2.1.251.

User Impact

OAuth requests use a maintained client-version floor of 2.1.278 (the published @anthropic-ai/claude-code version checked on 2026-09-20), or a newer installed stable Claude CLI version. Missing, older, malformed, failed, over-output, or slow probes fall back to the floor. Requests wait at most 1.5 seconds for the shared probe; a late result cannot change the cached identity. No configuration, credential, dependency, or state migration is required.

API-key, Copilot, Foundry, and Cloudflare routes retain their existing behavior. This changes the direct Messages API client identity, not Claude CLI billing or model entitlement.

Why This Change Was Made

The Anthropic plugin reuses its existing lazy CLI capability probe and executable discovery, using direct PATH lookup to avoid a synchronous login-shell probe. Normal and simple-completion provider hooks pass installed-version evidence through existing request headers. @openclaw/ai spawns nothing: one shared owner enforces the floor and gives both transports a single header/billing snapshot. The command runner retains bounded output and process cleanup; request waiting has its own deadline.

The single-snapshot and header/billing boundary-test approach builds on @KrasimirKralev's prior work. Thanks to @Cyb3rb1ade, @raghidtawil-lab, and @davidcittadini for the reports and controlled comparisons. #144903 is a distinct local model-allowlist rejection before provider I/O and is not repaired here.

Evidence

Injected-fetch boundary tests exercise both the SDK and native transport with claude-fable-5-1. Before the fix, the regression failed on the stale default and mismatched newer-header/old-billing identities. After:

missing/older CLI:
  user-agent: claude-cli/2.1.278
  x-anthropic-billing-header: cc_version=2.1.278; cc_entrypoint=sdk-cli;
newer synthetic CLI:
  user-agent: claude-cli/3.0.0
  x-anthropic-billing-header: cc_version=3.0.0; cc_entrypoint=sdk-cli;

Live OAuth acceptance is not verified: no subscription token was available, and no operator OpenClaw state was read. @Cyb3rb1ade and the canonical issue's reporters: please verify this branch build using your existing OAuth profile and the previously rejected model, and report the OpenClaw commit/version and whether claude_code_version_too_old disappears. Do not post tokens.

  • Focused provider, transport, CLI, catalog, and state-fixture tests pass: 507 distinct tests across 10 files, plus repeated regression/shard proof. The new identity parity file takes 3.02 s for its original eight cases; with the extra header-case regression plus cache parity, 53 tests take 7.80 s wall. The new probe file takes 31.20 s wall (25 tests; 92% transform time). Both use --maxWorkers=1 through the repository test runner.
  • node scripts/check-changed.mjs and its remaining planned commands were completed by continuation after fixing two type errors: the new table needed an explicit header-record type, and an existing state-migration fixture imported a serializer from its retired location (the identical fix independently landed on main in fix(ui): avoid repeated waits in the people picker #153988). Core/extension production and test typechecks, formatting, line caps, dead exports, import cycles, and all other selected guards pass.
  • The extension lint wrapper hits this nested checkout's ancestor-install boundary. The authorized direct command node_modules/.bin/oxlint --tsconfig test/tsconfig/tsconfig.extensions.test.json <changed extension files> passes. Canary output before reverting its temporary line: cli-version.ts:47:7: error eslint(no-unused-vars): Variable 'l1084UnusedCanary' is declared but never used. Real-file result afterward: exit 0, no diagnostics. CI's extension lint remains authoritative.
  • pnpm build passes on the final implementation (14m 21.7s); no INEFFECTIVE_DYNAMIC_IMPORT warning.
  • P1 autoreview: scoped-clean, no accepted/actionable P0 or P1 findings on the final implementation.

Bounded test repairs encountered during verification: the existing compaction-wrapper test cold-loaded plugin metadata and took 32,852 ms; the existing manifest-backed fixture reduced it to 5 ms without replacing endpoint classification. The catalog metadata-cache test depended on OS watch delivery inside real-time polling and failed after 2,923 ms; the existing event driver and direct reads preserve its assertions. Its final regression passes 20 executions (--repeats=19), reported at 209 ms, with 83.59 s total cold runner wall. The three-file catalog/stream/CLI shard passed three times (92.93 / 149.07 / 106.21 s wall; two runs retained the original file order). The initial worker-termination warning did not recur. One subsequent preparation attempt raced a build replacing generated plugin output and ran no tests; serializing the final test after the build resolved that known preparation failure. The identical state-fixture import correction is already on main and is omitted from this PR; it passes all nine tests (87.07 s wall, largely transform/setup).

Production: +195/−74 (net +121); tests: +343/−17 (net +326); docs: +8/−1 (net +7). No changelog edit: release-note context is recorded here. CI timings are pending at PR creation.

The branch was rebased onto the main-owned state-test repair after validation; all 19 Anthropic/doc file blobs remain identical to the reviewed and tested candidate.

Maintainer review disposition

The ClawSweeper review completed at 2026-09-21 00:32 UTC on 2312ae07d8452fede6df1272aa160e2516dbf36b reports no actionable code or security findings. Its single Rank-up move requests a redacted live OAuth completion trace from this candidate. Skipped for this landing: no subscription token is available to this lane, and operator state access is outside its authorized scope. Candidate live acceptance remains unverified; the recorded injected-fetch boundary proof and green exact-head CI are the available evidence. This disposition does not claim live provider acceptance.

Keep the OAuth Claude Code identity at the maintained 2.1.278 floor and
prefer a newer installed CLI through the Anthropic plugin's shared bounded
version probe. Use one request snapshot for User-Agent and billing metadata
in both transports, preserving case-insensitive header replacement.

Cover the wire boundary and probe lifecycle, and repair the cold metadata
fixture and OS-watch race encountered in the provider tests.

Fixes #94716. Related: #154016. Supersedes the approach in #150790 with credit.

Co-authored-by: Krasimir Kralev <[email protected]>
@clawsweeper

clawsweeper Bot commented Sep 20, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation extensions: anthropic size: L maintainer Maintainer-authored PR labels Sep 20, 2026
@steipete
steipete marked this pull request as ready for review September 20, 2026 21:45
@clawsweeper clawsweeper Bot added P1 High-priority user-facing bug, regression, or broken workflow. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Sep 20, 2026
@clawsweeper

clawsweeper Bot commented Sep 20, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 20, 2026, 9:05 PM ET / September 21, 2026, 01:05 UTC (Revision 3).

ClawSweeper review

What this changes

Updates Anthropic OAuth client identification using a maintained version floor or newer installed Claude CLI, with matching request headers and billing metadata.

Merge readiness

✅ Ready for maintainer review

Still necessary: current main and the latest release retain the stale identity. No actionable correctness or security findings remain, and the maintainer explicitly disposed of the earlier live-proof request.

Priority: P1
Reviewed head: 2312ae07d8452fede6df1272aa160e2516dbf36b

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused, well-covered repair with no actionable findings and an explicitly acknowledged live-acceptance limitation.
Proof confidence 🌊 off-meta tidepool Not applicable: The maintainer-authored exemption applies, and the recorded disposition explicitly accepts proceeding without candidate live OAuth acceptance. Injected-fetch tests exercise both changed transports and plugin tests cover probe lifecycle; neither is presented as live provider proof.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The maintainer-authored exemption applies, and the recorded disposition explicitly accepts proceeding without candidate live OAuth acceptance. Injected-fetch tests exercise both changed transports and plugin tests cover probe lifecycle; neither is presented as live provider proof.
Evidence reviewed 9 items Pinned introduction reviewed: Reviewed the merge-base-to-head patch, keeping unrelated base-branch changes outside PR ownership. The supplied test merge is stale and was not used to infer removals.
Current main still needs the fix: The fetched main revision still sets the OAuth client version to 2.1.75 and derives the billing block from that constant.
Latest release remains affected: The same 2.1.75 identity is present in v2026.9.5; this change is not demonstrated as shipped.
Findings None None.
Security None None.

How this fits together

The Anthropic plugin prepares model requests and discovers local Claude CLI capabilities. The shared AI package converts those requests into SDK or native HTTP calls to Anthropic.

flowchart LR
  A[Model request and credentials] --> B{Anthropic OAuth?}
  B -->|Yes| C[Shared bounded CLI probe]
  C --> D[Version floor and identity snapshot]
  D --> E[SDK or native transport]
  B -->|No| E
  E --> F[Anthropic Messages API]
  F --> G[Completion or provider error]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +121, Tests +326, Docs +7. Total +454 across 19 files.

View PR surface stats
Area Files Added Removed Net
Source 9 195 74 +121
Tests 8 343 17 +326
Docs 2 8 1 +7
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 19 546 92 +454

Review metrics

Metric Value Why it matters
Discovery budget 1 shared probe; 1,500 ms asynchronous wait Concurrent OAuth and CLI requests share the result, including a cached fallback after timeout.
Production and test growth production net +121 lines; tests net +326 lines Growth has a stated purpose: bounded shared discovery and consistent transport identity, with registration and wire-boundary regressions.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #94716
Summary: This PR is a candidate repair for the canonical stale OAuth client-identity report; related model allowlist failures remain separate.

Members:

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

Technical review

Best possible solution:

Keep one transport-owned identity floor and plugin-owned discovery shared across request paths, preserving existing credentials and non-OAuth routing.

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

Yes at the source boundary: main and v2026.9.5 emit the stale identity identified by the reported controlled comparison. This review did not execute a live OAuth request.

Is this the best way to solve the issue?

Yes. Reusing plugin-owned discovery and one shared transport identity avoids a competing startup manager or configuration surface while keeping the fallback usable without an installed CLI.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 03b6338390f1.

Labels

Label justifications:

  • P1: Repairs reported rejection of existing Anthropic OAuth inference on current releases.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The maintainer-authored exemption applies, and the recorded disposition explicitly accepts proceeding without candidate live OAuth acceptance. Injected-fetch tests exercise both changed transports and plugin tests cover probe lifecycle; neither is presented as live provider proof.

Evidence

What I checked:

  • Pinned introduction reviewed: Reviewed the merge-base-to-head patch, keeping unrelated base-branch changes outside PR ownership. The supplied test merge is stale and was not used to infer removals. (2312ae07d845)
  • Current main still needs the fix: The fetched main revision still sets the OAuth client version to 2.1.75 and derives the billing block from that constant. (packages/ai/src/providers/anthropic-model-contract.ts:39, 03b6338390f1)
  • Latest release remains affected: The same 2.1.75 identity is present in v2026.9.5; this change is not demonstrated as shipped. (packages/ai/src/providers/anthropic-model-contract.ts:39, ec9c1a13db89)
  • Shared identity and bounded discovery: The plugin shares one lazy probe between CLI execution and both provider hooks. It uses direct executable discovery, bounded output, process cleanup, and a 1,500 ms request deadline. Both transports consume the same floor-bounded identity builder for headers and billing. (extensions/anthropic/cli-version.ts:8, 2312ae07d845)
  • Boundary coverage and proof limits: The new parity tests capture both production transports through injected fetch and check matching header/billing versions, case-insensitive headers, and unaffected non-OAuth routes. Plugin tests cover shared discovery, timeout fallback, and late-result stability. These are supplemental tests, not live Anthropic acceptance. Inspected downloaded images belong to unrelated people-picker proof. (packages/ai/src/anthropic-client-identity-parity.test.ts:7, 2312ae07d845)
  • Maintainer disposition of prior review: The captured body at sourceRevision c0be467677cba05892f8a63360d81fcbbf129fa040197376124195e977ce8fc3 explicitly skips the previous live OAuth rank-up for this landing while preserving the unverified-acceptance limitation. A live read retained that disposition and the same reviewed head. GitHub separately confirms steipete has repository admin access. This accepted limitation is not reopened as a blocker or represented as live proof. (2312ae07d845)

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
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.

Workflow

  • 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.

History

Review history (2 earlier review cycles)
  • reviewed 2026-09-20T21:53:33.165Z sha efa6f2b :: needs changes before merge. :: none
  • reviewed 2026-09-21T00:32:40.423Z sha 2312ae0 :: needs changes before merge. :: none

@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. labels Sep 21, 2026
@steipete
steipete merged commit b58603e into main Sep 21, 2026
177 checks passed
@steipete
steipete deleted the upd/anthropic-client-version branch September 21, 2026 01:24
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 21, 2026
…law#154098)

Direct Anthropic OAuth requests could fail with claude_code_version_too_old because they advertised Claude Code 2.1.75. Maintain a 2.1.278 client-version floor and prefer a newer installed stable CLI through the Anthropic plugin's shared, bounded probe. Both transports use one selected version for request headers and billing metadata; failed or slow probes fall back to the floor.

Preserve API-key and other provider routes without configuration, credential, dependency, or state migrations. Cover request identity and probe lifecycle, and repair the cold metadata fixture and OS-watch race encountered during validation. Focused tests and exact-head CI passed; candidate live OAuth acceptance remains unverified.

Thanks to @Cyb3rb1ade, @raghidtawil-lab, and @davidcittadini for the reports and controlled comparisons. The single-snapshot and header/billing boundary-test approach builds on @KrasimirKralev's prior work.

Fixes openclaw#94716. Related: openclaw#154016. Supersedes the approach in openclaw#150790 with credit; that PR remains open for maintainer follow-up. The separate model-allowlist issue openclaw#144903 is outside this repair.

Co-authored-by: Krasimir Kralev <[email protected]>
@Newbie012 Newbie012 mentioned this pull request Sep 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Improvements or additions to documentation extensions: anthropic maintainer Maintainer-authored PR P1 High-priority user-facing bug, regression, or broken workflow. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: L status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

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