Skip to content

fix: deliver a saved child answer after a Gateway crash - #207706

Merged
daniel-lxs merged 8 commits into
mainfrom
openclaw/child-answer-lost-on-restart-48768e
Nov 28, 2026
Merged

daniel-lxs merged 8 commits into
mainfrom
openclaw/child-answer-lost-on-restart-48768e

Conversation

@roboclaw-bot

@roboclaw-bot roboclaw-bot commented Nov 28, 2026 •

Copy link
Copy Markdown
Collaborator

Related: #206422 (the crash-without-an-answer case).

What Problem This Solves

A waiting parent can lose an answer its child saved just before a Gateway crash. If the child's transcript stays unreadable, the parent can instead wait indefinitely.

User Impact

The parent receives the confirmed answer once, or an interruption notice if the Gateway still cannot read the answer after one local retry. The child is not rerun. Ordinary steering, explicit session deletion, graceful shutdown and timeout precedence keep their existing behavior. No configuration change or migration is required.

Why This Change Was Made

I kept the interruption behavior from #206437 and #207549 when there is no confirmed final. A saved answer needs the original run ID, the producer's terminal marker and a successful stop. Recovery records whether it found that final rather than guessing from a missing end time. This also leaves live shutdown free to honor an already accepted Stop.

Only crash recovery records that later cleanup must leave the inspected visible transcript alone. The decision survives another restart. This preserves the readable answer and avoids reopening a damaged child database to delete it while the healthy parent's wake is queued. An explicit cleanup: "delete" still applies to the child session.

I left the shared deletion operation and steer replacement code identical to main. #151936 retained post-replacement transcript cleanup; #167966 required a verified predecessor before retiring it. That history concerns a distinct, explicitly recorded target, not a policy to erase default visible spawns.

Evidence

I verified that published head 285bb91df68f has tree 527db66ff6d9, identical to the tested tree. In the three-way CrabBox AWS comparison, a read-only SQLite connection checked both the session row and the exact answer after the real replacement operation finished:

After ordinary steer Main 1bf58762 Previous head 6b5d9be8 This head
Explicit visible predecessor target: session and its answer Deleted Both retained Deleted
No explicit target: original visible session and its answer Retained Retained Retained
Explicit hidden predecessor target Deleted Deleted Deleted
Successor's copy and unrelated conversation's answer One each One each One each

The explicit-target cases seeded a recorded target. Separately, a real public visible spawn and follow-up on each revision showed what the default does: it recorded no target, replaced the paused run, preserved the visible conversation and wrote the successor's final.

On the same fixed tree I killed the real Gateway after the child saved its final and before registry completion. The readable case delivered the answer once and retained the child final; the persistently unreadable case delivered one interruption. Both produced a direct parent acknowledgment with zero history-only fallbacks. A second restart added no delivery or model call. The Gateway and Codex app-server were real; model responses were scripted.

The regression failed on the previous head because the retired session still existed. On the exact published tree, 42 selected tests passed, as did formatting, lint and both core and touched-test typechecks. The new tests write answers through an awaited SessionManager. Deferred cleanup runs against a terminal record reloaded from SQLite and checks the actual session and transcript. Relative to the merge base: production +116/-18 lines; tests +272/-27. The shared remover adds no new policy. Both AWS leases for the steer comparison were released.

Earlier proof, not counted as final-head runs: the SIGTERM process comparison checked at handler return and caught a pending Stop that an exit-only check missed. Both live-shutdown owner controls passed again on this head. Earlier runs cover direct crash delivery, cleanup checks and the corrected preview counter, an intermediate shutdown run whose wrapper exited 1, nine crash comparisons, bounded reads, and a crash before any final. I did not run the full suite or use live model inference.

Worked on by: @daniel-lxs

Work sessions

Linked for team reference; these sessions aren’t public.

Worked on by

🦞 Made with OpenClaw

