Repository navigation
Conversation
|
Thanks for the contribution. This PR still needs the requested real-behavior proof, and the branch has been idle since that ask. Close as a stalled, unproven PR. The branch has been inactive since June 21, 2026, the July 10 proof request expired without evidence that patched OpenClaw emits the corrected OAuth header, and the unchanged patch still retains the stale fallback that can reproduce the reported failure. Root-cause cluster Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. So I’m closing this for now to keep the review queue honest. Please reopen or open a fresh PR with real-behavior proof (a live run, logs, or a reproducible validation transcript) and it will be reviewed again. Review detailsBest possible solution: Keep one current-main-aligned fix for the canonical incident: use a shared resolver that cannot silently send the rejected stale header, covers both OAuth builders, and includes a redacted after-fix request trace before merge. Do we have a high-confidence way to reproduce the issue? Yes, at source level: the canonical report traces an OAuth token through both header builders and identifies the stale Is this the best way to solve the issue? No. The branch duplicates resolver logic, calls CommonJS Security review: Security review cleared: The patch only reads a local package manifest for a request header and introduces no dependency, secret, workflow, permission, or code-download change. AGENTS.md: found and applied where relevant. What I checked:
Likely related people:
Codex review notes: model internal, reasoning high; reviewed against 62cbbcc80021. |
|
@clawsweeper re-review
|
|
🦞🧹 I asked ClawSweeper to review this item again. |
|
@clawsweeper re-review Addressed the review gap (0 exact user-agent assertions):
|
|
🦞🧹 I asked ClawSweeper to review this item again. |
d382a79 to
c43fa4f
Compare
…-agent Instead of hardcoding the claude-cli version string, resolve the installed @anthropic-ai/claude-code package version at runtime via createRequire. Falls back to the previous constant when the package is not resolvable (e.g. running from source). Fixes openclaw#94716
Apply the same runtime version resolution to the second OAuth header builder in anthropic-transport-stream.ts, which also had a hardcoded CLAUDE_CODE_VERSION constant. # Conflicts: # src/agents/anthropic-transport-stream.ts
Strengthen the transport-stream OAuth user-agent assertion to verify the header matches claude-cli/<semver> instead of only the prefix, so a regression to an empty or malformed version string is caught.
c43fa4f to
860df03
Compare
|
@ruomuxydt thanks for the PR. ClawSweeper is still waiting on real behavior proof before this can move forward. Useful proof can be a screenshot, short video, terminal output, copied live output, linked artifact, or redacted logs that show the changed behavior after the fix. Please redact private tokens, phone numbers, private endpoints, customer data, and anything else sensitive. Once proof is added to the PR body or a comment, ClawSweeper or a maintainer can re-check it. |
|
Thanks for tackling this — #94716 is a real, reproducible bug and worth fixing quickly. I opened #94719 for the same issue before seeing this PR; now that both are open, flagging the design difference so maintainers have full context rather than reviewing two parallel fixes for the same root cause. Where the two diverge:
The failure-behavior difference matters most for #94716 itself: the original bug is a stale hardcoded version silently going out over the wire. A resolver that falls back to that same stale constant on any resolution error reproduces the exact failure mode it's meant to fix — just with a smaller window (only triggers when resolution fails, instead of always). #94719 treats resolution failure as loud and blocking instead, which is a stronger guarantee against silent staleness recurring. Module-load-time caching also means a Not trying to step on this — happy to consolidate into whichever design maintainers prefer, or merge the two approaches (e.g. keep a cache as a legitimate perf optimization, but fail loud on resolution error instead of falling back to the stale constant). Mainly wanted to get the tradeoff in front of reviewers before both PRs get separate review cycles for the same bug. |
|
This pull request has been automatically marked as stale due to inactivity. |
|
ClawSweeper applied the proposed close for this PR.
|
Summary
The Anthropic provider hardcodes
claudeCodeVersion = "2.1.75"for theuser-agentheader sent with every Claude CLI OAuth request. When the installed@anthropic-ai/claude-codeCLI is updated (e.g. to 2.1.177), the stale user-agent string causes bearer auth to fail because the backend rejects the mismatched version.This fix resolves the installed CLI version at runtime via
createRequire, falling back to the previous hardcoded constant when the package is not resolvable. Both OAuth header builders are updated:src/llm/providers/anthropic.ts(legacy provider)src/agents/anthropic-transport-stream.ts(transport stream)Changes
src/llm/providers/anthropic.ts: Replace hardcodedclaudeCodeVersionwithresolveClaudeCodeVersion().src/agents/anthropic-transport-stream.ts: Replace hardcodedCLAUDE_CODE_VERSIONwithresolveClaudeCodeVersion().Real behavior proof
Behavior addressed: Anthropic provider now sends the correct installed CLI version in the user-agent header instead of a stale hardcoded constant, in both OAuth header builders.
Real environment tested: Windows 10 (10.0.17763), Node.js v22.19.2, source tree checkout at commit ff14d9af3a.
Exact steps or command run after this patch:
Evidence after fix:
@anthropic-ai/claude-codeis installed: outputsresolved version: 2.1.177(actual installed version)fallback needed: MODULE_NOT_FOUNDand gracefully falls back toFALLBACK_CLAUDE_CODE_VERSION = "2.1.75"without throwingObserved result after fix: The user-agent header now reflects the actual installed CLI version in both Anthropic OAuth header builders (
src/llm/providers/anthropic.tsandsrc/agents/anthropic-transport-stream.ts). The version is resolved once at module load time viacreateRequire(import.meta.url)and cached.What was not tested: End-to-end OAuth flow against Anthropic backend (requires live credentials). The fix only changes the user-agent string value; the OAuth token refresh logic is unchanged.
Verification
git diff --stat: 2 files changed, +44 -2 linesresolveClaudeCodeVersion()pattern@anthropic-ai/claude-codeis not installed (source-tree builds, Docker, etc.)Fixes #94716