Repository navigation
fix(auth): reuse Claude CLI logins natively and stop forwarding expired OAuth tokens - #115134
Conversation
|
Codex review: needs maintainer review before merge. Reviewed July 28, 2026, 8:28 AM ET / 12:28 UTC. ClawSweeper reviewWhat this changesThis PR verifies that an imported Claude CLI login matches the selected account and lets Claude authenticate natively, while continuing to refresh, persist, and forward OpenClaw-managed Anthropic credentials without profile fallback. Merge readinessKeep this PR open for maintainer review. The branch directly addresses the reported beta regression with a bounded split between imported Claude CLI credentials and OpenClaw-managed credentials, but it intentionally changes the authentication/identity contract for existing selected Claude CLI profiles and the author is a repository MEMBER with a protected Priority: P1 Review scores
Verification
How this fits togetherAgent execution prepares an authentication profile before launching a CLI backend such as Claude. The prepared credential either becomes a short-lived subprocess descriptor for OpenClaw-managed credentials or leaves Claude CLI to use its own verified host login, affecting whether scheduled and interactive agent runs can authenticate. flowchart LR
A[Selected auth profile] --> B[CLI run preparation]
B --> C{Credential ownership}
C -->|Imported Claude CLI login| D[Verify host Claude identity]
D --> E[Native Claude authentication]
C -->|OpenClaw-managed Anthropic credential| F[Refresh and materialize exact profile]
F --> G[Forward valid descriptor]
E --> H[Claude agent run]
G --> H
Decision needed
Why: This is a deliberate identity and credential-ownership boundary affecting upgraded multi-account installations; source-level tests can verify either implementation, but cannot choose the intended long-term authentication contract. Before merge
Agent review detailsSecurityNone. PR surfaceSource +132, Tests +342, Docs +3. Total +477 across 8 files. View PR surface stats
Review metricsNone. Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Adopt one explicit credential-ownership contract: verified native passthrough for imported Claude CLI logins, exact-profile refresh and descriptor forwarding only for OpenClaw-managed credentials, with clear pre-spawn re-authentication guidance and focused coverage for fresh, expired, absent, and mismatched-account states. Do we have a high-confidence way to reproduce the issue? Yes in source, with medium confidence: the linked report identifies the selected Is this the best way to solve the issue? Unclear until the maintainer chooses the long-term credential-ownership contract. The proposed split is a narrow and maintainable solution to the stale forwarded-token regression, but its fail-before-spawn behavior for imported profiles is an intentional compatibility decision. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 981a3dfad302. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (5 earlier review cycles)
|
53948c4 to
7f01698
Compare
7f01698 to
1227cf2
Compare
e497d01 to
33a0b9c
Compare
33a0b9c to
60aa3a2
Compare
|
Maintainer verification on head Bug confirmed on Best-fix judgment: yes. The alternatives lose: OpenClaw cannot refresh Claude's single-use rotating refresh-token family without bricking the host login, and staging tokens into Claude's own store (the gemini pattern) would race the host's interactive use of the same account. Since the imported credential is the host login, identity-verified passthrough is the correct ownership boundary, and it preserves #112458's account-boundary intent via verification instead of injection. Checked the seams: profile id is canonical ( Local proof (trusted source): Remaining item is the ClawSweeper owner decision: accepting the fail-before-spawn contract for imported profiles (missing/mismatched host login now fails with re-auth guidance instead of forwarding a soon-stale token). Behavior and docs ( |
|
Merged via squash.
|
|
Maintainer review + landing note. Contract acceptance: Accepting the credential-ownership split this PR introduces: imported ClawSweeper rank-up moves:
Independent review proof (beyond PR-body evidence):
Known accepted tradeoff: a host whose Claude keychain is unreadable at prepare time now fails closed with the exact re-auth command instead of coasting on a still-valid stored copy — visible failure over silent 401s. |
…ed OAuth tokens (openclaw#115134) * fix(auth): refresh selected Claude CLI profiles * fix(auth): run imported Claude CLI logins as verified native passthrough * fix(auth): satisfy CLI auth failure exhaustiveness * docs: remove PR changelog entry --------- Co-authored-by: Alex Knight <[email protected]>
…1-prep * commit 'be24db5f72a6992273f90f707305f8650643523a': (24 commits) fix(auth): reuse Claude CLI logins natively and stop forwarding expired OAuth tokens (openclaw#115134) fix(gateway): cancel disconnected HTTP tool calls (openclaw#115550) fix(memory): preserve Unicode in short-term promotion (openclaw#115591) fix(heartbeat): deliver task-preempted same-session commitments (openclaw#115581) feat(ui): add plugin Discover path URL (openclaw#115587) feat(chat): show live run telemetry across clients (openclaw#113084) fix(web-fetch): speed up large styled pages (openclaw#115584) fix(gateway): harden config patch writes (openclaw#115579) fix(feishu): accept valid empty inbound message bodies (openclaw#115583) refactor(ollama): unify local model onboarding (openclaw#115543) refactor: make Telegram release workflow tests behavioral (openclaw#114023) fix(ui): contain model picker scrolling (openclaw#115473) fix(whatsapp): prevent replies from suppressing other chats (openclaw#115574) fix(agents): normalize OpenAI-compatible CLI usage aliases (openclaw#115564) fix(gateway): canonicalize session keys in chat.subscribe and chat.unsubscribe handlers (openclaw#111830) fix(gateway): reconnect nodes after transient socket failures (openclaw#115539) fix(qa): run profile scenarios on every eligible channel (openclaw#115540) fix(configure): ignore blank gateway env credentials in wizard probes (openclaw#113096) chore(i18n): refresh native locales (openclaw#115532) fix(outbound): strip leaked inline runtime context (openclaw#115561) ...
Closes #115137
Related: #112733
Regression source: #112458 (first shipped in
2026.7.2-beta.4)What Problem This Solves
Since
2026.7.2-beta.4, Claude CLI runs on a selected OAuth profile could forward an expired access token to Claude Code, and the forwarded descriptor also overrides Claude Code's native login — so Claude could no longer refresh its own credentials during runs. Reusedclaudelogins therefore went stale within hours of the host's last nativeclaudeuse and every run died silently with a 401. Multi-account setups could additionally have the resolver substitute a different profile.Why This Change Was Made
Imported
claudelogins are Claude's own credential family: the refresh token rotates single-use, so OpenClaw deliberately has no refresh path for them — any forwarded snapshot is unrefreshable by both sides. This PR splits the two credential families at preparation time:provider: "claude-cli"OAuth) now run as identity-verified native passthrough: OpenClaw verifies the host's liveclaudelogin matches the selected profile's account, then spawns Claude with no forwarded credential so it authenticates and refreshes natively — restoring the self-sustaining pre-beta.4 loop deliberately instead of accidentally. A missing host login or an account mismatch fails before spawn with the exact re-auth commands (the account boundary from fix(anthropic): forward selected profiles to Claude CLI #112458 is enforced by verification instead of injection).allowProfileFallback: false), and the Anthropic plugin independently rejects expired forwarded OAuth as a backstop.google-gemini-cliis unaffected by the stale-snapshot failure mode: its plugin stages refresh material into the CLI's own credential store, so Gemini self-heals on expiry.User Impact
Claude CLI reuse works unattended again: runs keep Claude's own login fresh instead of depending on someone using
claudeinteractively on the host. Managed profiles forward freshly rotated tokens. Runs that cannot authenticate correctly (unmaterializable selection, substituted profile, missing host login, wrong account, expired managed token) fail before spawn with an actionable message instead of silent 401 exits. Note: the claude-cli auth-epoch basis changes for passthrough runs (the host login identity joins the hash), so existing reusable Claude CLI sessions reset once after upgrading; the identity hash is rotation-stable afterwards.Evidence
node scripts/run-vitest.mjs src/agents/cli-runner/prepare.test.ts— 88 tests passed, including new coverage: native passthrough forwards no credential and skips the resolver; missing host login fails closed withclaude auth loginguidance; different-account host login fails closed; managed-profile refresh/persist/forward, no-revive, no-fallback-substitution, and refresh-failure-surfacing tests retargeted to the managed (provider: "anthropic") family they now govern.node scripts/run-vitest.mjs src/agents/command/attempt-execution.cli.test.ts src/agents/embedded-agent-runner/cli-backend-dispatch.test.ts src/system-agent/setup-inference.test.ts extensions/anthropic/cli-shared.test.ts— 3 shards passed (45 extension tests).tsgocore, core-test, and extensions lanes passed locally;oxfmton touched files. Blacksmith Testbox backend was unreachable (network timeout), so heavier proof ran locally per the trusted-source fallback policy; hosted CI on this push supersedes it.2026.7.2-beta.5: importedanthropic:claude-cliprofile expired exactly 8h after the last nativeclaudeuse; store row never rewritten afterwards; every subsequent run spawned and died in ~6s with no transcript output; installed dist verified to contain the revive-and-forward path and none of this branch's guards; no refresh path exists forprovider: "claude-cli"credentials (no pluginrefreshOAuthhook, core registry only registersanthropic).AI-assisted change. I reviewed the implementation and validation evidence and understand the passthrough-verification, refresh-ownership, and fail-before-spawn behavior.