roboclaw-bot and others added 2 commits November 28, 2026 19:39
Recover a confirmed final from the original child run before treating an orphaned registry row as interrupted. Keep normal parent delivery, the recorded reply time, and the existing interruption notice when no final was saved.

Co-authored-by: daniel-lxs <[email protected]>
Worked on by:
- @daniel-lxs

Co-authored-by: daniel-lxs <[email protected]>
OpenClaw-Publication: 8765fc69-70a9-4cf5-ba52-608b5c68ac71
@clawsweeper

clawsweeper Bot commented Nov 28, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

ClawSweeper review in progress

ClawSweeper is reviewing this revision. This supersedes any previous blocked status.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation agents Agent runtime and tooling size: S labels Nov 28, 2026
@clawsweeper clawsweeper Bot added P1 High-priority user-facing bug, regression, or broken workflow. impact:message-loss Channel message delivery can be lost, duplicated, or misrouted. clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. labels Nov 28, 2026
@roboclaw-bot
roboclaw-bot marked this pull request as ready for review November 28, 2026 20:00
@roboclaw-bot

Copy link
Copy Markdown
Collaborator Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 28, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. 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. labels Nov 28, 2026
@clawsweeper

clawsweeper Bot commented Nov 28, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: passed.

What this changes

Recover producer-confirmed child answers after a Gateway crash and preserve inspected visible transcripts during deferred cleanup.

Example: Run completed saves “saved child answer” immediately before the Gateway crashes.

  • Before: Restart reports an interruption despite the saved final answer.
  • After: Restart delivers the saved answer through normal parent completion without rerunning the child.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused repair with distinct regression coverage and reported production-entry-point proof; exact-head CI remains in progress.
Proof confidence 🐚 platinum hermit (4/6) ✨ media proof bonus Sufficient (linked_artifact): The self-contained PR report covers real Gateway crashes on the published tree, confirmed-answer delivery, unreadable-transcript interruption, ordinary steering, shutdown controls, and no duplicate delivery after another restart; inference was scripted and the linked artifacts could not be independently opened here.
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 waiting parent can lose a child answer already saved before a Gateway crash.
Reason: Recovering confirmed saved work avoids misleading failure reports and unnecessary task repetition; the maintainer-authored direction is already established.

Merge readiness

✅ Ready for maintainer review

This PR addresses a current saved-answer loss path through the existing completion owner; no blocking correctness or security defects were found.

Reviewed head: 285bb91df68f8f1fa68dd8c4f150c2eff597f3f4

Before merge

None.

Findings

None.

Agent review details

How this fits together

The subagent registry restores child runs, reads their recorded transcripts, and sends terminal outcomes through the existing parent-delivery and cleanup owners.

flowchart TD
  A[Restored child run] --> B[Registry sweeper]
  B --> C[Original run transcript]
  C --> D[Terminal completion owner]
  D --> E[Parent delivery]
  D --> F[Deferred cleanup]
Loading

Technical review

Best possible solution:

Recover confirmed local finals through the existing terminal owner while retaining interruption fallback, cancellation precedence, and restart-specific transcript preservation.

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

Current-main source establishes that a crash between saving the child's final and registry completion produces an interruption instead of recovering that answer; this read-only review ran no reproduction.

Is this the best way to solve the issue?

The patch repairs the existing recovery path with producer evidence and a bounded read retry, without introducing a second execution or delivery owner.

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Crash interruption settlement changes intended behavior with a stated reason (3cce42d: Settle children abandoned by a crashed Gateway so requesters do not wait indefinitely.)
  • Fresh requester custody keeps the original intent (f444d3b: Deliver each child outcome under its requester's retained turn identity and fresh restart admission.)
  • Complete transcript answer rendering keeps the original intent (792b48a: Read the complete original-run answer rather than returning only the bounded lifecycle preview.)
  • Terminal transition ownership keeps the original intent (42f33ba: Centralize terminal row decisions and owed cleanup effects while adapters retain publication and dispatch.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

Likely related people:

  • Vincent Koc: Raw commit 3cce42d adds src/agents/subagents/registry/subagent-registry-sweep-settle.ts:148 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 3cce42d18562; files: src/agents/subagents/registry/subagent-registry-sweep-settle.ts)
  • Peter Steinberger: Raw commit f444d3b adds src/agents/subagents/registry/subagent-registry-sweep-settle.ts:153 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: f444d3b18c23; files: src/agents/subagents/registry/subagent-registry-sweep-settle.ts)
  • Jason (Json): Raw commit 792b48a adds src/agents/subagents/announce/subagent-announce-result.ts:90 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: medium; commits: 792b48a34a69; files: src/agents/subagents/announce/subagent-announce-result.ts)

PR surface

Source +56, Tests +287, Docs +7. Total +350 across 13 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 6 74 18 +56
Tests 6 314 27 +287
Docs 1 14 7 +7
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 13 402 52 +350

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.

Review metrics

Metric Value Why it matters
Production versus test changes Production +74/-18; tests and test support +314/-27 The additional coverage protects distinct crash evidence, unreadable storage, accepted cancellation, persisted cleanup, steering, and shutdown boundaries.

Labels

Label changes:

  • add proof: sufficient: Contributor real behavior proof is sufficient.

Label justifications:

  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • proof: sufficient: Contributor real behavior proof is sufficient.

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.

History

Review history (3 earlier review cycles)
  • reviewed 2026-11-28T20:05:47.390Z sha f6c2d8e :: passed. :: none
  • reviewed 2026-11-28T20:52:33.372Z sha b2df5ae :: passed. :: none
  • reviewed 2026-11-28T22:01:32.609Z sha 6b5d9be :: passed. :: [P3] Seed the new transcript fixture through SessionManager

Reviewed November 28, 2026, 5:53 PM ET / 22:53 UTC (Revision 4).

roboclaw-bot and others added 2 commits November 28, 2026 20:29
Retry the local evidence read once, not the whole sweep. If the read still fails, settle the original run through its existing interruption and delivery path instead of leaving the parent waiting.

Co-authored-by: daniel-lxs <[email protected]>
Worked on by:
- @daniel-lxs

Co-authored-by: daniel-lxs <[email protected]>
OpenClaw-Publication: e738913b-3c51-436c-b7f8-888355c38c4c
@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime size: M and removed size: S labels Nov 28, 2026
@roboclaw-bot

Copy link
Copy Markdown
Collaborator Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 28, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added the proof: sufficient ClawSweeper judged the real behavior proof convincing. label Nov 28, 2026
roboclaw-bot and others added 2 commits November 28, 2026 21:37
Distinguish the unconfirmed crash fallback from live shutdown instead of inferring it from an untimed error. Keep child transcript retention with the child-session owner: hidden-effects cleanup must not open a visible session target for hard deletion during requester delivery.

Co-authored-by: daniel-lxs <[email protected]>
Worked on by:
- @daniel-lxs

Co-authored-by: daniel-lxs <[email protected]>
OpenClaw-Publication: 80bda22f-ca7e-42b4-aa53-250cbc95fd59
@roboclaw-bot

Copy link
Copy Markdown
Collaborator Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 28, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀

Re-review progress:

@clawsweeper clawsweeper Bot removed the proof: sufficient ClawSweeper judged the real behavior proof convincing. label Nov 28, 2026
roboclaw-bot and others added 2 commits November 28, 2026 22:33
Keep the verified replacement cleanup path and its removal primitive unchanged from main. Record the visible-transcript preservation decision only when a crash completion is committed, so deferred terminal cleanup can respect it after another restart. Exercise both session metadata and answer retention using SessionManager.

Co-authored-by: daniel-lxs <[email protected]>
Worked on by:
- @daniel-lxs

Co-authored-by: daniel-lxs <[email protected]>
OpenClaw-Publication: d2361948-5a64-4256-bf5a-440963ea98d1
@roboclaw-bot

Copy link
Copy Markdown
Collaborator Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 28, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀

Re-review progress:

@clawsweeper clawsweeper Bot added the proof: sufficient ClawSweeper judged the real behavior proof convincing. label Nov 28, 2026
@daniel-lxs
daniel-lxs merged commit b7967b2 into main Nov 28, 2026
131 checks passed
@daniel-lxs
daniel-lxs deleted the openclaw/child-answer-lost-on-restart-48768e branch November 28, 2026 23:06
vincentkoc added a commit that referenced this pull request Nov 29, 2026
…or baseline

* commit '2f2edbf36836a8ddc6758dfdcce872d4414a3a92': (520 commits)
  chore(doctor): hold expired doctor migrations as removal-pending (#207865)
  fix: show ended one-time automations in History (#201280)
  chore(release): update appcast for 2026.11.11 (#207504)
  fix: let updates back up deeply nested databases (#207756)
  fix(telegram): stop resending earlier messages to the model on every turn in DM topics (#207684)
  feat(workboard): choose which sessions appear on a board (#207781)
  fix: acknowledge updates when the Gateway first becomes ready (#207819)
  chore: stop the cron recovery test from failing CI on slow runners (#207837)
  fix: queue follow-ups when session creation reuses an active chat (#207800)
  feat(clawrouter): consume qualified native memory embeddings (#191874)
  fix: save the account for main-session prompts and converted reminders (#207776)
  test(infra): measure worker Buffer storage directly (#207663)
  feat(workboard): hide sessions and filter subagents per board (#207744)
  chore(i18n): refresh native locales (#207796)
  fix: name safe recovery when agent schema markers disagree (#207705)
  improve(ui): show only setup warnings on skill pages (#203750)
  fix(gateway): keep Linux legacy lock recovery explicit (#207340)
  fix: deliver a saved child answer after a Gateway crash (#207706)
  fix(ui): fold background command wakes into chat activity (#207305)
  fix: restore the Feishu proxy transport tests (#207782)
  ...
vincentkoc added a commit that referenced this pull request Nov 29, 2026
…aseline

* commit '2f2edbf36836a8ddc6758dfdcce872d4414a3a92': (520 commits)
  chore(doctor): hold expired doctor migrations as removal-pending (#207865)
  fix: show ended one-time automations in History (#201280)
  chore(release): update appcast for 2026.11.11 (#207504)
  fix: let updates back up deeply nested databases (#207756)
  fix(telegram): stop resending earlier messages to the model on every turn in DM topics (#207684)
  feat(workboard): choose which sessions appear on a board (#207781)
  fix: acknowledge updates when the Gateway first becomes ready (#207819)
  chore: stop the cron recovery test from failing CI on slow runners (#207837)
  fix: queue follow-ups when session creation reuses an active chat (#207800)
  feat(clawrouter): consume qualified native memory embeddings (#191874)
  fix: save the account for main-session prompts and converted reminders (#207776)
  test(infra): measure worker Buffer storage directly (#207663)
  feat(workboard): hide sessions and filter subagents per board (#207744)
  chore(i18n): refresh native locales (#207796)
  fix: name safe recovery when agent schema markers disagree (#207705)
  improve(ui): show only setup warnings on skill pages (#203750)
  fix(gateway): keep Linux legacy lock recovery explicit (#207340)
  fix: deliver a saved child answer after a Gateway crash (#207706)
  fix(ui): fold background command wakes into chat activity (#207305)
  fix: restore the Feishu proxy transport tests (#207782)
  ...
vincentkoc added a commit that referenced this pull request Nov 29, 2026
…aseline

* commit '2f2edbf36836a8ddc6758dfdcce872d4414a3a92': (520 commits)
  chore(doctor): hold expired doctor migrations as removal-pending (#207865)
  fix: show ended one-time automations in History (#201280)
  chore(release): update appcast for 2026.11.11 (#207504)
  fix: let updates back up deeply nested databases (#207756)
  fix(telegram): stop resending earlier messages to the model on every turn in DM topics (#207684)
  feat(workboard): choose which sessions appear on a board (#207781)
  fix: acknowledge updates when the Gateway first becomes ready (#207819)
  chore: stop the cron recovery test from failing CI on slow runners (#207837)
  fix: queue follow-ups when session creation reuses an active chat (#207800)
  feat(clawrouter): consume qualified native memory embeddings (#191874)
  fix: save the account for main-session prompts and converted reminders (#207776)
  test(infra): measure worker Buffer storage directly (#207663)
  feat(workboard): hide sessions and filter subagents per board (#207744)
  chore(i18n): refresh native locales (#207796)
  fix: name safe recovery when agent schema markers disagree (#207705)
  improve(ui): show only setup warnings on skill pages (#203750)
  fix(gateway): keep Linux legacy lock recovery explicit (#207340)
  fix: deliver a saved child answer after a Gateway crash (#207706)
  fix(ui): fold background command wakes into chat activity (#207305)
  fix: restore the Feishu proxy transport tests (#207782)
  ...
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 29, 2026
)

Recover a worker-confirmed final answer from the original child transcript after a Gateway crash. Use the existing requester delivery path and send the interruption notice if the local transcript stays unreadable after one retry. Preserve a visible transcript during restart recovery while keeping ordinary steer and shutdown behavior.

Co-authored-by: daniel-lxs <[email protected]>
OpenClaw-Publication: 8765fc69-70a9-4cf5-ba52-608b5c68ac71
OpenClaw-Publication: e738913b-3c51-436c-b7f8-888355c38c4c
OpenClaw-Publication: 80bda22f-ca7e-42b4-aa53-250cbc95fd59
OpenClaw-Publication: d2361948-5a64-4256-bf5a-440963ea98d1
tideclaw-bot pushed a commit that referenced this pull request Nov 30, 2026
Preserve the existing requester restart reason in announce classification so unconsumed completed results remain pending for startup custody. Existing consumption receipts prevent replay; permanent refusals, explicit cancellation, and ambiguous sends retain their policies.

(cherry picked from commit b8b06c4)

Follow-ups: fca5133 fix: preserve child completion inputs across Gateway restarts (#208367) [not selected for this narrow backport]; b7967b2 fix: deliver a saved child answer after a Gateway crash (#207706) [not selected for this narrow backport]; 17e2ec9 fix: tell the user when a finished subagent's report can't start in their chat (#207194) [not selected for this narrow backport]; 811f999 refactor(subagents): centralize completion delivery decisions (#206383) [not selected for this narrow backport]; 50a6774 fix: retain channel requester when child completion resumes parent [separately ordered lane row]; d2699a8 chore: carry and enforce participant limits on admitted runs (#204847) [not selected for this narrow backport]; 57dd84b fix(agents): settle every undelivered child completion into history; drop delivery dispositions (#204260) [separately ordered lane row]; cded11f fix(agents): deliver a child's end state as parent history, not a turn obligation (#204178) [not selected for this narrow backport]; 92e92d7 fix: preserve restarted child results and gateway test ownership (#203839) [not selected for this narrow backport]; 09d956b fix(subagents): wake a yielded requester for each ready child result (#203176) [not selected for this narrow backport]; 9f35510 fix: retain child results behind live requester turns (#203198) [separately ordered lane row]; c23cd7f fix: preserve private child results during restart (#203156) [separately ordered lane row]

Release adaptation: Keep stable requester fixture setup and insert the two consumed/unconsumed restart cases without moving its existing lost-yield test.

Co-authored-by: RomneyDa <[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 impact:message-loss Channel message delivery can be lost, duplicated, or misrouted. P1 High-priority user-facing bug, regression, or broken workflow. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: M 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.

2 participants