Skip to content

fix(gateway): settle a lost yielded child after restart so its parent wakes - #202000

Merged
obviyus merged 1 commit into
mainfrom
fix/restart-lost-yield-settle
Nov 19, 2026
Merged

obviyus merged 1 commit into
mainfrom
fix/restart-lost-yield-settle

Conversation

@obviyus

@obviyus obviyus commented Nov 19, 2026

Copy link
Copy Markdown
Collaborator

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: recordRestartYieldFailure writes 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

  • After the existing lifecycle failure, settle that exact yielded run through the existing completion owner (completeSubagentRunWithRecovery, exported from the registry). It runs with settleYielded: true, the unchanged terminal error, and normal cleanup and delivery.
  • suppressSessionEffects: true only 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.
  • The completion owner already selects the exact 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).

  • New regression in subagent-registry.requester-wake-settlement.test-support.ts, which runs the real resumeMarkedSessions startup path.
    • On unchanged main: the child session is failed, but the registry outcome stays undefined.
    • With the fix: the registry records the terminal error, the parent receives exactly one agent request with subagent_settle provenance, and the delivered-cleanup acknowledgment completes.
  • 12 restart-resume and registry pause/yield/settle files pass. An earlier 36-file scope also passed.
  • 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.

… 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.
@clawsweeper

clawsweeper Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime agents Agent runtime and tooling size: S labels Nov 19, 2026
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Nov 19, 2026
@clawsweeper

clawsweeper Bot commented Nov 19, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This 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.

  • Before: Startup fails the child session, but its registry run remains yielded and the parent stays parked.
  • After: Startup also records the child’s terminal registry outcome and delivers its completion to the parent.

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) Focused, source-supported repair with a meaningful regression and no identified patch defect, but the required shipped-entry-point behavior remains unproven.
Proof confidence 🧂 unranked krab (1/6) Real behavior proof is not required for maintainer- or bot-authored pull requests.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: After restart, a parent can wait indefinitely for a child whose session has already failed.
Reason: Restores the documented lost-source failure contract and parent progress using existing owners; collaborator authorship establishes direction.

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
Reviewed head: 7e9f8baaffa20a53038b9303f8200f4cbb9cd511

Before merge

None.

Findings

None.

Tests

  • Missing end-to-end proof: Supply redacted post-fix Gateway logs or terminal output showing a real restart with an unreachable yielded child, its recorded failure, and its parent continuing without a manual message.
Agent review details

How this fits together

Gateway 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]
Loading

Technical review

Best 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

  • Unreachable yielded-session failure keeps the original intent (bbf0d73: Preserve reachable waits across restart and visibly terminate waits whose continuation source is unavailable.)
  • Registry completion coordination keeps the original intent (4cd327e: Separate registry machinery while preserving completion, persistence, and cleanup ownership.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit 4cd327e adds src/agents/subagent-registry.ts:128 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 4cd327e31fe2; files: src/agents/subagent-registry.ts)
  • Ayaan Zaidi: Raw commit cf21361 adds src/agents/subagents/registry/subagent-registry.ts:24 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: cf213616b987; files: src/agents/subagents/registry/subagent-registry.ts)

PR surface

Source +17, Tests +55. Total +72 across 3 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 2 17 0 +17
Tests 1 55 0 +55
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 3 72 0 +72

Preflight source

Source unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified.

Labels

Label changes:

  • add P1: The reported live restart failure leaves an active parent workflow silently parked for hours until a human sends another message.
  • add rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Label justifications:

  • P1: The reported live restart failure leaves an active parent workflow silently parked for hours until a human sends another message.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Rating scale

6/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.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

Reviewed November 19, 2026, 2:07 PM ET / 19:07 UTC.

@obviyus
obviyus merged commit 70f100d into main Nov 19, 2026
144 checks passed
@obviyus
obviyus deleted the fix/restart-lost-yield-settle branch November 19, 2026 19:12
obviyus added a commit that referenced this pull request Nov 19, 2026
…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]>
@obviyus

obviyus commented Nov 19, 2026

Copy link
Copy Markdown
Collaborator Author

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 yield-source-unavailable, its registry run is settled, and the root receives subagent_settle ×1 with no restart input, ending done. Full table on #202044.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 20, 2026
… 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]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 20, 2026
…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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling gateway Gateway runtime P1 High-priority user-facing bug, regression, or broken workflow. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: S status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant