Skip to content

fix(cron): forward CLI auth profiles to isolated runs - #144221

Closed
harshitgupta31415 wants to merge 3 commits into
openclaw:mainfrom
harshitgupta31415:codex/fix-claude-cli-cron-auth-144047
Closed

harshitgupta31415 wants to merge 3 commits into
openclaw:mainfrom
harshitgupta31415:codex/fix-claude-cli-cron-auth-144047

Conversation

@harshitgupta31415

@harshitgupta31415 harshitgupta31415 commented Sep 10, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #144047

Reporter: @angeliti999

What Problem This Solves

Scheduled cron runs using a CLI-backed model lost the auth profile selected during cron preparation. The initial profile could be forwarded unchanged to a fallback CLI candidate, allowing the wrong credential owner to reach the backend or causing a valid managed run to fall back to native login.

Why This Change Was Made

The cron executor now resolves CLI auth at each candidate's execution-provider boundary through the existing resolveCliExecutionAuthProfileId owner. Candidate-owned CLI profiles may be forwarded; automatic canonical Anthropic selections preserve native Claude login; automatic cross-provider profiles are not carried into Claude CLI; explicit incompatible or missing profiles fail closed. Missing auth-selection provenance is normalized to automatic, matching the resolver contract and the candidate pattern referenced by #144266.

User Impact

CLI-backed cron jobs keep their selected managed profile when the selected CLI backend owns it. Fallback candidates cannot inherit an unrelated automatic credential, and explicit account mismatches stop before execution. No configuration, dependency, or public API surface changes.

Evidence

  • Red-before proof on upstream base 0f68d696c3cc9c93bb45048f8c72036e577490de: the focused cron regression failed because runCliAgent received no authProfileId (2 passed, 1 failed).
  • Current head: 8d8b48c2421c1703fea14551671aa7b0a25d34d0.
  • Green-after focused cron suite:
    node_modules\\.bin\\vitest.cmd run --config test/vitest/vitest.cron.config.ts src/cron/isolated-agent.auth-profile-propagation.test.ts --maxWorkers=1 --testTimeout=180000 — 4/4 passed.
  • Candidate auth-owner suite:
    node_modules\\.bin\\vitest.cmd run --config test/vitest/vitest.agents-core.config.ts src/agents/cli-execution-auth.test.ts — 19/19 passed. Coverage includes native-login preservation, omitted provenance, cross-provider fallback denial, explicit incompatibility, missing profiles, and backend-owned ordered profiles.
  • Installed-backend process proof at this head: the cron test executes the production runCronIsolatedAgentTurn path, captures authProfileId: anthropic:managed at the CLI dispatch boundary, then runs the captured call through a registered CLI backend fixture using the real prepareCliRunContext and executePreparedCliRun. The fixture launches a real Node child process, and the observed output is anthropic:managed. This proves the selected profile identity crosses the cron-to-backend boundary; it is not presented as live Claude provider E2E.
  • Core typecheck passed:
    node scripts/run-tsgo.mjs -p tsconfig.core.json --incremental --tsBuildInfoFile .artifacts/tsgo-cache/core.tsbuildinfo.
  • Targeted Oxlint, Oxfmt, and git diff --check passed.
  • check:changed remains unclaimed because an earlier run was interrupted in the core-test typecheck lane.
  • No live Claude credential or provider endpoint is available in this environment, so live provider E2E and provider-side token/session rotation proof are not claimed.
  • Fresh autoreview was unavailable on the Windows runtime (reviewer_unavailable, no report produced).
  • Production delta for this follow-up is +3 lines in the resolver; test delta is +130 net lines across focused resolver and cron coverage.
  • Maintainer edits are enabled.

Limitations

The deterministic installed-backend proof verifies profile identity propagation and process execution. It does not claim a live Claude login, provider token refresh, or an account reassignment during an in-flight run.

@clawsweeper

clawsweeper Bot commented Sep 10, 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 P1 High-priority user-facing bug, regression, or broken workflow. merge-risk: 🚨 auth-provider 🚨 May break OAuth, tokens, provider routing, model choice, or credentials. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Sep 10, 2026
@clawsweeper

clawsweeper Bot commented Sep 10, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed September 10, 2026, 3:23 PM ET / 19:23 UTC (Revision 3).

ClawSweeper review

What this changes

The PR forwards backend-compatible authentication profiles to isolated cron attempts and treats unspecified selection provenance as automatic.

Merge readiness

⛔ Blocked before merge - 4 items remain

This remains a useful fix for an omission present on main and in v2026.9.3. The earlier candidate-selection finding is resolved; the new process fixture improves propagation coverage but does not satisfy the outstanding credential-boundary proof requirement.

