Repository navigation
fix(cron): forward claude-cli auth profile on scheduled runs to prevent OAuth expiration - #144266
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. Reviewed September 10, 2026, 7:04 PM ET / 23:04 UTC (Revision 6). ClawSweeper reviewWhat this changesScheduled and queued agent runs now use the shared CLI credential selector, with regression coverage for managed credentials, native login, and incompatible account selections. Merge readiness✅ Ready for maintainer review This remains a useful fix: current main still misses the credential handoff, and the latest commit resolves the two concrete concerns raised in the maintainer discussion. No blocking patch defect was found. Priority: P1 Review scores
Verification
How this fits togetherScheduled jobs and queued replies select a model and execution backend before starting an agent. The CLI credential selector determines which stored account reaches that backend, while the runner controls credential delivery and session reuse. flowchart TD
A[Scheduled job] --> C[Model and backend selection]
B[Queued reply] --> C
C --> D[Shared CLI credential selector]
E[Stored profiles and account selection] --> D
D --> F[Reject incompatible account]
D --> G[CLI runner and session boundary]
G --> H[Authenticated agent result]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource +43, Tests +523. Total +566 across 4 files. View PR surface stats
Review metricsNone. Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Technical reviewBest possible solution: Keep cron, queued replies, and direct commands on the existing CLI credential policy, preserving explicit account boundaries and native-login session isolation. Do we have a high-confidence way to reproduce the issue? Yes: current-main source omits the cron profile while Claude disables automatic profile selection, matching the reported headless managed-credential failure. This review did not execute repository code. Is this the best way to solve the issue? Yes: both callers now reuse the established credential owner instead of weakening native-login safeguards or introducing another selection policy. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 1180b0592364. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (5 earlier review cycles)
|
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. |
|
🦞👀 Re-review progress:
|
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
Independent review of
Two fixes remain before landing:
I prefer this cron implementation over #144221 because it preserves shared auth policy and supplies the executing candidate's provider. The independent checks verify credential selection and real subprocess credential transport with synthetic credentials, not installed-Claude OAuth login or refresh. The author's installed-Claude evidence is separate. |
|
Reviewed
This is a focused cron CLI credential-forwarding repair that reuses the existing resolver and preserves explicit account boundaries and native-login behavior. Local model/CLI execution and fallback orchestration were simulated; the contributor's installed-Claude transcript remains author-supplied evidence, not a live run independently reproduced here. No full Gateway restart guarantee is inferred. No blocking defect was demonstrated in the tested paths. I have not run native preparation or merge; current-main landing checks remain with the maintainer taking over. Thanks @MasterSwords1 for the targeted fix and regression coverage! Worked on by: @IWhatsskill, @fuller-stack-dev |
Use the existing CLI credential owner for queued candidates, preserving explicit account boundaries and native login. Isolate persisted cron auth fixtures. Completes the managed CLI credential handoff for cron and queued runs described in openclaw#144266 and openclaw#144047.
|
Updated the PR with the queued-followup repair and isolated cron fixtures at I also checked the other agent's persisted-provenance review. Its conclusion matches the production normalization path: legacy manual pins become Verification:
The independent subprocess checks use synthetic credentials. Installed-Claude OAuth acceptance/refresh remains author-supplied evidence, and no full Gateway restart guarantee is inferred. All task-owned Crabbox leases are released. The full PR is production +45/-2, tests +524/-1. The 43 production lines connect cron and queued callers to the existing credential owner; no new policy helper, config, store, or session-invalidation path was added. @clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
Final maintainer verification for
Thanks @MasterSwords1 for the original fix and installed-Claude evidence, and @IWhatsskill for the additional boundary review. |
|
Merged via squash.
|
…nt OAuth expiration (openclaw#144266) * fix(cron): forward claude-cli auth profile on scheduled runs * fix(agents): resolve managed CLI auth for queued runs Use the existing CLI credential owner for queued candidates, preserving explicit account boundaries and native login. Isolate persisted cron auth fixtures. Completes the managed CLI credential handoff for cron and queued runs described in openclaw#144266 and openclaw#144047. --------- Co-authored-by: Jason (Json) <[email protected]>
…ns (#146095) ## What Problem This Solves A saved subscription token was dropped before CLI execution unless the account was explicitly selected. Default turns reported “Not logged in” and used the configured fallback (#144793). ## Why This Change Was Made The shared selector forwards saved subscription credentials using account order. This restores 2026.9.1 behavior and reverses the forwarding restriction from #144266. @MasterSwords1 for awareness. ## User Impact New sessions use saved subscription tokens without an account selection or native login file. Existing sessions keep their account and history until the user selects another account or the stored profile is removed. ## Evidence - Token-only default: before, all 10 turns failed at 1/2/3/4 concurrency; after, all succeeded without fallback. - Native conversation: before, saving a token and restarting switched accounts and omitted history; after, the real CLI resumed the same native session with prior history. Fresh sessions and explicit changes used the saved token. - Registered `chat.send` → `agent.wait` → `chat.history` and recording endpoints exercised both paths. All 16 valid saved-config fixtures reached readiness; the invalid legacy fixture was rejected. Published 2026.9.1 passed the token-only cases. ## Compatibility Explicit pins, native selections and empty orders retain their meaning. Provider API keys require explicit selection for this subscription route. Cross-account history protection and fallback policy are unchanged. No schema, config-key or API changes. ## Consumers - Chat replies and scheduled turns: keep the session account. - Direct CLI turns: preserve scoped credentials for every supported backend. - System-agent setup: uses the ordered saved credential; verified conversations retain their bound route. - Integration-test scheduling: prepares runtime artifacts using existing runner capacity. ## Invalidation Each turn reads current credentials and the session binding; saving tokens or changing account order preserves an existing account, while profile removal or a new session permits selection, and restart restores the saved binding. ## Contention No new lock or queue. Real CLI overlap at 2/3/4 turns passed; Gateway health responded within 0.8 seconds. ## Tests Five registered chat cases cover defaults, native continuity, explicit changes, account order/removal, empty order and API-key-only setup. All 152 direct CLI cases pass. Timing and planner baselines are unchanged. Co-authored-by: Ayaan Zaidi <[email protected]>
…ns (openclaw#146095) ## What Problem This Solves A saved subscription token was dropped before CLI execution unless the account was explicitly selected. Default turns reported “Not logged in” and used the configured fallback (openclaw#144793). ## Why This Change Was Made The shared selector forwards saved subscription credentials using account order. This restores 2026.9.1 behavior and reverses the forwarding restriction from openclaw#144266. @MasterSwords1 for awareness. ## User Impact New sessions use saved subscription tokens without an account selection or native login file. Existing sessions keep their account and history until the user selects another account or the stored profile is removed. ## Evidence - Token-only default: before, all 10 turns failed at 1/2/3/4 concurrency; after, all succeeded without fallback. - Native conversation: before, saving a token and restarting switched accounts and omitted history; after, the real CLI resumed the same native session with prior history. Fresh sessions and explicit changes used the saved token. - Registered `chat.send` → `agent.wait` → `chat.history` and recording endpoints exercised both paths. All 16 valid saved-config fixtures reached readiness; the invalid legacy fixture was rejected. Published 2026.9.1 passed the token-only cases. ## Compatibility Explicit pins, native selections and empty orders retain their meaning. Provider API keys require explicit selection for this subscription route. Cross-account history protection and fallback policy are unchanged. No schema, config-key or API changes. ## Consumers - Chat replies and scheduled turns: keep the session account. - Direct CLI turns: preserve scoped credentials for every supported backend. - System-agent setup: uses the ordered saved credential; verified conversations retain their bound route. - Integration-test scheduling: prepares runtime artifacts using existing runner capacity. ## Invalidation Each turn reads current credentials and the session binding; saving tokens or changing account order preserves an existing account, while profile removal or a new session permits selection, and restart restores the saved binding. ## Contention No new lock or queue. Real CLI overlap at 2/3/4 turns passed; Gateway health responded within 0.8 seconds. ## Tests Five registered chat cases cover defaults, native continuity, explicit changes, account order/removal, empty order and API-key-only setup. All 152 direct CLI cases pass. Timing and planner baselines are unchanged. Co-authored-by: Ayaan Zaidi <[email protected]>
Closes #144047
What Problem This Solves
Fixes an issue where scheduled cron jobs and isolated agent follow-up runs backed by
claude-cli(or canonical Anthropic routes routed through Claude CLI) would experience"OAuth session expired"errors on every scheduled run, while ordinary user turns succeeded.Why This Change Was Made
In
src/cron/isolated-agent/run-executor.ts, when running a CLI-backed candidate (cliExecution: true),runCliAgentwas invoked without passingauthProfileId. Becauseclaude-cliconfiguresautoSelectAuthProfile: falseto safeguard native logins when no profile is explicitly passed, omittingauthProfileIdcaused the runner to execute without OpenClaw's stored OAuth credentials.Cron isolated agent execution now resolves and forwards the active or ordered CLI auth profile to
runCliAgent, matching user turns inattempt-execution.ts. Specifically:cliBackendAcceptsAuthProfileForwarding.resolveCliExecutionAuthProfileIdprior towithLocalSessionPlacementTurnSettlementso incompatible user-locked profiles reject cleanly before admission without leaking turn settlement locks.authProfileIdSourceas"auto"in cron jobs (matching line 482 ofrun-executor.ts), allowing clean fallback to ordered CLI profiles without erroneously triggering strict user-lock rejections.authProfileIdintorunCliAgent({ ..., trigger: "cron", jobId: params.job.id, authProfileId }).applyCliSessionBindingResultandpersistSessionEntry, resetting invalidated session state when moving from native login to managed OAuth.User Impact
Scheduled cron tasks using
claude-clior Anthropic models configured with CLI backends now reliably access authenticated OAuth profiles and execute successfully without "OAuth session expired" failures. Native logins remain safely unforwarded when no managed profile is configured.Adversarial Review (Code & Proofs)
In accordance with our adversarial review process, an independent contrarian security reviewer critically evaluated both the code fix and the verification proof methodology:
run-executor.ts):authProfileIdSourceto"auto"could allow an attacker or legacy session to silently substitute credentials on fallback.authProfileIdSourcereflects the auto-selected primary profile configured inauth.orderor agent model defaults. If unspecified source were treated as user-locked, any cron job whose primary model fails (e.g. HTTP 401 or upstream outage) and falls back to Claude CLI would fail closed instead of cleanly falling back to the orderedclaude-cliprofile. Only an explicitsource === "user"indicates a user-pinned profile that must fail closed (matchinguserLockedAuthProfileIdat line 482 ofrun-executor.ts). Both behaviors are rigorously verified in automated tests and live binary proofs (Scenarios 4 and 5).verify-execute-cron-run.ts):runCliAgentdirectly and only tested fresh sessions (isNewSession: true) with no-op persistence, omitting the existing-session binding transition (isNewSession: false).executeCronRundirectly (the exact owner function altered by this PR) with real session persistence (persistSessionEntry). Added Scenario 6 covering the multi-turn transition: Turn 1 runs with native login (authProfileId: undefined) and persists the native binding. Turn 2 runs withisNewSession: falseon the same session upgraded to managed OAuth. The runner detects the auth boundary (cli session reset: provider=claude-cli reason=auth-profile,reuse=invalidated:auth-profile), completes the turn with installed Claude Code binary (TURN2_MANAGED_OK), and persists the new managed profile binding.Evidence
1. Direct
executeCronRunReal Behavior Verification with Installed Claude CLI (v2.1.232)Executed end-to-end against installed Claude Code binary (
/home/masterswords/.gemini/antigravity-cli/bin/claudev2.1.232) directly throughexecuteCronRun. All 6 scenarios executed and completed successfully:Verification Script Source (
scratch/verify-execute-cron-run.ts)2. Automated Test Suite Verification
Run against isolated agent auth profile propagation test suite: