Skip to content

fix: keep interrupted child results visible after restart - #202592

Merged
steipete merged 4 commits into
mainfrom
steipete/perf-micro-drain-child-result-delivery-20260919
Nov 20, 2026
Merged

steipete merged 4 commits into
mainfrom
steipete/perf-micro-drain-child-result-delivery-20260919

Conversation

@steipete

@steipete steipete commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

After a Gateway restart interrupts a subagent, its requester can consume the saved result and then yield or abort without showing it. That result can be counted as delivered and cleaned up. A failed background announcement can also leave only a generic error, without identifying the interrupted child.

Related: #202423, #202420. Overlap: #199455 proposes notice-authority changes in the same settlement owners. This patch preserves current requester targeting and fixes visible-result custody/retirement ordering; later integration of #199455 must retain the visible-before-retirement invariant. Its separate authority proposal is not required by this fix.

User Impact

Consumed child results that still owe a visible reply receive a saved-result fallback before delivery is settled. Intentionally private handoffs retain their existing consumption-only settlement. If that write fails, the result remains owed across restart. Failure notices identify the child session/run and restart interruption so the requester can start replacement work; an unconsumed failure is also available to the requester model. No configuration or schema changes are required.

Why This Change Was Made

Committed model input prevents replay, but does not establish visible delivery. The existing notice writer now serves both announce cleanup and retained requester settlement, and failure notices commit before delete cleanup can retire the last result row. Existing private-consumption eligibility, explicit no-completion requests, stopped/deleted requester behavior, and ambiguous channel-send handling remain intact.

Production code grows by 70 net lines to render the saved result and enforce write-before-retirement. The existing admission-store writer is shared rather than duplicated; no new cache, state store, or retry scheduler is introduced.

Evidence

Four synthetic owner-boundary regressions fail on base 5e6db3e87ad4d6f27a5d0cb6e6c4fed961a2118d and pass with the fix: spawn/drain/restart/resume followed by yielded settlement, unconsumed aborted announce, consumed aborted announce, and fallback-write failure followed by another restart. A separate regression proves that a failed notice append cannot retire an owed delete-cleanup row, including a mixed optional/already-delivered/owed batch.

The final private-handoff repair passed all 219 lifecycle tests and 47 requester-boundary tests. After extracting the shared settlement routine to meet the line cap, all eight focused private/restart/partition cases passed again. Earlier affected consumer proof passed 40 dispatch tests, 27 wake tests, 46 admission tests, and prompt-prefix stability. Fresh Codex autoreview is scoped-clean at P0–P2. These tests use real persistence/controller ownership and synthetic announce responses; they are not live-model/channel proof. The exact production sequence deleting both a child session and its run remains unproven from the available metadata.

Additional regressions caught and repaired during review: distinct admitted partitions now have distinct saved-result identities; restored or cancelled private-only handoffs emit no visible child result. Both behaviors have pre-fix failing tests. The visible private-parent case explicitly carries yieldedFinalDeliverable: true. The original notice writer remains in its module, with no identity-allowlist exception; the shared settlement routine is a small sibling used by both delivery owners.

Changed checks passed core/test typechecking, core lint, format, SQLite guards and import-cycle checks. The benchmark script lint is fixed and passes its focused rerun. The composite pnpm check:changed remains red for unused exports reproduced on exact base 5e6db3e8: CronSchedule introduced by #202416 (44ec89e71877e), and installSpawnThreadBindingFixture / installSpawnAttachmentFixture left without callers by #202522 (c23cb9f0cd39e). These are main regressions, not noise; no ignore/baseline exception was added. Full 35 GiB qualification is waived for this correctness/reliability fix (qualification decision). The bounded 2.26 GiB btrfs fixture (10,000 sessions, one million events, full 62,000-file workspace) is accepted as sufficient regression evidence for this PR; measured scale and costs remain disclosed below.

Bounded performance evidence (50 warm samples per arm; median / p95):

Owner operation Base wall ms Candidate wall ms Base CPU ms Candidate CPU ms Base / candidate allocation KiB (median)
Consumed result without visible reply 0.017 / 0.021 15.442 / 44.294 0.033 / 0.040 37.331 / 69.629 2.18 / 1255.61
Aborted unconsumed announce 13.914 / 16.117 13.988 / 16.147 33.466 / 38.643 33.048 / 38.630 1312.50 / 1318.70

The first operation adds one visible report where base wrote none; its extra work is the required correctness cost, not a performance improvement. A/A abort-notice wall medians were 17.752 and 16.050 ms, with noisy p95s of 134.225 and 45.258 ms. Allocation is a separate V8 sampling run for the host isolate; CPU includes process worker work. These are owner costs on the smaller local fixture, not end-to-end Gateway latency. Successful announcement behavior is unchanged and not benchmarked here.

Require visible saved-result fallback before consumed requester input can settle completion delivery. Commit failure notices with child identifiers before delete cleanup can retire the last result, and retain owed fallback work across restart.
@clawsweeper

clawsweeper Bot commented Nov 20, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation scripts Repository scripts agents Agent runtime and tooling size: L labels Nov 20, 2026
@steipete

Copy link
Copy Markdown
Contributor Author

@clawsweeper review

Please review head 101e34df35273f7b8abc1dd395aee03d1123649a, especially visible fallback before consumed-input settlement, notice-before-retirement on failed writes, and recovery without replay. Related #199455 changes the same notice/settlement owners under a different authority policy; please account for that overlap. This remains a draft pending the documented full-scale benchmark qualification.

@clawsweeper

clawsweeper Bot commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@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. labels Nov 20, 2026
@steipete

steipete commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor Author

Full 35 GiB qualification is waived for this PR: it repairs correctness/reliability—visible fallback before settlement and failure notices before delete cleanup—rather than optimizing performance. The bounded 10,000-session / 1,000,000-event btrfs fixture (2.26 GiB database, full 62,000-file workspace) is accepted as sufficient regression evidence. The larger fixture will not be built; measured costs and limitations remain disclosed.

Attribution, as expressly required by the decision-maker: this is the Team perf-loop lead’s decision, an agent acting under Peter’s standing unattended instruction, not Peter’s personal decision.

@steipete
steipete marked this pull request as ready for review November 20, 2026 16:52
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-20T17:52:04.967569Z cdd487e New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@clawsweeper

clawsweeper Bot commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR records saved child results and identifying failure notices before completion settlement can retire them.

Example: After a Gateway restart, requester run parent-17 consumes child-42's saved result and yields without answering.

  • Before: The child result can be marked delivered and retired without appearing in the requester chat.
  • After: The saved result is recorded visibly before settlement; a failed write leaves delivery owed without replaying the consumed input.

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) The patch is focused and the prior correctness finding is fixed, but synthetic boundary coverage does not satisfy the required real-behavior proof.
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: Interrupted child work can disappear from the requester chat even though its saved input was consumed.
Reason: The maintainer-authored direction repairs a concrete silent outcome while retaining intentional private handoffs.

Merge readiness

✅ Ready for maintainer review

Keep this PR open: it addresses a concrete restart-recovery defect, and the latest head resolves the prior private-handoff finding without a new confirmed code defect.

Priority: P2
Reviewed head: cdd487e87a4f269d3a43e510625452d8d3a12024

Before merge

None.

Findings

None.

Tests

  • Missing end-to-end proof: Provide redacted logs or a recording of an isolated Gateway using public sessions.create and a real model, showing restart interruption, visible fallback before retirement, and no replay of consumed input.
Agent review details

How this fits together

Subagent completion owners take saved child outcomes and requester-consumption facts, publish transcript notices when required, and settle registry delivery and cleanup.

flowchart TD
  A[Child execution ends] --> B[Saved completion record]
  B --> C[Requester consumes input]
  C --> D[Completion settlement]
  D --> E[Existing transcript notice writer]
  E --> F[Registry delivery and cleanup]
Loading

Technical review

Best possible solution:

Use the existing settlement and transcript owners to require visible fallback before retirement while preserving private custody, ambiguous sends, and no replay.

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

Current-main source exposes consumption-based success without visible fallback, and the supplied regressions report base failures; no product reproduction was run during this read-only review.

Is this the best way to solve the issue?

The approach fixes the owning settlement boundary and shares the existing notice writer without adding storage, scheduling, or competing delivery policy.

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Consumed-input settlement changes intended behavior with a stated reason (b601a4b: Committed child input must never replay or be reported lost solely because its requester turn failed; later restart handling also settled already-consumed input without resubmission.)
  • Private continuation custody keeps the original intent (6d7a56d: Private transcript consumption survives cancellation, while a visible final remains a separate obligation.)
  • Completion failure notices changes intended behavior with a stated reason (fa40e29: Required completion failures need a visible requester notice; this PR preserves that purpose and moves the append before retirement can discard its source.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

Likely related people:

  • Ayaan Zaidi: Raw commit b601a4b adds src/agents/subagents/announce/subagent-announce.requester-settle-wake.ts:20 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: b601a4b206c2; files: src/agents/subagents/announce/subagent-announce.requester-settle-wake.ts)

PR surface

Source +70, Tests +369, Docs +11, Other +206. Total +656 across 15 files. Added test files: 1.

View PR surface stats
Area Files Added Removed Net
Source 5 102 32 +70
Tests 8 449 80 +369
Docs 1 14 3 +11
Config 0 0 0 0
Generated 0 0 0 0
Other 1 206 0 +206
Total 15 771 115 +656

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 regression coverage Production +102/-32 lines; tests +449/-80 lines The growth supports visible fallback and write-before-retirement, with distinct partition, cancellation, restart, and failed-write regressions.

Labels

Label changes:

  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • remove merge-risk: 🚨 message-delivery: Current PR review selected no merge-risk labels.
  • remove status: ⏳ waiting on author: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • P2: This repairs lost visibility of delegated results during restart recovery, with limited scope and no demonstrated urgent regression.
  • 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.

History

Review history (3 earlier review cycles)
  • reviewed 2026-11-20T17:00:07.498Z sha 101e34d :: needs changes before merge. :: [P2] Remove internal agent-workflow narration from the public description
  • reviewed 2026-11-20T17:11:34.619Z sha 101e34d :: blocked before merge. :: [P2] Give saved-result fallbacks a partition-specific identity | [P2] Update the existing consumers for deferred delivery normalization
  • reviewed 2026-11-20T17:36:52.448Z sha 29f7a3a :: needs changes before merge. :: [P2] Preserve intentional private handoffs when emitting visible fallbacks

Reviewed November 20, 2026, 12:58 PM ET / 17:58 UTC (Revision 4).

@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. 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 20, 2026
@steipete

Copy link
Copy Markdown
Contributor Author

Response to the latest review's open item, checked against head e1421800455636db276c7d618cf9a8960534a3a8:

  1. Public description / qualification attribution (P2). Removed the internal landing-workflow narration from the PR body. It now gives the technical waiver, measured fixture, costs, and limitations, with a link to the qualification decision. The decision comment has also been shortened. Its remaining attribution is expressly required by the decision-maker: the Team perf-loop lead made the waiver as an agent acting under Peter's standing unattended instruction; it is not Peter's personal acceptance. This is necessary attribution for the qualification decision, not a generated-code footer or a claim of human approval, so removing it would misstate the task's authority. Please reassess this item with that explicit instruction. Qualification decision.