Priority: P1
Reviewed head: 8d8b48c2421c1703fea14551671aa7b0a25d34d0

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The focused repair and added coverage are useful, but the remaining account-boundary evidence limits merge confidence.
Proof confidence 🦐 gold shrimp (3/6) Needs stronger real behavior proof before merge: Authority-chain proof required: the reported real Node child output demonstrates profile-name propagation through preparation and execution, but mocked selection and the replacement backend bypass Claude credential materialization. Actual cron/fallback evidence must establish managed and native outcomes plus rejection of incompatible or invalidated identities before credential I/O and stale session reuse. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Patch quality 🦐 gold shrimp (3/6) Security review found an item that needs attention.

Verification

Check Result Evidence
Real behavior Needs proof Needs stronger real behavior proof before merge: Authority-chain proof required: the reported real Node child output demonstrates profile-name propagation through preparation and execution, but mocked selection and the replacement backend bypass Claude credential materialization. Actual cron/fallback evidence must establish managed and native outcomes plus rejection of incompatible or invalidated identities before credential I/O and stale session reuse. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Evidence reviewed 9 items Introduced change and review continuity: The supplied complete merge-base-to-head patch establishes the four introduced files. Comparing the previous reviewed head with HEAD shows no further changes to run-executor.ts; its candidate-local resolver now addresses the earlier forwarding finding.
Current main still needs cron forwarding: The fetched main revision invokes runCliAgent without authProfileId, while the embedded branch forwards it. The complete changed executor and the shared resolver were inspected.
Release behavior: The v2026.9.3 executor also omits authProfileId from the CLI invocation. Its source was retrieved through GitHub after the local release blob was unavailable.
Findings None None.
Security Needs attention Profile invalidation is not covered at credential delivery: The selected profile crosses awaited work before backend credential preparation. The new fixture replaces the auth owner and prints a profile identifier, so it cannot establish rejection or safe session invalidation when that profile is removed or reassigned.

How this fits together

Cron executes scheduled agent prompts through model fallback candidates. For CLI-backed candidates, OpenClaw selects an authentication profile before the backend prepares credentials and starts its process.

flowchart TD
  A[Scheduled agent prompt] --> B[Model fallback candidate]
  C[Selected profile and auth store] --> D[CLI auth resolver]
  B --> D
  D --> E{Compatible identity?}
  E -->|Managed profile or native login| F[CLI backend preparation]
  E -->|Invalid explicit profile| G[Reject attempt]
  F --> H[CLI process and response]
Loading

Before merge

  • Add real behavior proof - Needs stronger real behavior proof before merge: Authority-chain proof required: the reported real Node child output demonstrates profile-name propagation through preparation and execution, but mocked selection and the replacement backend bypass Claude credential materialization. Actual cron/fallback evidence must establish managed and native outcomes plus rejection of incompatible or invalidated identities before credential I/O and stale session reuse. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
  • Resolve security concern: Profile invalidation is not covered at credential delivery - The selected profile crosses awaited work before backend credential preparation. The new fixture replaces the auth owner and prints a profile identifier, so it cannot establish rejection or safe session invalidation when that profile is removed or reassigned.
  • Resolve merge risk (P1) - Cron will newly materialize managed credentials instead of relying on native login. Final-effect evidence remains missing for incompatible selections and for a profile removed or reassigned between selection and execution, including prevention of stale CLI session reuse.
  • Complete next step (P2) - Add final-effect cron authentication evidence covering the actual backend and profile invalidation. Terminal output or redacted logs are sufficient; screenshots or recordings are welcome when they show diagnostics. Remove credentials, IP addresses, phone numbers, and private endpoints before posting. Updating the PR body should trigger a fresh review; if it does not, ask a maintainer to comment @clawsweeper re-review.

Findings

  • [medium] Profile invalidation is not covered at credential delivery — src/cron/isolated-agent/run-executor.ts:542
Agent review details

Security

Needs attention: No concrete exploit or supply-chain change was established, but the new credential handoff still needs final-effect authority proof.

PR surface

Source +17, Tests +247. Total +264 across 4 files.

View PR surface stats
Area Files Added Removed Net
Source 2 19 2 +17
Tests 2 249 2 +247
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 4 268 4 +264

Review metrics

None.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #144047
Summary: This PR is one of two open candidates for the reported cron auth omission; reply-dispatch identity handling is adjacent work.

Members:

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

Merge-risk options

Maintainer options:

  1. Complete credential-boundary evidence (recommended)
    Keep the PR open until cron evidence reaches the actual credential-delivery owner and demonstrates allowed, incompatible, and invalidated profile outcomes.

Technical review

Best possible solution:

Use the shared candidate-auth owner for cron while preserving native login and proving that invalidated identities cannot reach credential delivery or reuse another account's CLI history.

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

Yes, at source level: main omits the CLI auth profile, and the report supplies repeatable headless cron steps with a valid managed token. This review did not execute those steps.

Is this the best way to solve the issue?

Yes, reusing the existing candidate-auth resolver is the appropriate repair boundary; the supplied fixture is not sufficient validation of the resulting credential handoff.

AGENTS.md: found and applied where relevant.

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

Labels

