Repository navigation
fix: keep scheduled work with cron across Gateway restarts - #201757
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 Summary: ✅ CompletedThis 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: 748fc24abd
ℹ️ 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".
|
Codex review: needs maintainer review before merge. What this changesThis PR leaves interrupted scheduled turns under cron ownership while preserving accepted user work and correcting restart-failure attribution. Example: A cron job runs in agent:other:main:thread:restart-resume-0-stream when the Gateway restarts.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep this PR open: current main still selects scheduled conversation work for operator recovery, and the prior backend-detach finding is resolved with no new blocking code defect found. Priority: P2 Before mergeNone. FindingsNone. Tests
Agent review detailsHow this fits togetherGateway shutdown selects live controller and registry work, preserves queued-input custody, and writes session restart markers that startup consumes through existing authority checks. flowchart TD
A[Live session controller] --> C[Restart selection]
B[Run registry] --> C
C --> D[Session restart markers]
D --> E[Startup authority admission]
E --> F[Conversation continuation]
C --> G[Cron retains scheduled work]
Technical reviewBest possible solution: Keep the existing controller, cron scheduler, and restart persistence owners, using retained logical run associations to preserve accepted user obligations. Do we have a high-confidence way to reproduce the issue? Current-main selection exposes the reported path, and the author reports a parent-red/head-green Gateway regression; this read-only review executed no target code. Is this the best way to solve the issue? The patch fixes selection at its existing owner, preserves queued custody, and replaces the prior attached-backend check with the controller's retained association. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against dbf41b9173f6. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
PR surfaceSource +44, Tests +203, Docs +5, Other +17. Total +269 across 11 files. Added test files: 1. View PR surface stats
Preflight sourceSource unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified. 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 HistoryReview history (1 earlier review cycle)
Reviewed November 19, 2026, 5:13 AM ET / 10:13 UTC (Revision 2). |
Use the existing retained run association so accepted user replies survive provider backoff. Update the inherited parent restart assertion from #201706 to require the restored child completion instead of a duplicate generic resume.
|
Addressed the latest review on
The cited CI parent-recovery failure reproduces on exact main parent The subprocess Gateway regression exercises the real scheduler, agent, session database, shutdown, startup admission and operator continuation against a deterministic synthetic Responses endpoint. It is red on the parent and green on this repair; cron runs on its next tick without an operator-authority notice. This is synthetic-provider boundary evidence, not a live-provider claim. No provider protocol, schema, configuration or migration changed. @clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Merged via squash.
|
…201757) * fix(gateway): keep interrupted automation with its scheduler * fix(gateway): retain steered work between backend attempts Use the existing retained run association so accepted user replies survive provider backoff. Update the inherited parent restart assertion from openclaw#201706 to require the restored child completion instead of a duplicate generic resume.
* fix(gateway): keep interrupted automation with its scheduler * fix(gateway): retain steered work between backend attempts Use the existing retained run association so accepted user replies survive provider backoff. Update the inherited parent restart assertion from #201706 to require the restored child completion instead of a duplicate generic resume. (cherry picked from commit cb04fef) Co-authored-by: RomneyDa <[email protected]> (cherry picked from commit 2324999c64c047bc97813153e345d35cdf26be2b) (cherry picked from commit 1d8de7fa3709981f7b6fcfd176d79f0277f9112d)
What Problem This Solves
Restarting the Gateway while a scheduled automation runs in an ordinary conversation can tell the conversation owner that their request could not resume, even though they never sent that request. Shutdown was selecting the cron execution for operator recovery; its marker cleared correctly, but the next interrupted occurrence could be selected again.
User Impact
Scheduled work keeps the cron scheduler's retry and next-tick behavior without an operator-authority failure notice. Interrupted operator turns still resume, and accepted queued inputs retain their durable custody. No configuration or schema changes are needed.
Why This Change Was Made
Shutdown selection now honors the live input's automation owner and avoids selecting the same controller operation again through the run registry. A child-root candidate cannot override an active root's cron ownership. Accepted user-reply obligations retain the existing recovery path, including retry backoff while the backend is detached. Selection reads the controller’s retained run association. Failure diagnostics use a current writer/lifecycle run ID when available instead of attributing the failure to a historical
lastRunId.The live-owner selection moved into a focused sibling module to stay within the existing line limit. Production grows by 44 lines for that boundary and the explicit ownership decision; there is no new cache or persisted state. Requester-settle recovery remains unchanged, including the completion restoration from #201706.
Evidence
The new real-Gateway regression fails on parent
f250a678c8138fcf86799cb3ef2db692b61936c9: shutdown writes an unavailable-operator marker for the dashboard cron turn. With the fix, that marker is absent, a concurrent operator turn resumes, and cron runs on its next tick without an operator-authority notice. All 62 focused restart/admission/yield/custody tests passed. A second regression fails on the initial PR head when a steered cron turn detaches its backend; the repaired selector preserves its required user reply. The 34 steering tests and affected subagent cancellation tests pass.A synthetic fixture contained 10,000 sessions, 1,000,000 events, a 35.13 GiB agent database, and 62,000 workspace files totaling 1.116 GB. Five counterbalanced pairs with three calls per arm used 30 operator and 30 cron registry-only owners. This measures the run-registry fallback, not provider retries or steering; that measured path is unchanged by the backoff repair. Markers fell from 60 to 30 and worker tasks from 121 to 61 per call. Median owner wall time was 174.38 → 49.20 ms, process CPU 142.18 → 75.34 ms, and separately sampled host allocation 6.96 → 3.71 MiB. Shared-host timing was noisy: timing A/A medians were 388.92/218.30 ms, CPU 183.92/152.81 ms; allocation A/A was 6.91/6.99 MiB. These are local APFS owner measurements, not production/btrfs restart latency claims.
The initial CI run also exposed a stale assertion in the existing graceful-shutdown parent test. It fails identically on exact main parent
f250a678c8138; #201706 (d54f706b921a) restored the interrupted child completion, so the yielded parent receives that result instead of a generic resume. This PR updates the test to require exactly one matching child error completion, zero duplicate generic resumes, and a visible reply. Both graceful restart modes pass. This repairs an inherited main test regression; no subagent recovery implementation changes are included.Validation: real-Gateway regression; four focused owner suites;
pnpm check:changed; isolated Codex autoreview. No UI-imported production modules changed.