Repository navigation
fix(cron): start forced automations after the requesting turn ends - #188513
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 SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 736e6a236c
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if ( | ||
| params.job && | ||
| params.resolveCronAgent && | ||
| (params.evt.status === "skipped" || (params.evt.status === "error" && params.runNotStarted)) |
There was a problem hiding this comment.
Keep intentional scratch-empty skips silent
For a recurring job with payload.skipIfScratchEmpty: true, this condition turns every intentionally suppressed check into a conversation warning telling the user to resolve a cause and run it again. executeJobCore returns status: "skipped" with the summary Automation scratch is explicitly empty, and finalization publishes that outcome for scheduled runs too. The default proactive job enables this policy and runs every 30 minutes, so leaving its scratch empty now repeatedly appends notices despite there being nothing requiring attention. Exclude intentional policy skips from these failure notices, or scope the notices to explicitly requested runs.
Useful? React with 👍 / 👎.
| outcome.executionStarted === false | ||
| ? { ...eventContext, runNotStarted: true } | ||
| : eventContext, |
There was a problem hiding this comment.
Propagate non-start metadata from preparation failures
When an accepted run fails during model selection or hits the setup watchdog before execution, the new conversation notice is still omitted. For example, resolveCronRunPreparation returns an error result when resolveCronModelSelection fails without setting executionStarted: false; runCronIsolatedAgentTurn and executeDetachedCronJob preserve that undefined value. The setup-timeout outcome in timer-job-runner.ts also omits the field. Consequently, this strict comparison never sets runNotStarted, and the notification dispatcher rejects these pre-execution errors. Propagate an authoritative non-start flag from those preparation and timeout paths so the newly promised failure notice covers them.
Useful? React with 👍 / 👎.
|
Codex review: needs real behavior proof before merge. What this changesThis PR hands accepted manual automation runs to scheduled execution authority and adds conversation notices when runs cannot start. Example: A daily automation scheduled at 16:00 is force-run from its owning conversation at 15:41.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness⛔ Blocked before merge - 5 items remain Keep open: this PR addresses a current automation failure, but two notification defects need repair. Priority: P2 Before merge
Findings
Tests
Agent review detailsHow this fits togetherThe Gateway admits automation requests, the durable cron queue selects work, and the launcher executes under scheduled authority before recording history and publishing conversation results. flowchart LR
A[Requesting agent turn] --> B[Cron request admission]
B --> C[Durable run queue]
C --> D[Scheduled run launcher]
D --> E[Agent execution]
E --> F[Outcome finalization]
F --> G[History and conversation result]
Technical reviewBest possible solution: Keep the scheduler handoff, classify non-start outcomes at their producers, and send actionable notices through the existing conversation-result writer. Do we have a high-confidence way to reproduce the issue? The incident records an accepted request followed by an expired-caller skip, and current-main source shows the corresponding guard after the idle wait; the PR reports red-on-base and green-on-head Gateway coverage, which was inspected but not executed during this read-only review. Is this the best way to solve the issue? Moving the accepted request to the existing scheduler owner addresses the lifecycle mismatch without another queue or configuration option, but notice eligibility and producer metadata need correction. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 7861f59337f9. Merge-risk optionsMaintainer options:
Provenance checked
TestingProof path: in-process harness. SecurityNeeds attention: The changed authority handoff needs queued-revocation proof; inspection established no concrete bypass. EvidenceSecurity concerns:
What I checked:
Likely related people:
PR surfaceSource +79, Tests +7, Docs +1. Total +87 across 12 files. Added test files: 1. View PR surface stats
Review metrics
LabelsLabel changes:
Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment Reviewed October 30, 2026, 12:38 PM ET / 16:38 UTC. |
Align manual cron fixtures and documentation with durable enqueue authority while retaining cleanup and eligibility controls. Refs #188513.
…penclaw#188513) A forced automation run requested from inside an agent turn, for a job that targets that same conversation, is deferred until the turn ends. Launch re-checked the requesting tool caller's authority, which had ended by construction, so every such run was skipped with "agent tool caller authority is no longer active" and the conversation got no notice (Team, 2026-10-30, Dependency Updater "do it now"). Request authority is now checked once at enqueue; launch uses the job's scheduled authority with the existing final eligibility check (job present, owner/source current, not disabled after enqueue). Skipped or unstarted runs post a notice in the owning conversation through the existing cron result writer. Unauthorized force requests and requests revoked before commit remain refused.
…law#188704) Align manual cron fixtures and documentation with durable enqueue authority while retaining cleanup and eligibility controls. Refs openclaw#188513.
Align manual cron fixtures and documentation with durable enqueue authority while retaining cleanup and eligibility controls. Refs #188513. (cherry picked from commit 4fba134) Co-authored-by: RomneyDa <[email protected]>
Backport main PR #188513 so a manual automation accepted by the scheduler no longer depends on the requesting tool generation after enqueue. Preserve event-ingress custody and the final live job eligibility checks. Co-authored-by: RomneyDa <[email protected]>
What Problem This Solves
Fixes a same-session automation's “run it now” request being silently skipped as soon as the requesting agent turn ends.
User Impact
An authorized run-now request starts after the requesting turn finishes. If the job is disabled, removed, or otherwise cannot start, the owning conversation receives a short notice with the reason and a next step. Request-time
cron.*permissions and the scheduled job's live owner/grant checks remain enforced.Why This Change Was Made
Enqueueing is the manual request's authorization boundary. The queue previously retained and rechecked the requesting tool turn's authority after waiting for that same turn to end, making the handoff fail by construction. Accepted runs now use the existing scheduled execution authority. Event-ingress transfer and on-exit source custody retain their separate checks.
Non-start outcomes use the existing cron conversation-result commit, including its idempotency and transcript-generation checks. No new queue, recovery owner, persisted shape, configuration, or dependency is introduced. Force-running a job that was already disabled remains supported; disabling it after enqueue prevents launch.
Evidence
Incident timeline, 2026-10-30 UTC: a daily job targeting the caller's session used
0 16 * * *andwakeMode: now. At 15:41:58.899 the agent requestedrunMode: forcewithtimeoutMs: 1000and received an enqueued receipt with the “starts after this turn” note. The turn ended at 15:42:01.874. At 15:42:02.034 the receipt finishedskipped, withagent tool caller authority is no longer activeand deliverynot-started. No follow-up turn or conversation notice appeared.The new regression runs a real agent turn and automations tool through an isolated Gateway against a synthetic HTTP Responses provider. On base
1d6f75fd745062cb4bf0ca94bc53b256d3659af5, it reproduced that exact skipped receipt and stopped after three provider calls. With the fix it completes a fourth call in a new turn in the same session. A second scenario disables the job before the caller ends: no agent turn starts, history records the skip, and the transcript contains exactly one notice.OPENCLAW_VITEST_RUNTIME=<node|bun> OPENCLAW_E2E_USE_PREBUILT_DIST=1 node scripts/run-vitest.mjs src/gateway/cron-forced-after-turn.e2e.test.ts --maxWorkers=1— passed. The prebuilt runtime was prepared by the initial normal E2E invocation; changed source workers were rebuilt and verified by the wrapper.pnpm tsgo:core; touched test projectstest/tsconfig/tsconfig.core.test.services-cron.jsonandtest/tsconfig/tsconfig.core.test.gateway-root.json; targeted Oxlint and formatting; one-file MDX check;git diff --check— passed.The diff adds 79 production lines, 7 net test lines, and one documentation line. The test increase replaces a mocked lifecycle test and the superseded caller-retention contract with the real Gateway handoff and notice proof. Most production growth is the previously missing conversation notice.
Notices are best effort through the existing result writer: a missing owning transcript or a generation change during commit is logged, while durable cron history remains authoritative. This does not add notice replay after a Gateway crash. No live Gateway or real user state was accessed; no deployment, release, or migration was performed.