Skip to content

fix(gateway): resume a root whose yield source was lost instead of failing it - #202044

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

obviyus merged 1 commit into
mainfrom
fix/restart-root-lost-source

Conversation

@obviyus

@obviyus obviyus commented Nov 19, 2026

Copy link
Copy Markdown
Collaborator

What problem this solves

At Gateway startup, a session parked in sessions_yield whose wake source could not survive the restart was always closed with a visible failure (recordRestartYieldFailure). For a sub-agent that is correct: since #202000, the registry also settles it and its requester wakes. For an ordinary root session, nothing settles: completeSubagentRunWithRecovery returns at once when there is no registry row. So the root's work just failed and stayed failed until a human wrote to it. The restart contract says an interrupted root gets one ordinary input to inspect current state and continue.

Seen live: a root failed at startup and was only rescued by an unrelated child-settlement turn nine seconds later.

Change

  • resolveSessionYieldWait (the registry read owner, subagent-registry-read.ts): at the root branch, when no waiting child resolves but a child still owes this requester a completion, it returns waiting. "Owes" means a pending settle wake, or an owed completion that is not yet terminal, is still yielded, or has a delivery pending or in progress. That registry completion is then the root's only wake.
  • session-restart-resume.ts: a root that is still unreachable (nothing will ever wake it) is admitted through the ordinary restart-resume input instead of being failed. Sub-agents keep the lost-source failure plus registry settlement (fix(gateway): settle a lost yielded child after restart so its parent wakes #202000).
  • No ordering, fence or handshake. The registry is one shared map across physical agents, so a child in another agent's store counts. Startup awaits registry hydration before restart resume (server-startup-observers.ts:63, then :74).
  • A failed delivery does not count as owed: it is terminal (subagent-registry-lifecycle-finalize-cleanup.ts:234-244), so counting it would park the root forever.
  • docs/gateway/restart-recovery.md: corrected the lost-source row and paragraph.

Follows #201970 and #202000.

User impact

After a restart, a root session waiting on work that cannot continue resumes on its own to inspect and reconcile, or wakes on its child's settlement. It is not left failed until someone writes to it.

Evidence

Proof tier: source (ocx test).

  • New regressions through the real resumeMarkedSessions startup path. On unchanged main, both roots are marked failed. With the fix:
    • a root with no owed child gets exactly one restart input, across two boots, and is not failed;
    • a root whose lost-source child is settled is woken once by subagent_settle, with no restart input and no failed status.
  • 19 files, 230 tests: restart-resume, registry read/yield and requester-wake settlement. Four orphan-matrix expectations that required yielded roots to fail were updated to one normal resume.
  • pnpm tsgo, pnpm check:test-types, oxlint, format, and the lifetime-check, line-cap and session-identity ratchets: pass.
  • Unrelated: subagent-registry-worker.test.ts "releases serialized payloads while their immutable registry rows remain resident" also fails on clean main (d9e2d8a).

Production +24 −5 lines, tests +47 −17, docs +4 −2.

…iling it

- Startup failed every yielded session whose wake source could not survive the
  restart. For a root that ended its work: nothing could wake it, so it needed a
  new human message.
- The registry read owner now reports a root as waiting while a child still owes
  it a settlement or delivery (that completion is its only wake); a root with
  nothing owed gets the ordinary restart input to inspect and reconcile.
- Sub-agents keep the lost-source failure plus registry settlement (#202000).
@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 docs Improvements or additions to documentation 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

Resume yielded root sessions after restart when no child completion remains capable of waking them.

Example: agent:main:dashboard:parked-root restarts after its awaited child registry entry disappears.

  • Before: Startup records a failure and the root needs another user message.
  • After: Startup admits one ordinary restart input so the root can inspect saved work and continue.

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) The focused patch has no identified defect and useful boundary regressions, but required real behavior proof remains absent.
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: A yielded root whose wake source disappears can fail at startup and stop progressing until another message arrives.
Reason: Restores automatic root reconciliation under the documented restart contract; collaborator authorship establishes the direction.

Merge readiness

✅ Ready for maintainer review

Keep open: this maintainer-authored PR addresses a current root-recovery defect, and no introduced correctness or security defect was found.

Priority: P1
Reviewed head: 0ace52091cf849928ae42cb88401668c77466e00

Before merge

None.

Findings

None.

Tests

  • Missing end-to-end proof: Provide redacted post-fix output from an isolated Gateway with a real agent and model showing a lost-source root continuing once, and an owed-child root waking through settlement without an extra restart turn.
Agent review details

How this fits together

Gateway startup classifies persisted session waits using the subagent registry, then preserves a reachable wait, settles an unreachable child, or admits ordinary root recovery.

flowchart TD
  A[Gateway startup] --> B[Registry wait classification]
  B --> C[Child completion still owed]
  C --> D[Registry wakes requester]
  B --> E[Root has no remaining wake]
  E --> F[Authority checked restart input]
  B --> G[Unreachable child settlement]
Loading

Technical review

Best possible solution:

Keep registry completion as the wake owner while an obligation remains, otherwise resume the eligible root through ordinary restart admission.

Do we have a high-confidence way to reproduce the issue?

Current-main source establishes the unreachable-root failure path, and the supplied regressions report the matching base failure; no target code was executed during this read-only review.

Is this the best way to solve the issue?

The patch is a small, complete repair using existing classification, completion, and admission owners, with distinct regressions for direct recovery and child-settlement wake ownership.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against d5f3e4d7b75a.

Provenance checked

  • Unavailable yield-source handling changes intended behavior with a stated reason (bbf0d73: Preserve reachable waits and visibly terminate waits whose external continuation source is unavailable.)
  • Chat-scoped child completion lookup keeps the original intent (5d35af1: Use agent and session key as the stable chat owner across follow-up runs and session changes.)
  • Retired completion-authority precedence keeps the original intent (272e2da: Resume parents when restored children cannot continue under retired completion authority.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit bbf0d73 adds src/agents/subagents/registry/subagent-registry-read.ts:201 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: bbf0d7380315; files: src/agents/subagents/registry/subagent-registry-read.ts)

PR surface

Source +19, Tests +30, Docs +2. Total +51 across 6 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 2 24 5 +19
Tests 3 47 17 +30
Docs 1 4 2 +2
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 6 75 24 +51

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: A reported live restart leaves an active root workflow failed until another input arrives.
  • 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: A reported live restart leaves an active root workflow failed until another input arrives.
  • 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.

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Supply the isolated Gateway evidence described in the testing review.

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, 3:26 PM ET / 20:26 UTC.

@obviyus

obviyus commented Nov 19, 2026

Copy link
Copy Markdown
Collaborator Author

Real-Gateway restart proof (isolated Gateway from source, real model, natural source loss by SIGKILL; no state injection).

A root yields in sessions_yield on a non-durable background command, then the Gateway is killed and restarted.

Case Root inputs after restart Final status Startup summary
This PR, (a) no child owes a completion restart ×1 done resumed: 1
This PR, (b) a child yielded on a lost source subagent_settle ×1, restart ×0 done root parked; child yield-source-unavailable
Unchanged main, same checkpoint and config as (a) no recovery input; visible "child completion … can no longer arrive" notice failed yield-source-unavailable

Case (a) ran with background-process exit notices disabled after the crash, on both sides, so the comparison differs only in code.

Known, pre-existing, not changed here: with exit notices on, an interrupted root also receives the background process's lost-exit notice, so it replies twice. A non-yielded interrupted root on unchanged main does the same. Follow-up: the exit-notice enqueue in src/agents/bash-tools.exec-notify.ts (reached from bash-process-durable.ts) should not add a second wake when the root already receives the restart input.

@obviyus
obviyus merged commit 4eb3541 into main Nov 19, 2026
142 checks passed
@obviyus
obviyus deleted the fix/restart-root-lost-source branch November 19, 2026 20:33
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 docs Improvements or additions to documentation 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