Repository navigation
fix(gateway): settle a lost yielded child after restart so its parent wakes - #202000
Conversation
… wakes - Startup failed a yielded child whose wake source could not survive the restart, but only in the session lifecycle; its registry run stayed held as yielded, so the parent stayed parked on a completion that could never arrive. - Settle that exact run through the existing completion owner (settleYielded, the same terminal error, normal cleanup and delivery); the session lifecycle still owns the visible failure. The parent wakes through subagent_settle.
|
🦞👀 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 maintainer review before merge. What this changesThis PR settles an unreachable yielded child’s registry run after restart so its waiting parent receives the failure and wakes. Example: The run parent-before-restart waits for restart-lost-yield, whose own continuation becomes unavailable after a Gateway restart.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep open: this PR addresses a current restart-recovery defect with a focused change through the existing completion owner; no introduced correctness or security defect was found. Priority: P1 Before mergeNone. FindingsNone. Tests
Agent review detailsHow this fits togetherGateway startup classifies persisted session waits; the subagent registry owns terminal child outcomes, cleanup, and completion delivery to waiting requesters. flowchart TD
A[Gateway startup recovery] --> B[Classify persisted yield wait]
B --> C[Record child session failure]
C --> D[Registry completion owner]
D --> E[Terminal outcome and cleanup]
E --> F[Parent completion delivery]
F --> G[Parent continuation]
Technical reviewBest possible solution: Keep the exact session failure with its lifecycle owner and settle the matching yielded registry run through the existing completion owner. Do we have a high-confidence way to reproduce the issue? Current source shows session failure without registry settlement, and the supplied regression reports the corresponding red-on-base result; no target code was executed during this read-only review. Is this the best way to solve the issue? This is the smallest complete repair: connect the existing failure path to the existing guarded completion operation without adding state, policy, or a parallel delivery path. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 99e2b6eb1f9b. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +17, Tests +55. Total +72 across 3 files. Added test files: 0. 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. 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 November 19, 2026, 2:07 PM ET / 19:07 UTC. |
…iling it (#202044) Problem: at Gateway startup, every yielded session whose wake source could not survive the restart was closed with a visible failure. A sub-agent is then settled by the registry and its requester wakes (#202000), but an ordinary root has no registry row, so its work stayed failed until a human wrote to it. Fix: resolveSessionYieldWait (the registry read owner) reports a root as waiting while a child still owes it a settlement wake, an unfinished completion, a yield or a pending/in-progress delivery; that registry completion is the root's only wake. A root still unreachable (nothing will wake it) is admitted through the ordinary restart-resume input instead of failed. Sub-agents keep the lost-source failure plus registry settlement. No ordering or handshake: the registry is shared across physical agents and hydrated before restart resume. A failed delivery is terminal and does not count as owed. Proof: source tier (ocx test): red on unchanged main for both roots (marked failed); green with one restart input across two boots, or one subagent_settle wake with no restart input. 230 tests across 19 files; tsgo, test types, oxlint, format, lifetime-check, line-cap and session-identity ratchets; clean exact-head local ClawSweeper review; ocx build --dts plus packed install smoke on the head. Real-Gateway restart proof (isolated Gateway, real model, natural SIGKILL source loss): root without owed child gets restart x1 and ends done; root with settled lost-source child gets subagent_settle x1, restart x0, ends done; unchanged main ends failed. Co-authored-by: Ayaan Zaidi <[email protected]>
|
Post-merge real-Gateway proof (isolated Gateway from source, real model, natural source loss by SIGKILL): a root spawns a child that yields on a non-durable background command, then the Gateway is killed and restarted. The child closes with |
… wakes (openclaw#202000) Problem: after a Gateway restart, startup failed a yielded child whose wake source could not survive the restart, but only in the child's session lifecycle. Its registry run stayed held as yielded, so the parent's owed completion never arrived and the parent stayed parked until a human wrote to it. Fix: after the existing lifecycle failure, the exact yielded run is settled through the existing completion owner (completeSubagentRunWithRecovery with settleYielded, the unchanged terminal error, and normal cleanup and delivery). suppressSessionEffects only prevents a duplicate visible failure on the child; the parent is still notified. The owner selects the exact runId, refuses non-yielded rows, and is a no-op without a registry entry. Proof: source tier (ocx test). New regression through the real resumeMarkedSessions startup path: red on unchanged main (child session failed, registry outcome undefined); green on the fix (one parent agent request with subagent_settle provenance, delivered-cleanup acknowledgment). 12 restart-resume and registry pause/yield/settle files; tsgo, test types, oxlint, format, lifetime-check, line-cap and session-identity ratchets; clean exact-head local ClawSweeper review; ocx build --dts plus packed install smoke on the head. Co-authored-by: Ayaan Zaidi <[email protected]>
…iling it (openclaw#202044) Problem: at Gateway startup, every yielded session whose wake source could not survive the restart was closed with a visible failure. A sub-agent is then settled by the registry and its requester wakes (openclaw#202000), but an ordinary root has no registry row, so its work stayed failed until a human wrote to it. Fix: resolveSessionYieldWait (the registry read owner) reports a root as waiting while a child still owes it a settlement wake, an unfinished completion, a yield or a pending/in-progress delivery; that registry completion is the root's only wake. A root still unreachable (nothing will wake it) is admitted through the ordinary restart-resume input instead of failed. Sub-agents keep the lost-source failure plus registry settlement. No ordering or handshake: the registry is shared across physical agents and hydrated before restart resume. A failed delivery is terminal and does not count as owed. Proof: source tier (ocx test): red on unchanged main for both roots (marked failed); green with one restart input across two boots, or one subagent_settle wake with no restart input. 230 tests across 19 files; tsgo, test types, oxlint, format, lifetime-check, line-cap and session-identity ratchets; clean exact-head local ClawSweeper review; ocx build --dts plus packed install smoke on the head. Real-Gateway restart proof (isolated Gateway, real model, natural SIGKILL source loss): root without owed child gets restart x1 and ends done; root with settled lost-source child gets subagent_settle x1, restart x0, ends done; unchanged main ends failed. Co-authored-by: Ayaan Zaidi <[email protected]>
What problem this solves
After a Gateway restart, a parent session can be parked waiting on a child (
sessions_yield). If that wait cannot survive the restart, startup fails the child:recordRestartYieldFailurewrites the visible error "The Gateway restarted, but the child completion this run was waiting for can no longer arrive…". That only failed the child's SESSION, though. Its registry run stayed held as yielded (subagent-registry-run-pause.ts), so the parent's owed completion was never delivered. The parent stayed parked on a wake that could never come.Seen on a live Gateway: a parent stayed asleep for over two hours after one restart, and again after the next, until a human wrote to it.
Change
completeSubagentRunWithRecovery, exported from the registry). It runs withsettleYielded: true, the unchanged terminal error, and normal cleanup and delivery.suppressSessionEffects: trueonly prevents a duplicate visible failure on the child session, since the lifecycle write above already owns it. It does not suppress the parent's notification.runId, refuses rows that are resumed or not yielded, and does nothing when there is no registry entry. So a root session's own run is unaffected.Follows #201970 (restart root discovery through visible spawned children).
User impact
A parent whose child's wait could not survive a restart now gets that child's failure result and wakes up, so it can re-instruct the child. Before, it stayed silent until someone wrote to it.
Evidence
Proof tier: source (
ocx test).subagent-registry.requester-wake-settlement.test-support.ts, which runs the realresumeMarkedSessionsstartup path.main: the child session isfailed, but the registry outcome staysundefined.subagent_settleprovenance, and the delivered-cleanup acknowledgment completes.pnpm tsgo,pnpm check:test-types, oxlint, format, and the lifetime-check, line-cap and session-identity ratchets: pass.Production +17 lines, test +55 lines.