Skip to content

improve(anthropic): log Claude Code version probe failures - #157697

Merged
altaywtf merged 2 commits into
openclaw:mainfrom
Bruce-Yii:fix/157541-claude-version-probe
Oct 6, 2026
Merged

altaywtf merged 2 commits into
openclaw:mainfrom
Bruce-Yii:fix/157541-claude-version-probe

Conversation

@Bruce-Yii

@Bruce-Yii Bruce-Yii commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Related: #157541.

The Anthropic plugin's Claude Code version probe can fail without any visible diagnostic. Missing executables, non-zero or unusable command results, unparseable output, and thrown probe errors all previously collapsed to undefined, leaving operators with an OAuth claude_code_version_too_old response and no indication of which probe step failed.

This is a diagnostic-only improvement. It does not claim to fix the OAuth rejection or change the request's version fallback.

Why This Change Was Made

Emit fixed warning categories for probe failures so an operator can distinguish a missing CLI, command failure, unparseable output, or thrown/timeout-style failure without exposing subprocess stdout, stderr, executable paths, or raw error text.

The existing transport contract remains unchanged: a successful probe may supply the installed version; a failed probe still uses the maintained version floor, and the lazy discovery cache is unchanged.

User Impact

Evidence

  • Regression coverage in extensions/anthropic/cli-version.test.ts exercises missing-executable, command-failure, and unparseable-output warnings and verifies the request remains on the transport floor.
  • The exact head has green required CI: 47 successful checks and 51 skipped checks at takeover time.
  • Prior local checks recorded on this head: oxlint, oxfmt, and git diff --check clean.
  • A secretless GitHub-hosted real-Gateway proof based on this exact head passed. It used a disposable Gateway, a loopback Anthropic Messages stub, a synthetic OAuth-shaped token, and a synthetic claude --version exit failure.

Redacted observed proof from that run:

warning=Claude Code version probe: command-failed; OAuth requests keep the built-in version floor
warningCount=1 requestCount=1
request=POST /v1/messages authorization=true x-api-key=false
fakeProbeInvoked=true stdoutSentinelInLogs=false stderrSentinelInLogs=false

The proof test read the redacted Gateway log, confirmed the warning category, confirmed the single loopback request and OAuth-shaped auth path, and confirmed that synthetic subprocess stdout/stderr did not enter the captured logs. It is diagnostic evidence for the warning path; it is not a root-cause repair for #157541.

Measured cost for the changed test file: an isolated one-worker run of extensions/anthropic/cli-version.test.ts on the exact PR head completed in 46s wall time (41.67s Vitest duration, 1 file / 28 tests). The repository check-test-types job completed in 7m18s.

Non-goals / follow-ups

@clawsweeper

clawsweeper Bot commented Sep 24, 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.

@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Sep 24, 2026
@clawsweeper

clawsweeper Bot commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed October 6, 2026, 12:48 PM ET / 16:48 UTC (Revision 8).

ClawSweeper review

What this changes

The Anthropic plugin logs fixed categories when Claude Code version discovery fails and adds regression coverage while preserving request fallback behavior.

Merge readiness

✅ Ready for maintainer review

Keep open: the diagnostic gap remains on current main, the patch has no blocking correctness findings, and the recorded Gateway proof exercises the changed warning path.

Priority: P2
Reviewed head: ef721660000db75a7a45de1be685183b80b21691

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused diagnostic patch with relevant real Gateway proof and no blocking findings.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (logs): The captured after-fix real Gateway trace exercises the Anthropic probe through a failing Claude executable and a loopback Messages request, showing one categorized warning and no subprocess-output leakage. Unit regressions supplement that proof; no stored-data contract changes.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (logs): The captured after-fix real Gateway trace exercises the Anthropic probe through a failing Claude executable and a loopback Messages request, showing one categorized warning and no subprocess-output leakage. Unit regressions supplement that proof; no stored-data contract changes.
Evidence reviewed 10 items Verified introduced change: The pinned merge-base-to-head diff adds bounded warning categories and diagnostic regression cases. The command budget, executable resolution, lazy cache, and successful version parsing remain unchanged.
Still necessary on current main: Current main still returns undefined silently for missing executables, unsuccessful command results, and exceptions; it does not contain these failure warnings.
Latest release comparison: The v2026.9.8 version probe also lacks these diagnostics, so the requested warning behavior is not already present in the supplied latest release.
Findings None None.
Security None None.

How this fits together