The source owner remains subagent-completion-admission.store.ts: consumed settlement awaits the visible report at lines 64–79, and failed requester settlement awaits notices before mutation at lines 676–703. The extracted module has been removed without changing the identity allowlist. CI's caller-contract assertions and canonical-registry fixtures have been repaired. No live-model/channel proof is claimed; the evidence uses synthetic announce I/O with real persistence and controller ownership. No Knowledge screenshots belong to this PR.

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e142180045

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +68 to +71
const settled = resolveRequesterDeliveryOutcome(entries, outcome)!;
const required = entries.filter((entry) => entry.expectsCompletionMessage === true);
if (settled !== outcome && required[0]) {
await recordRequiredCompletionNotice(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve private completion handoffs when adding visible fallbacks

For a consumed completionTarget: "parent" result, resolveRequesterDeliveryOutcome also converts intentional non-delivery into success; that conversion does not mean a visible reply was required. For example, the private-continuation cancellation exercised in subagent-registry-lifecycle-delivery.test-support.ts reaches this branch with reason: "delivery_suppressed". The new call then appends the complete child findings with display: true, exposing a private result in the requester chat despite the cancellation. This contradicts the private-input contract documented in docs/tools/subagents/announce.md. Distinguish private transcript custody from a failed visible-response obligation before emitting the fallback.

Useful? React with 👍 / 👎.

@steipete

Copy link
Copy Markdown
Contributor Author

Response to all four open items in review comment 7045528150, checked against 29f7a3ade86ee52982d822792698262c521941e4:

  1. Partition-specific saved-result identity — fixed. Result reports now include the sorted actual admitted child-run set in their identity; failure/delayed report identity is unchanged. See notice identity, lines 122–132. The owner-boundary regression at line 52 fails on e142180: both child rows become delivered, but only one visible saved-result report exists. It passes after this fix, as does the full 47-test requester-boundary suite. Repeated delivery for the same member set keeps the same identity.

  2. Consumer contracts — fixed in e142180. Wake/dispatch callers hand the raw observed failure to retained settlement; their assertions now preserve that contract and no-replay behavior. The two lifecycle cases use the canonical registry that result preparation reads, retaining their consumption and delivery assertions (fixture at line 78). All lifecycle tests, 40 dispatch tests, and 119 wake/admission/restart tests passed after that repair. The original identity-ratchet failure was also repaired by retaining the notice writer in its existing module, with no allowlist change. Fresh Codex reviews are scoped-clean at P0–P2.

  3. Qualification attribution — narrowed, with the explicit attribution retained. The body now gives only the technical waiver, measurements and limitations, linked to the shortened decision comment. The decision-maker expressly requires that comment to identify the Team perf-loop lead's decision as an agent acting under Peter's standing unattended instruction, not Peter's personal decision. This is specific authorization and attribution for a qualification waiver, not a generated-code footer. Removing it would contradict the task and risk implying personal acceptance. Please reassess this item under that explicit instruction; unrelated workflow narration has been removed.

  4. Stored-data compatibility — existing format retained and exercised. No registry record shape, codec, storage kernel, schema version, or required persisted field changes. The fix consumes the existing saved result and requester-consumption facts and writes through the existing transcript-report owner. The passing lifecycle cases cover restored consumed private completion at line 65 and legacy unbound completion at line 292, alongside persisted restart/resume and second-restart recovery. I found no changed data model supporting the claimed incompatibility. This is synthetic native-storage proof, not a claimed live-model or latest-stable upgrade run. Please identify a concrete incompatible stored shape if this item remains.

The review's Knowledge-screenshot references are unrelated: this PR supplies no screenshot evidence and makes no such claim. Exact-head CI and the latest review must complete before landing; the prior head is not final-head proof.

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@steipete

Copy link
Copy Markdown
Contributor Author

Response to both remaining items in the review of 29f7a3ad…, checked against cdd487e87a4f269d3a43e510625452d8d3a12024:

  1. Preserve intentional private handoffs — fixed. The shared settlement routine now uses the existing hasConsumedPrivateRequesterInput predicate to exclude private-only consumed members from visible fallback (settlement lines 14–17). A yielded final still qualifies because the existing predicate excludes yieldedFinalDeliverable: true. The original already-delivered cleanup shortcut is restored (cleanup line 222). Strengthened restored/cancelled-private tests fail on 29f7a3 by detecting a newly visible child result, and pass with the fix. The partition regression explicitly exercises an owed visible final. All 219 lifecycle and 47 requester-boundary tests passed; all eight focused private/restart/partition cases passed again after the mechanical extraction required by the 700-line cap. Fresh Codex review is scoped-clean at P0–P2.

  2. Original private-continuation intent — restored. I inspected 6d7a56de584adb5c2e05af229bf254c74b4dfd95 (fix: report subagent requester waiting and consumption truthfully #199695): committed private input survives cancellation, while an outstanding visible final is a separate obligation. This patch now preserves that distinction through the existing owner predicate, rather than introducing a second policy. Private custody settles without showing the saved result; a consumed result with an owed visible reply still requires the fallback to commit before settlement. The announcement documentation states both behaviors. No configuration, persisted shape, or schema change.

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Nov 20, 2026
@steipete
steipete merged commit aae5d48 into main Nov 20, 2026
136 checks passed
@steipete
steipete deleted the steipete/perf-micro-drain-child-result-delivery-20260919 branch November 20, 2026 18:05
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 21, 2026
…02592)

* fix: keep interrupted child results visible after restart

Require visible saved-result fallback before consumed requester input can settle completion delivery. Commit failure notices with child identifiers before delete cleanup can retire the last result, and retain owed fallback work across restart.

* fix(agents): align child delivery consumers with retained settlement

* fix(agents): distinguish saved results from separate completion partitions

* fix(agents): preserve consumed private completion handoffs
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 P2 Normal backlog priority with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. scripts Repository scripts size: L 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