Label justifications:

  • P1: The linked report documents repeated failures of scheduled jobs on v2026.9.3 while equivalent interactive turns authenticate successfully.
  • merge-risk: 🚨 auth-provider: The patch changes which credential a scheduled CLI process receives, and the fixture does not validate the real backend handoff.
  • merge-risk: 🚨 security-boundary: The newly forwarded profile crosses an account boundary whose removal and reassignment behavior remains unproven at final credential I/O.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🦐 gold shrimp.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs stronger real behavior proof before merge: Authority-chain proof required: the reported real Node child output demonstrates profile-name propagation through preparation and execution, but mocked selection and the replacement backend bypass Claude credential materialization. Actual cron/fallback evidence must establish managed and native outcomes plus rejection of incompatible or invalidated identities before credential I/O and stale session reuse. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.

Evidence

Security concerns:

  • [medium] Profile invalidation is not covered at credential delivery — src/cron/isolated-agent/run-executor.ts:542
    The selected profile crosses awaited work before backend credential preparation. The new fixture replaces the auth owner and prints a profile identifier, so it cannot establish rejection or safe session invalidation when that profile is removed or reassigned.
    Confidence: 0.93

What I checked:

  • Introduced change and review continuity: The supplied complete merge-base-to-head patch establishes the four introduced files. Comparing the previous reviewed head with HEAD shows no further changes to run-executor.ts; its candidate-local resolver now addresses the earlier forwarding finding. (src/cron/isolated-agent/run-executor.ts:542, 8d8b48c2421c)
  • Current main still needs cron forwarding: The fetched main revision invokes runCliAgent without authProfileId, while the embedded branch forwards it. The complete changed executor and the shared resolver were inspected. (src/cron/isolated-agent/run-executor.ts:650, 87f646243c44)
  • Release behavior: The v2026.9.3 executor also omits authProfileId from the CLI invocation. Its source was retrieved through GitHub after the local release blob was unavailable. (src/cron/isolated-agent/run-executor.ts, 1391f7cd2d40)
  • Process evidence has a substituted authentication boundary: The added test mocks profile selection and runCliAgent, then substitutes cron-auth-fixture and explicitly supplies anthropic:managed to preparation. Its backend copies the profile name into an environment variable for a Node child to print. This supports process execution and parameter propagation, but does not exercise Claude credential materialization, fallback rejection, or profile removal/reassignment. (src/cron/isolated-agent.auth-profile-propagation.test.ts:197, 8d8b48c2421c)
  • Actual credential delivery owner: Claude backend preparation consumes authCredential and constructs protected descriptor input; autoSelectAuthProfile is false. The test fixture does not use this owner. This is OpenClaw's Claude backend contract, with no affirmative dependency on the Codex harness. (extensions/anthropic/cli-backend.ts:254, 8d8b48c2421c)
  • Authority lifecycle requiring proof: Cron resolves the profile before awaited catalog and session work. CLI preparation subsequently loads and materializes credentials, and execution asserts run liveness. The supplied evidence does not establish the final credential/session outcome when the selected profile changes across that interval. (src/agents/cli-runner/prepare.ts:798, 8d8b48c2421c)

Likely related people:

  • unknown: The claimed source-line change could not be verified from bounded local history. (role: source history unknown; confidence: low)
  • unknown: The claimed source-line change could not be verified from bounded local history. (role: source history unknown; confidence: low)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Add redacted after-fix cron evidence through the actual Claude backend for managed credentials, native login, and fallback.
  • Prove incompatible profiles and removal or reassignment cannot deliver unauthorized credentials or reuse stale account sessions.

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-10T17:13:36.312Z sha b3b5c99 :: needs real behavior proof before merge. :: [P1] Resolve each CLI candidate through the existing auth-selection owner
  • reviewed 2026-09-10T18:04:02.386Z sha 714b57e :: needs real behavior proof before merge. :: none

@openclaw-barnacle openclaw-barnacle Bot added the agents Agent runtime and tooling label Sep 10, 2026
@harshitgupta31415

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Sep 10, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. labels Sep 10, 2026
@harshitgupta31415

Copy link
Copy Markdown
Contributor Author

@openclaw/openclaw-secops please review the auth-boundary evidence for this draft PR.

Current head: 8d8b48c2421c1703fea14551671aa7b0a25d34d0.

The focused cron test now executes the production cron path, captures the candidate-owned authProfileId, and runs that captured call through a registered installed-backend fixture using the real prepareCliRunContext and executePreparedCliRun; a real Node child process returns the selected profile identity. Resolver tests cover native-login preservation, omitted provenance, cross-provider fallback denial, explicit incompatibility, missing profiles, and ordered backend-owned profiles.

No live Claude credential or provider endpoint is available locally, so live provider E2E and in-flight account reassignment proof are explicitly not claimed.

@harshitgupta31415

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Sep 10, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Sep 10, 2026
@harshitgupta31415
harshitgupta31415 deleted the codex/fix-claude-cli-cron-auth-144047 branch September 20, 2026 13:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling merge-risk: 🚨 auth-provider 🚨 May break OAuth, tokens, provider routing, model choice, or credentials. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: M status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

1 participant