The Anthropic plugin probes the installed Claude Code version for subscription requests and native CLI capabilities. Failed discovery leaves the transport's maintained version floor in place; this change makes that failure visible in Gateway logs.

flowchart TD
  A[Subscription request or CLI preparation] --> B[Shared lazy version probe]
  C[Installed Claude Code executable] --> B
  B --> D{Discovery succeeds}
  D -->|Yes| E[Installed version evidence]
  D -->|No| F[Categorized Gateway warning]
  F --> G[Existing version floor]
  E --> H[Provider request identity]
  G --> H
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +21, Tests +47. Total +68 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 1 25 4 +21
Tests 1 47 0 +47
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 72 4 +68

Review metrics

None.

Technical review

Best possible solution:

Keep failure diagnostics in the existing Anthropic probe, with bounded categories and unchanged fallback, and handle refresh policy separately.

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

Yes: current-main source clearly returns silently on failed discovery, and the recorded real Gateway run exercises the introduced command-failure diagnostic. No local runtime reproduction was executed during this read-only review.

Is this the best way to solve the issue?

Yes: fixed categories in the existing probe are a narrow solution that preserves the documented fallback and avoids logging private subprocess content.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

No label changes.

Label justifications:

  • P2: This is a bounded operator-diagnostic improvement for provider version discovery without changing request behavior.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (logs): The captured after-fix real Gateway trace exercises the Anthropic probe through a failing Claude executable and a loopback Messages request, showing one categorized warning and no subprocess-output leakage. Unit regressions supplement that proof; no stored-data contract changes.
  • proof: sufficient: Contributor real behavior proof is sufficient. The captured after-fix real Gateway trace exercises the Anthropic probe through a failing Claude executable and a loopback Messages request, showing one categorized warning and no subprocess-output leakage. Unit regressions supplement that proof; no stored-data contract changes.

Evidence

What I checked:

  • Verified introduced change: The pinned merge-base-to-head diff adds bounded warning categories and diagnostic regression cases. The command budget, executable resolution, lazy cache, and successful version parsing remain unchanged. (extensions/anthropic/cli-version.ts:38, ef721660000d)
  • Still necessary on current main: Current main still returns undefined silently for missing executables, unsuccessful command results, and exceptions; it does not contain these failure warnings. (extensions/anthropic/cli-version.ts:14, e0ec9b048f0c)
  • Latest release comparison: The v2026.9.8 version probe also lacks these diagnostics, so the requested warning behavior is not already present in the supplied latest release. (extensions/anthropic/cli-version.ts:14, fc23bc864e45)
  • Existing lifecycle contract: Documentation explicitly defines shared discovery cached until process restart and the maintained floor on failed checks. Registration shares one probe across both OAuth wrappers and the CLI backend; the patch preserves this contract. Public docs: docs/providers/anthropic.md. (docs/providers/anthropic.md:199, ef721660000d)
  • Real Gateway diagnostic proof: The captured PR body, sourceRevision 5aa2e8a0d558b877e468aac3c8c5c58d7feb381ebfafae825427b334733db79d, records a secretless real Gateway with a loopback Messages server and failing synthetic Claude executable. Observations show one command-failed warning, one OAuth-shaped POST, executable invocation, and no stdout/stderr sentinels in logs. This directly exercises the changed probe and logging path without claiming to repair provider rejection. (ef721660000d)
  • Earlier review concerns addressed: Warnings contain only fixed literals, addressing the earlier raw-output concern. The captured body records 46 seconds one-worker wall time and 41.67 seconds Vitest duration, addressing the prior missing-cost findings. The completed previous review reports no remaining findings or published rank-up moves. (extensions/anthropic/cli-version.test.ts:141, ef721660000d)

