Repository navigation
fix(agents): resume interrupted tasks after gateway restarts - #138394
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 real behavior proof before merge. Reviewed September 4, 2026, 7:00 PM ET / 23:00 UTC. ClawSweeper reviewWhat this changesRestores interrupted delegated work after Gateway restarts, atomically reactivates its task and mirrored flow, sends a resumption notice, and prevents predecessor events from overwriting successor status. Merge readiness⛔ Blocked before merge - 9 items remain Keep open: the underlying task-state defect remains on inspected main and v2026.9.1, and the related merged PRs do not supersede this repair. The owner-level repair has substantial supporting evidence, but three introduced defects remain, including the previously raised final-delivery fence. Priority: P1 Review scores
Verification
How this fits togetherThe subagent registry tracks delegated child runs and recovers unfinished work when the Gateway restarts. Recovery updates operator-visible task and flow status, resumes execution, and sends notices through the shared outbound delivery queue. flowchart TD
A[Gateway restart or follow-up] --> B[Saved child run and session]
B --> C{Current recovery owner?}
C -->|Yes| D[Commit successor, task and flow]
C -->|No| H[Reject stale work]
D --> E[Resume child execution]
D --> F[Queue recovery notice]
F --> G[Recipient and delivery receipt]
Before merge
Findings
Agent review detailsSecurityNeeds attention: New recovery notices can outlive their owner's authority at external I/O; no unrelated dependency, permission or supply-chain change was found. PR surfaceSource +556, Tests +1468, Other +1. Total +2025 across 44 files. View PR surface stats
Review metrics
Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Keep recovery in the existing registry, with atomic task/flow publication, final-send authority, valid bounded receipts, and terminating run-scoped cleanup; the previously missing crash-orphan and cross-record commit contracts justify production growth. Do we have a high-confidence way to reproduce the issue? Yes, there is a high-confidence source path: accepted successor replacement on inspected main updates backing detail without rearming the failed task, and the supplied real-registry/SQLite regressions exercise that mismatch; this review did not execute them. Is this the best way to solve the issue? No, not yet: atomic replacement is the correct owner boundary, but notification delivery and rejected-follow-up cleanup violate existing downstream contracts. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 6c63f6710637. LabelsLabel changes:
Label justifications:
EvidenceSecurity concerns:
What I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (5 earlier review cycles)
|
fbf72ad to
15117d0
Compare
|
Updated head
Fresh local gates on this head: 270 owner/recovery tests, 7 completed-session reactivation tests, full
|
15117d0 to
ac2228d
Compare
|
Exact head
Fresh local gates on this head: 320 owner/recovery tests, full Final landing receipts:
|
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
ac2228d to
429b9e4
Compare
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
429b9e4 to
a17e7f4
Compare
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
a17e7f4 to
098e06c
Compare
098e06c to
a7df9c6
Compare
|
Merged via squash.
|
…#138785) Follow up on #138394: route successor activity through the canonical task identity, reject stale predecessor activity, stop cleanup after Gateway retirement, and fence notice settlement after awaited delivery. Simplify atomic publication and document hard-kill recovery. The acceptance-receipt persistence cut point is tracked separately in #138783.
…openclaw#138785) Follow up on openclaw#138394: route successor activity through the canonical task identity, reject stale predecessor activity, stop cleanup after Gateway retirement, and fence notice settlement after awaited delivery. Simplify atomic publication and document hard-kill recovery. The acceptance-receipt persistence cut point is tracked separately in openclaw#138783.
What Problem This Solves
After a hard Gateway process restart, an interrupted delegated task could remain abandoned until an operator manually prompted the session. A hard kill cannot write the normal abort marker, so recovery skipped a session still recorded as running. When recovery did create a successor, the subagent owner and canonical task were persisted separately; a failure between those writes could leave the successor active while the task and its mirrored TaskFlow stayed failed.
Fixes #137991.
Why This Change Was Made
The material persistence design was explicitly accepted in issue #137991. This adds no schema, migration, configuration, scheduler, controller, retention, security-policy, or protocol surface.
Direct dependency inspection used Codex
8e6a44b428e31f91b21edc97904fcdf4f0931ade:thread/resumeandturn/startremain distinct app-server requests (codex-rs/app-server-protocol/src/protocol/common.rs:524-535,982-986), while running-thread resume attaches the connection and reports active-turn state (codex-rs/app-server/src/request_processors/thread_lifecycle.rs:568-703). The repair therefore stays in OpenClaw's recovery/orchestration owners; it does not add or change a Codex protocol.Production/tooling delta: +1,028/-426 (net +602). Test/support delta: +1,835/-264 (net +1,571). The production growth is the automatic hard-kill recovery capability, the atomic cross-owner commit boundary, and the requester confirmation path; the previous split writer and obsolete task-detail mutation path are removed.
User Impact
Interrupted managed subagent work now resumes automatically after a Gateway restart without a manual prompt. The original conversation receives a resumption confirmation after recovery has actually dispatched and adopted the successor. That confirmation is distinct from the later task-completion reply.
Failed persistence cannot publish half of the ownership transfer, late predecessor terminal events cannot overwrite a live successor, and a second restart does not duplicate the recovered turn or its external tool effects.
Evidence
Regression: red on the split writer
The injected canonical task activation failure still returned replacement success, persisted the successor, and left the task/TaskFlow terminal.
Green
Autoreview findings resolved before publication include failed confirmation delivery blocking settlement, legacy task identity across chained recovery, incoherent observer publication, undurable accepted-run ownership, and the completed-session replacement race. The final P1 regression proves a losing accepted run is terminated while an already-canonical successor remains live.
Isolated hard-restart proof
Ephemeral Gateway + QA channel + mock provider verdict:
{ "status": "pass", "originalGeneration": 1, "recoveredGeneration": 2, "restoredStatus": "succeeded", "recoveryRequests": 1, "operatorPromptRequired": false, "resumptionConfirmations": 1, "completionReplies": 1, "toolCallsBeforeRestart": { "exec": 1, "wait": 1 }, "toolCallsAfterRestart": { "exec": 1, "wait": 1 } }The proof passed on exact head
a7df9c6b06f134250123febce2457caeb183c957. It hard-kills the first Gateway, verifies automatic successor adoption with the same requester/child session identities, waits for the resumption confirmation before releasing provider completion, restarts the Gateway again, observes a full recovery sweep, and verifies no duplicate recovery request, reply, or tool call.Related merged owners inspected: #136780, #137606, and #137851.