Repository navigation
fix(subagents): complete nested fleets after Gateway restarts - #177652
Conversation
Normalize requester origins before hashing and persistence so recovered worker completions match their committed envelopes. Reconcile existing raw receipts only against their complete historical hash, preserving strict payload and authority checks. Cover a committed worker replay through cold reload, sub-lead settlement, and the top-parent handoff. Document the replay identity guarantee.
Release the replaced run’s unclaimed controller inputs after its successor is durably published. A restored cohort reservation otherwise retains the old batch identity and blocks the adopted sub-lead’s completion from waking its parent until another Gateway restart. Preserve claimed inputs, completed-source obligations, same-ID FIFO ordering, and existing completion authority. Extend cold-reload nested replay coverage through real mailbox admission; the regression fails on c200a67 and passes with this fix. Focused registry, announce, and session-accessor suites pass.
…ions Reapply committed native annotations through the original producer before comparing replayed completion input. Preserve exact payload checks and reject changed requester facts without adding stored fields.
Check the exact restored requester-settle batch before marking a sub-lead interrupted. Keep the existing live-owner and commit guards for actual orphan recovery, and prove a hard-killed continuation never enters that mutation path.
Merge origin/main to resolve the transcript annotation conflict. Preserve main's exact-session-key lookup and the shared annotation producer used by completion replay.
|
🦞👀 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 repairs completion replay and recovery ordering so nested subagent fleets can finish after a Gateway restart. Example: An owner starts two sub-leads with four workers each, then the Gateway is killed after the workers commit.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep this PR: it repairs source-confirmed nested restart failures through existing owners, and no actionable introduced defect was found. Priority: P1 Before mergeNone. FindingsNone. Tests
Agent review detailsHow this fits togetherThe subagent registry coordinates retained child results, requester continuations, and session mailbox admission; recovery consumes persisted execution facts and produces bounded continuation or interruption outcomes. flowchart TD
A[Persisted subagent registry] --> B[Restart recovery]
B --> C[Incoming settle custody]
C --> D[Requester mailbox]
D --> E[Pending input replay]
F[Committed transcript annotation] --> E
E --> G[Requester continuation]
G --> H[Parent completion]
Technical reviewBest possible solution: Retain this focused repair using the existing replay, annotation, replacement, and recovery owners. Do we have a high-confidence way to reproduce the issue? Source shows the hash mismatch, annotated-transcript comparison, retained reservation, and premature orphan mutation paths; the body reports matching live failures, but this read-only review ran no target code. Is this the best way to solve the issue? The smallest complete fix is to stabilize captured identity, reconcile exact historical receipts and annotations, retire replaced reservations, and check existing continuation custody before orphan mutation. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against de3b3ce82714. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +139, Tests +525, Docs +4. Total +668 across 14 files. Added test files: 3. View PR surface stats
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 19, 2026, 3:44 PM ET / 19:44 UTC. |
…aw#177652) * fix(agents): preserve nested completion replay after restart Normalize requester origins before hashing and persistence so recovered worker completions match their committed envelopes. Reconcile existing raw receipts only against their complete historical hash, preserving strict payload and authority checks. Cover a committed worker replay through cold reload, sub-lead settlement, and the top-parent handoff. Document the replay identity guarantee. * fix(agents): retire remapped requester wake reservations Release the replaced run’s unclaimed controller inputs after its successor is durably published. A restored cohort reservation otherwise retains the old batch identity and blocks the adopted sub-lead’s completion from waking its parent until another Gateway restart. Preserve claimed inputs, completed-source obligations, same-ID FIFO ordering, and existing completion authority. Extend cold-reload nested replay coverage through real mailbox admission; the regression fails on c200a67 and passes with this fix. Focused registry, announce, and session-accessor suites pass. * fix(sessions): reconcile completion replay with native prompt annotations Reapply committed native annotations through the original producer before comparing replayed completion input. Preserve exact payload checks and reject changed requester facts without adding stored fields. * fix(agents): honor incoming settle custody before orphan recovery Check the exact restored requester-settle batch before marking a sub-lead interrupted. Keep the existing live-owner and commit guards for actual orphan recovery, and prove a hard-killed continuation never enters that mutation path.
What Problem This Solves
#176861 made flat owner-started sub-agent fleets survive a Gateway restart, but nested fleets (top parent → sub-leads → workers) still stalled after a restart: the workers finished, the sub-leads finished their integration branches, and the top parent was never woken. A later restart sometimes unstuck it. Reproduced live (Linux, real OpenAI and Anthropic keys, shared-token owner via
openclaw agent):kill -9after all workers committed, restart, then nothing for 15+ minutes. Four defects were involved:src/agents/requester-origin.ts) emitted explicitundefinedfields. JSON persistence dropped them,stableStringifykept them, so every post-restart replay of an already-committed worker completion failedInput completion retry conflicts with the committed input, and the sub-lead received four bogus "Subagent completion delivery is blocked" notices.completion_handoff_pending). The next boot cleared it, which is why another restart "fixed" it.mirrorIdentity,mirrorOrigin: "codex-app-server",mirrorSourceFingerprint), so the whole-payload comparison against the original completion could never match.subagent orphan ownership changed before interruption commitand leaving the sub-leadexecution=runningforever.User Impact
Nested sub-agent fleets now resume and complete after a Gateway restart, including Codex app-server parents. No migration or user action is required.
Why This Change Was Made
docs/tools/subagents/operations.mddocuments the replay identity guarantee.Evidence
kill -9after all workers committed, one restart, no further restarts. Both fleets merged into main within ~2 minutes (35/35 tests each), zeroconflicts with the committed input, zerofailed to reconcile interrupted. On main the Codex route never completes without a second restart and the embedded route receives spurious "delivery is blocked" notices.Release note context
Fix: nested sub-agent fleets (sub-agents that spawn their own sub-agents) now resume and complete after a Gateway restart, including Codex app-server parents.
Landing validation
Merged current main at
b413bdc277einto the reviewed branch, resolving only the annotation-owner conflict. Main's exact-session-key authority lookup and the shared validated annotation producer are both preserved. Onfa631ad2d63, all 266 tests across pending-input mirror/origin replay, user-turn transcript/media/persistence, harness annotation, registry restart recovery, and completion authority pass. Changed-file formatting, lint, targeted annotation typed lint, andgit diff --checkpass. The live proof above is the coordinator's pre-landing proof; it was not repeated for this mechanical conflict resolution.