Likely related people:

  • unknown: The claimed source-line change could not be verified from bounded local history. (role: source history unknown; 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 (7 earlier review cycles)
  • reviewed September 24, 2026, 7:51 PM ET / 23:51 UTC sha unknown :: needs real behavior proof before merge. :: [P2] Keep unparsed probe text out of Gateway warnings
  • reviewed 2026-09-25T00:40:18.030Z sha e87b8d0 :: needs real behavior proof before merge. :: none
  • reviewed 2026-09-25T02:42:19.769Z sha e87b8d0 :: needs real behavior proof before merge. :: none
  • reviewed 2026-09-25T04:58:44.583Z sha e87b8d0 :: needs real behavior proof before merge. :: [P3] [P3] Record the added test file's measured cost
  • reviewed 2026-09-25T05:08:32.811Z sha e87b8d0 :: needs changes before merge. :: [P3] Record the changed test file's one-worker wall time
  • reviewed 2026-09-25T05:22:36.063Z sha e87b8d0 :: needs maintainer review before merge. :: none
  • reviewed September 26, 2026, 2:30 PM ET / 18:30 UTC (Revision 7) sha unknown :: needs maintainer review before merge. :: none

@clawsweeper clawsweeper Bot removed the merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. label Sep 25, 2026
@Bruce-Yii Bruce-Yii changed the title fix(anthropic): log Claude Code version probe failures instead of swallowing them improve(anthropic): log Claude Code version probe failures Sep 25, 2026
@Bruce-Yii

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Sep 25, 2026
@Bruce-Yii

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

…llowing them (openclaw#157541)

The OAuth identity wrapper sends `user-agent: claude-cli/<version>`
only when the version probe succeeds. Every failure mode — missing
executable, command failure, unparseable output, thrown errors —
returned undefined silently, so users hit HTTP 400
`claude_code_version_too_old` with no evidence that their installed
CLI was never detected, and "update Claude Code" could not help.

Each failure mode now logs a warning naming its cause, so the gateway
log shows which step failed instead of nothing. Transport behavior is
unchanged: the built-in version floor still applies on failure.

Adds regression coverage asserting a warning is emitted for each
failure mode while the request still goes through without identity.
@altaywtf
altaywtf force-pushed the fix/157541-claude-version-probe branch from e87b8d0 to ef72166 Compare October 6, 2026 16:29
@altaywtf

altaywtf commented Oct 6, 2026

Copy link
Copy Markdown
Member

@clawsweeper re-review

Rebased onto current main. Independent P0–P2 review is clean; fresh Linux regression tests, formatting, and lint pass. Please review the updated head.

@clawsweeper

clawsweeper Bot commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@altaywtf
altaywtf merged commit 9f9d888 into openclaw:main Oct 6, 2026
93 checks passed
@altaywtf

altaywtf commented Oct 6, 2026

Copy link
Copy Markdown
Member

Merged via squash.

vincentkoc added a commit that referenced this pull request Oct 6, 2026
* commit 'c39d9b0692dbaafa5b1bfe02514c9f6411ab5546': (30 commits)
  fix(ci): clear MCP audit and service-worker test blockers (#166217)
  test(gateway): wait for steering admission in FIFO fixtures
  fix(llama-cpp): managed setup crashes and loops on macOS below 13.3 (#163358)
  perf(worktrees): avoid full session parsing during GC (#166072)
  fix(update): recover stopped legacy managed services (#166232)
  perf(gateway): stream bounded link preview metadata (#166195)
  perf(diagnostics): release completed Git operation state (#166214)
  chore(deps): update fs-safe to 0.24.1 and clone plugin source captures (#166189)
  feat(clients): adopt worker-local inference placement (#163647)
  test: serialize PowerShell completion process suites (#166229)
  test: stabilize release timing boundaries (#166218)
  refactor(sessions): persist run outcomes only; liveness comes from the run registry (#165733)
  test(gateway): prove mention refresh after config retargeting
  fix(team-reports): keep the missed closed day when catch-up runs after midnight (#165780)
  test(gateway): join WebChat queue admission and drain completion
  fix(logging): reject blank diagnostic stability query fields (#145532)
  fix(agents): report unparseable serialized edit arguments (#163577)
  improve(anthropic): log Claude Code version probe failures (#157697)
  fix(agents): clarify prompt-size provider failures (#159712)
  fix(memory): re-throw non-ENOENT/ENOTDIR errors in root memory file lookup (#107921)
  ...
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 7, 2026
…157697)

* fix(anthropic): log Claude Code version probe failures instead of swallowing them (openclaw#157541)

The OAuth identity wrapper sends `user-agent: claude-cli/<version>`
only when the version probe succeeds. Every failure mode — missing
executable, command failure, unparseable output, thrown errors —
returned undefined silently, so users hit HTTP 400
`claude_code_version_too_old` with no evidence that their installed
CLI was never detected, and "update Claude Code" could not help.

Each failure mode now logs a warning naming its cause, so the gateway
log shows which step failed instead of nothing. Transport behavior is
unchanged: the built-in version floor still applies on failure.

Adds regression coverage asserting a warning is emitted for each
failure mode while the request still goes through without identity.

* fix(anthropic): log only failure categories from version probe

---------

Co-authored-by: Bruce-Yii <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

extensions: anthropic P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: S 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.

2 participants