Repository navigation
fix(agents): recover parent before restoring child completions - #178694
Conversation
Reconcile startup-orphaned requesters through the existing recovery owner before restoring child mailbox reservations. This prevents unfinished child output preparation from holding FIFO positions ahead of the interrupted parent, while preserving durable completion custody and order. Add a regression with eight restored children that verifies first-attempt parent execution and retained FIFO child reservations. Focused recovery, requester-settle, direct-announcement, and loopback Gateway tests pass.
|
🦞👀 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. |
|
Codex review: needs maintainer review before merge. What this changesThis PR marks interrupted parents for recovery before restoring child completion mailbox reservations. Example: A Gateway restarts with an interrupted parent and eight pending child completions.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep open: this PR addresses a source-supported startup recovery delay that remains on main; no actionable patch defects were found, and exact-head CI is still pending. Priority: P2 Before mergeNone. FindingsNone. Tests
Agent review detailsHow this fits togetherGateway startup restores durable subagent obligations into session controller mailboxes; the recovery owner must recognize interrupted parent work before child follow-ups reserve FIFO positions. flowchart TD
A[Gateway startup] --> B[Restore subagent obligations]
B --> C[Load requester session]
C --> D[Existing orphan recovery owner]
D --> E[Resume interrupted parent]
E --> F[Restore ordered child completions]
Technical reviewBest possible solution: Use the existing orphan recovery owner before either restored child reservation path, preserving durable obligations and their established ordering. Do we have a high-confidence way to reproduce the issue? Current source exposes the unmarked-orphan ordering gap, and the PR supplies a focused regression plus a reported live restart comparison; no target code was executed during this read-only review. Is this the best way to solve the issue? The patch is a focused extension of the existing recovery-before-completion contract, with no competing scheduler, new state owner, or unnecessary test scaffolding. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against ce97c81929f1. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +38, Tests +99. Total +137 across 3 files. Added test files: 0. 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 20, 2026, 3:19 PM ET / 19:19 UTC. |
…law#178694) Reconcile startup-orphaned requesters through the existing recovery owner before restoring child mailbox reservations. This prevents unfinished child output preparation from holding FIFO positions ahead of the interrupted parent, while preserving durable completion custody and order. Add a regression with eight restored children that verifies first-attempt parent execution and retained FIFO child reservations. Focused recovery, requester-settle, direct-announcement, and loopback Gateway tests pass.
What Problem This Solves
After a Gateway restart, an interrupted main-session turn (for example a fleet parent killed mid-turn) resumed 60–126 s after startup.
docs/gateway/restart-recovery.mdpromises "a few seconds". Meanwhile every child completion bounced off the parent every 15 s withSESSION_WORK_START_CHANGED.The cause was FIFO blockage:
subagent-announce-controller-source.tsonly recognized already-marked recovery.User Impact
Interrupted parent turns resume promptly after a Gateway restart while child completion reservations remain in FIFO order behind them. No configuration changes or migration are required.
Why This Change Was Made
Child restoration now invokes the existing recovery owner for the parent first, with commit-time ownership validation, before restoring child reservations. It adds no timer, queue or recovery state. The parent's interrupted turn runs on the first attempt, and all child reservations are retained in FIFO order behind it.
Evidence
main-session-restart-recovery-priority.test.ts"unmarked startup orphan": red on base (8 child inputs dispatched ahead of the parent) and green with the fix (first-attempt parent execution, 8 child reservations retained in order). Focused suites pass: main-session recovery marking, priority, admission and recovery (194),subagent-parent-recovery.restart-integration, requester-settle dispatch and restart, direct delivery, and theserver.startup-recovery-*loopback Gateway tests (330 tests).kill -9while a fleet parent was still in its first turn:SESSION_WORK_START_CHANGEDbounces.