Repository navigation
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review endedClawSweeper stopped reviewing this revision because the pull request closed. |
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: c3bee88f72
ℹ️ 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".
c3bee88 to
c50e0d5
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c50e0d58b9
ℹ️ 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".
| receipt.deliveryNotStarted === true && | ||
| receipt.configRevision === resolveCronJobConfigRevision(job) && | ||
| !job.state.runningScheduleChangeId | ||
| ? resolveCronRestartRetryAtMs(job, runningAtMs, nowMs) |
There was a problem hiding this comment.
Persist that the restart retry has already been spent
When the fresh retry is itself interrupted before delivery, its new scheduled receipt satisfies these same predicates again because no durable fact records that the one allowed retry was consumed; markInterruptedStartupRun simply replaces startupCatchupAtMs with another deadline. Consecutive restarts can therefore rerun a tool-bearing turn indefinitely and amplify duplicate external effects, rather than allowing only one fresh retry. Persist and consume a retry budget when scheduling the first replacement, and exclude that replacement's receipt from further automatic retries.
AGENTS.md reference: AGENTS.md:L95-L95
Useful? React with 👍 / 👎.
| if (job.state?.lastError === STARTUP_INTERRUPTED_ERROR) { | ||
| commandBody += | ||
| "\n\nThe previous attempt was interrupted by a Gateway restart. Continue the unfinished task. " + | ||
| "Inspect the retained conversation and any tool effects before acting; do not repeat work or deliveries that already completed."; |
There was a problem hiding this comment.
Add continuation guidance only to the actual retry
When startup recovery sees a recurring agent turn whose delivery state is started/unknown or whose definition changed, it intentionally declines to schedule a retry but still records STARTUP_INTERRUPTED_ERROR as lastError. The next ordinary recurring occurrence then enters this branch and is instructed to continue the previous task, which can make it skip its new occurrence or duplicate prior effects even though replay was deliberately disallowed. Gate this guidance on a durable pending-restart-retry marker rather than historical lastError alone.
Useful? React with 👍 / 👎.
…177127) * fix(cron): continue scheduled turns interrupted by restart * fix(cron): preserve unknown delivery state during restart recovery
What Problem This Solves
Fixes scheduled agent turns that never continue after a Gateway restart, including one-shot jobs whose interrupted run was disabled while session recovery reported
delegated_authority_unavailable.User Impact
An enabled, unchanged time-scheduled agent job interrupted before delivery gets one fresh retry through cron. The session records a visible handoff notice. Possible prior delivery, operator cancellation, edited or disabled jobs, and command/script/event/process-exit work retain their existing non-replay behavior. No configuration or schema migration is required.
Why This Change Was Made
Cron already persists the job's delegation, but its occurrence grant is process-scoped. Generic session recovery cannot borrow an earlier operator turn's authority. Preserve the typed restart outcome, finish the old receipt as interrupted, and schedule a fresh occurrence through cron's existing worker-owned receipt admission and current authorization checks. Release the single interrupted cron session claim so that admission can proceed.
The retry asks the agent to reconcile retained history and prior tool effects. Receipt uniqueness prevents duplicate retry admission; this does not promise exactly-once arbitrary external tool effects. Jobs already disabled by an older build require operator recovery.
Evidence
Three graceful-restart regression scenarios pass, including an earlier operator source and steering: one interrupted attempt, one authorized retry, no third attempt after another startup.
Crash recovery before delivery retries once; delivery already accepted is not replayed.
Core typecheck passed using tsrs. Export-name collision guard passed. Import-closure guards: 22 tests passed.
Focused startup recovery: 10 passed; delivery recovery: 7 passed; one-shot ownership and batch finalization: 29 passed. Changed-file lint, format, and diff checks passed. Independent autoreview found no actionable P0/P1 findings.
Live isolated Linux sandbox with a real
openai/gpt-4.1scheduled job: SIGTERM while its tool was running; shutdown recordedOPENCLAW_RESTART_ABORT. Boot recovery settled withreason=cron_interrupted,nextOwner=cron; cron retried after the standard 120-second startup delay. Result: 2 attempts, 1 completion, 1 interrupted receipt, 1 successful receipt. A third boot plus 130 seconds of observation produced no duplicate. The completed one-shot had no next run. All test Gateways exited cleanly.Live proof used
077fcccbdfdeplus the reviewed patch; the conflict-free rebase is covered by PR CI onc50e0d58b9d618024c2a3c620c27543e088c4592. No production state or service was modified.Initial CI 39220863837 found two stale disabled-job expectations; both reproduced locally and were updated to the new scheduled retry contract. Manual non-replay checks remain green. Review also identified migrated receipts with
unknowndelivery state: new announce/webhook cases reproduced duplicate delivery, then passed after requiring an explicitnot-startedfact. The complete follow-up received a clean independent review.Production LOC delta: +115. This growth carries the typed restart fact through existing adapters and checks the existing receipt's delivery/configuration facts in both graceful and crash recovery. There is no new recovery owner, sidecar, or durable state format. This is a correctness fix; no performance comparison is claimed.