Repository navigation
fix(subagents): show child delivery notices as child results, not failed replies - #204089
Conversation
- Write child delivery failure/expiry notices as subagent-completion, excluded from model context - Skip the notice for killed children with no captured result, per batch member - Replace 'retry or resend your request' child-delivery copy Co-authored-by: obviyus <[email protected]>
Co-authored-by: obviyus <[email protected]>
|
🦞👀 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 changes before merge. What this changesThis PR renders child-delivery failures as neutral child-result rows and suppresses notices for intentionally killed children without captured output. Example: A completion batch contains the child labeled Release notes and an intentionally killed child with no output.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness⛔ Needs changes before merge - 1 item remains Keep open: this maintainer-authored PR addresses a concrete, still-present mismatch between child-delivery outcomes and failed-reply presentation. Priority: P2 Before merge
Findings
Tests
Agent review detailsHow this fits togetherThe subagent completion owner receives terminal delivery outcomes and captured child results, then appends visible notices to the requester transcript for Control UI rendering. flowchart TD
A[Terminal child outcomes] --> B[Completion notice owner]
B --> C[Filter empty intentional stops]
C --> D[Format public saved results]
D --> E[Requester transcript]
E --> F[Control UI child result row]
Technical reviewBest possible solution: Keep the existing notice owner and neutral row type, while making recovery copy truthful when saved output is absent or private. Do we have a high-confidence way to reproduce the issue? Current-main source selects the failed-reply custom type for these notices, and the supplied production screenshots show the resulting badge; no target code was executed during this read-only review. Is this the best way to solve the issue? Changing presentation at the existing notice producer is the smallest complete approach, and the per-member filter preserves live siblings without adding another delivery owner. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 59ae4e0f760f. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceAcceptance criteria:
What I checked:
PR surfaceSource +10, Tests +50. Total +60 across 8 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 23, 2026, 9:16 AM ET / 14:16 UTC. |
Co-authored-by: obviyus <[email protected]>
Co-authored-by: obviyus <[email protected]>
Co-authored-by: obviyus <[email protected]>
Co-authored-by: obviyus <[email protected]>
|
After (head 7422135, same real-sweeper journey as the before screenshots in the PR body): the ok child's expiry notice is a neutral System row with no red badge and no Report a bug. The killed child (no captured result) writes no row; only one notice exists in the conversation. |
|
Landed as d66eeff. Bug: child delivery failure/expiry notices were written as |
…203176) ## Problem A requester that calls `sessions_yield` after spawning several completion-mode subagents was woken only when every member of the frozen yield batch was ready. A sibling that keeps running, or that pauses on its own `sessions_yield` while a background command runs, held every finished result back. Production incident (2026-11-21): a dashboard parent spawned 3 children and yielded at 16:20 IST. Two children finished at 16:26:58 and 16:29:41 with reports that needed a decision. The third kept cycling through exec-yield and resume. The Gateway log has no `announce:requester-settle:…` run for that parent. The parent ran again only at 18:32, when the user typed into the chat. A copy of the state database shows why: both finished rows were `terminal`/`ok` with `delivery.status: pending` and a pending `requesterSettleWake` (`batchRunIds` = all 3, `rearmGeneration: 1`). The third row was still `running`. The gate in `subagent-announce.requester-settle-wake.ts` returned `false` unless every frozen member passed `isRequesterSettleMemberReady`. #200967 had already made an exception for siblings that wait for a message. An exec-yielded or running sibling is the same bug class. ## Change Rule: every ready result wakes the yielded parent. Siblings that are still working keep their wake, with the same `rearmGeneration`, and wake the parent again when they finish. Each result is delivered once. - **Settle wake:** removed the all-or-nothing gate and the message-wait exception (`isEndedSubagentMessageWait` is deleted). The wake delivers the ready members of the frozen batch as one partition, and lists the members that are still working. A member whose partition has already started dispatch records its own batch, so a later partition never offers it again. When a partition holds only results that were already delivered and siblings are still pending, it settles without a redundant wake. - **Wake message:** a partition that leaves members pending no longer says "every subagent has settled… do not call sessions_yield again". It names the siblings that are still working (label, task name or run ID, at most 5, each truncated) and tells the parent: if the request needs those results, call `sessions_yield` to wait; otherwise act on the ready results without reporting the batch as finished. - **Lifecycle failure path:** `offeredBatch` now offers only ready members, so failure settlement can never consume the wake of a sibling that is still running or exec-yielded. - **Yield transfer:** when a child ended before the yield and a sibling is still running, `afterRelease` now schedules the settle for the finished child. Before, nothing woke the parent until the sibling ended. - **Followup owners** (`sessions_send` wait-for-reply, `agent-step`, nested `agent-run-subagent`): the caller is waiting for a single reply. Only the partition that leaves no member pending continues the followup. Earlier partitions wake the session as ordinary settle turns. `successor()` accepts that last partition as a subset of its cohort, so it no longer throws and records the result as a permanent failure. - **Automation authority:** a yield that carried cron-management authority keeps it for the partition that leaves no member pending. Earlier partitions run without borrowing it, and settling them shrinks the retained cohort instead of discarding the authority. - **Silent waits:** while siblings are still working, the parent may stay silent (`NO_REPLY`) and wait. Such a turn is not treated as a missing visible reply, so it is not retried. - **Goal return:** an earlier partition leaves the Goal cohort when it settles. The partition that settles the cohort last resumes the Goal once. - `isRequesterSettleMemberReady` moved to `subagent-run-liveness.ts`, its only owner, and replaces the deleted message-wait predicate. - Docs: `tools/subagents/announce.md` and `concepts/subagent-yield-handoff.md`. Product decisions, under the rules "no stranded user" and "no false done": - A stopped child is a settled outcome, so its report now wakes the parent right away instead of waiting for its siblings. - A followup caller gets one reply, after all results are in. The session itself is still woken for each result. ## Evidence **Regression test** (`subagent-registry.requester-wake.e2e.test.ts`, real registry, lifecycle, yield tool and wake entry point): spawn 2 children, yield, finish one, keep the other exec-yielded. The parent is woken with the finished result, and the wake names the working sibling. The sibling's continuation then wakes the parent again with only its own result. A sweep adds no third wake. A second case covers a child that ended before the yield, while the requester's turn held it. - Base `eb7ca3d33375`: both cases red (`expected [] to have a length of 1`: no wake). - Head: both cases green. **Owner tests:** cron authority (`requester-cron-authority.test.ts`: the early partition neither borrows nor consumes the authority, and the last partition is admitted with it), followup partition (`subagent-announce.requester-settle-followup.test.ts`: early partition runs with no followup successor, last partition carries it). Goal partition (`goal-continuation.test.ts`: early partition does not resume the Goal, last partition resumes it once). **Updated tests that asserted the all-at-once rule:** `requester-settle-cross-turn` (paused member), `subagent-control.worker` progress card (one wake per result; the card retires once), `requester-wake-settlement` (stopped child). **Real-Gateway E2E**, incident shape. Scratch `ocx src` Gateway under `env -i`, OpenAI `gpt-5.5` on the OpenClaw runtime. Parent spawns `alpha` (replies at once) and `beta` (`exec` with `background: true` running `sleep 90`, then `sessions_yield`), then yields. | | alpha ended | first parent wake | beta yielded | beta ended | second parent wake | |---|---|---|---|---|---| | base | 19:47:10 | **19:48:53** (one combined run, after beta) | 19:47:13 | 19:48:50 | none | | head | 19:40:08 | **19:40:11** (`announce:requester-settle:…:<alpha>:yield-1`) | 19:40:12 | 19:41:55 | 19:41:59 (`…:<beta>:yield-1`) | The parent's replies on head were `alpha: ALPHA-RESULT-7`, then `alpha: ALPHA-RESULT-7 / beta: BETA-RESULT-9`. The live Peanutto launchd pid and `openclaw.json` hash did not change. **Live sibling suites** (`subagent-yield-pause`, `subagent-followup-yield`, `subagent-yield-resume`, real OpenAI `gpt-5.5`): the same tests fail on base `eb7ca3d33375` and on this branch, with the same assertions (missing `completion.resultText` after a resumed or paused child completes, a Gateway shutdown timeout, an interim reply in the follow-up watch case; follow-up-yield failed 2 of 2 on base). One run of this branch showed a parent that wrote its final report as soon as the first result arrived; the wake message now says to keep waiting when the request needs the remaining results, and that failure no longer appears. The real-Gateway restart e2e files (`test/gateway-*-restart*.e2e.test.ts`) fail locally on base too (11 of 26 on base, 9 of 26 here, same assertions). **Gates:** `pnpm tsgo:core`, `pnpm check:test-types`, oxlint and oxfmt on the changed files. Every test file in `src/agents/subagents` and `goal-continuation.test.ts` was run across the unit-fast, infra, agents-support, spawn-boundary, core-isolated and e2e projects. Two infra tests failed once under host load and passed when run alone, on head and on base. ## Size Production code is +96 / −56. The gate, the message-wait exception and its predicate are deleted. The added lines are the partition support the old gate did not need: pending members in the message, the followup last-partition rule, Goal cohort shrink, and pre-yield scheduling, and cron-authority cohort shrink. A census of `batchRunIds`, `requesterYieldBatch`, the frozen branch and `selectConnectedSettledSubagentWave` found every remaining reader still in use. v8 coverage could not attribute lines under the compiled-worker test runner (0 files collected in two attempts), so the census was done by reading the code. ## Accepted edge cases - If a Goal cohort's last partition is rejected for an unrelated reason (for example, a rearm-generation mismatch), the Goal return stays retained until Stop or a lifecycle rotation. That is the same outcome as a failed final delivery today. - A nested requester whose early partition answers without yielding reports that answer to its parent. The later result wakes it again as a separate completion. ## Merge danger - **Two-way door.** No schema, stored-row or config change: the wake rows keep their existing fields and generation. A revert restores the all-at-once wake for every cohort, including rows written while this change ran. - **Blast radius:** requesters that yield on two or more completion children (dashboard, chat and nested subagent requesters). A defect here would show as an extra or a missing wake for the parent, not as a lost child result: every result stays saved in its child session. Co-authored-by: Ayaan Zaidi <[email protected]> (cherry picked from commit 09d956b) Release adaptation: Kept stable QA Gateway fixture lifecycle; filtered intentionally silent partial-result wakes. Companion audit: #203222 selected. #204249, #204069, #204048, #203892, #202513, #198960 not applicable (refactors/test cleanup); #204260, #204178, #204098, #204089, #203839, #203271 missing in lane and not prerequisites. Co-authored-by: RomneyDa <[email protected]>
…led replies (openclaw#204089) ## Problem When a child (subagent) result could not be handed to its parent turn, `recordRequiredCompletionNotice` wrote the notice as customType `run-failed-before-reply`. The Control UI renders that type as a failed reply: a red "Couldn't finish this reply" badge with "Report a bug". This happened even when no reply was running and the child ended days earlier. Seen in production. Child deliveries suspended by the old store-path veto (removed in openclaw#200760) stayed suspended. They expired after the 7-day retention, and the expiry sweep put red failed-reply badges under unrelated later turns. One notice was for a child that had been **killed** on purpose and had no captured result. The badge showed a raw session key, a run id, the word `killed`, and the text "…then retry or resend your request", but there was no request to retry. openclaw#200760 fixed the root cause of the suspension. This PR fixes how the remaining failure, expiry and idle-expiry notices are shown. ## Solution All changes are in the notice owner, `recordRequiredCompletionNotice`, and its copy: - **Killed or cancelled child with no captured result → no notice.** The function filters each batch member: `endedReason === "subagent-killed"`, not a steer restart, and no captured result text. Live siblings in the same batch still get their notice. A killed child that holds a captured result still shows it. There are no per-caller checks. - **Child-delivery notices use `customType: "subagent-completion"`**, the child-result row kind the function already writes for `kind === "result"`. No UI reader treats this type as a run error, so the red badge and "Report a bug" go away. No new customType. Old stored rows render as before. - **Model context: unchanged.** The design planned `excludeFromContext: true` for all notices. That rested on `packages/agent-core/.../session.ts` excluding every `run-failed-before-reply` row. That is one reader only. The SQLite model-context projection and `cli-runner/session-history.ts` read only `excludeFromContext`. So an unconsumed failure notice did reach the parent model, as `docs/tools/subagents/announce.md` documents ("available to the requester model if it never consumed the original result"). The existing conditional stays as it was: the notice enters model context only while a batch member's result is unconsumed (local review finding, round 3). - **Copy:** "<child label> finished on <date> UTC, but its result couldn't be added to this conversation automatically. Details are below." The heading makes no "saved result is below" claim, because a private `completionTarget=parent` handoff or an uncaptured child has only identity and status. Each child section starts with its session key and run id, then the label and status. The heading label is bounded to 200 characters, so a long label cannot push the ids out of the 512-character header or the 32,000-character limit (local review findings, rounds 1-3). - **Yielded requester** (a requester that ended its turn waiting on the child): stays a run error, because no reply was made. Its copy (`child_completion_delivery_failed`) now reads "This reply was waiting for a child agent whose result couldn't be added to this conversation automatically. Check the child session for its outcome." It no longer says "retry or resend your request". Accepted edge cases (no code for them): - A yielded batch now writes a run-error row and a separate child row. - A retry across the upgrade can duplicate one legacy row, because dedupe is scoped per customType. ## Impact - Child-delivery failure, expiry and idle-expiry notices show as neutral rows, not as failed replies. - An intentional kill writes no notice. - No schema, stored-row, protocol or dependency change. ## Evidence - New unit test `subagent-registry.store-replaced.test.ts` › "records a child-result notice for live children and none for a killed child": - Base `3baee0bb1290`: **red**. It writes the incident row, `run-failed-before-reply`, "…retry or resend your request", `Child agent:main:subagent:killed … killed`. - Head: green. - Updated the existing tests that pinned `run-failed-before-reply` for child-delivery notices. The gateway and e2e assertions that check for *no* failed reply stay as they are. - `ocx test` on touched tests and every test that imports a changed source or test-support file (29 files). oxfmt and oxlint pass. `pnpm check:changed` passes except the dead export scan, which flags `scripts/lib/docker-e2e-watchdog.mjs: parseTimeoutMs`. That file is not in this diff. - Not ours: - `subagent-registry-worker.test.ts` › "releases serialized payloads…" (GC retention) fails on base `3baee0bb1290` too. - `subagent-registry-lifecycle.test.ts` failed on different tests in two loaded runs. It passed alone on head and on base. - Real-product E2E: isolated scratch Gateway from source, real agent turns on Claude through the Control UI. The agent spawned two children; state was edited so one child was killed with no result and both deliveries were suspended for more than 7 days. Then the real sweeper ran `discardExpiredSubagentDelivery`. - Before (base): both children show the red "Couldn't finish this reply" + "Report a bug", the killed one included. - After (head): the ok child shows a neutral System row with its result and no badge. The killed child writes no row. Co-authored-by: Ayaan Zaidi <[email protected]>
…led replies (#204089) When a child (subagent) result could not be handed to its parent turn, `recordRequiredCompletionNotice` wrote the notice as customType `run-failed-before-reply`. The Control UI renders that type as a failed reply: a red "Couldn't finish this reply" badge with "Report a bug". This happened even when no reply was running and the child ended days earlier. Seen in production. Child deliveries suspended by the old store-path veto (removed in #200760) stayed suspended. They expired after the 7-day retention, and the expiry sweep put red failed-reply badges under unrelated later turns. One notice was for a child that had been **killed** on purpose and had no captured result. The badge showed a raw session key, a run id, the word `killed`, and the text "…then retry or resend your request", but there was no request to retry. All changes are in the notice owner, `recordRequiredCompletionNotice`, and its copy: - **Killed or cancelled child with no captured result → no notice.** The function filters each batch member: `endedReason === "subagent-killed"`, not a steer restart, and no captured result text. Live siblings in the same batch still get their notice. A killed child that holds a captured result still shows it. There are no per-caller checks. - **Child-delivery notices use `customType: "subagent-completion"`**, the child-result row kind the function already writes for `kind === "result"`. No UI reader treats this type as a run error, so the red badge and "Report a bug" go away. No new customType. Old stored rows render as before. - **Model context: unchanged.** The design planned `excludeFromContext: true` for all notices. That rested on `packages/agent-core/.../session.ts` excluding every `run-failed-before-reply` row. That is one reader only. The SQLite model-context projection and `cli-runner/session-history.ts` read only `excludeFromContext`. So an unconsumed failure notice did reach the parent model, as `docs/tools/subagents/announce.md` documents ("available to the requester model if it never consumed the original result"). The existing conditional stays as it was: the notice enters model context only while a batch member's result is unconsumed (local review finding, round 3). - **Copy:** "<child label> finished on <date> UTC, but its result couldn't be added to this conversation automatically. Details are below." The heading makes no "saved result is below" claim, because a private `completionTarget=parent` handoff or an uncaptured child has only identity and status. Each child section starts with its session key and run id, then the label and status. The heading label is bounded to 200 characters, so a long label cannot push the ids out of the 512-character header or the 32,000-character limit (local review findings, rounds 1-3). - **Yielded requester** (a requester that ended its turn waiting on the child): stays a run error, because no reply was made. Its copy (`child_completion_delivery_failed`) now reads "This reply was waiting for a child agent whose result couldn't be added to this conversation automatically. Check the child session for its outcome." It no longer says "retry or resend your request". Accepted edge cases (no code for them): - A yielded batch now writes a run-error row and a separate child row. - A retry across the upgrade can duplicate one legacy row, because dedupe is scoped per customType. - Child-delivery failure, expiry and idle-expiry notices show as neutral rows, not as failed replies. - An intentional kill writes no notice. - No schema, stored-row, protocol or dependency change. - New unit test `subagent-registry.store-replaced.test.ts` › "records a child-result notice for live children and none for a killed child": - Base `f595f0237a35`: **red**. It writes the incident row, `run-failed-before-reply`, "…retry or resend your request", `Child agent:main:subagent:killed … killed`. - Head: green. - Updated the existing tests that pinned `run-failed-before-reply` for child-delivery notices. The gateway and e2e assertions that check for *no* failed reply stay as they are. - `ocx test` on touched tests and every test that imports a changed source or test-support file (29 files). oxfmt and oxlint pass. `pnpm check:changed` passes except the dead export scan, which flags `scripts/lib/docker-e2e-watchdog.mjs: parseTimeoutMs`. That file is not in this diff. - Not ours: - `subagent-registry-worker.test.ts` › "releases serialized payloads…" (GC retention) fails on base `f595f0237a35` too. - `subagent-registry-lifecycle.test.ts` failed on different tests in two loaded runs. It passed alone on head and on base. - Real-product E2E: isolated scratch Gateway from source, real agent turns on Claude through the Control UI. The agent spawned two children; state was edited so one child was killed with no result and both deliveries were suspended for more than 7 days. Then the real sweeper ran `discardExpiredSubagentDelivery`. - Before (base): both children show the red "Couldn't finish this reply" + "Report a bug", the killed one included. - After (head): the ok child shows a neutral System row with its result and no badge. The killed child writes no row. Co-authored-by: Ayaan Zaidi <[email protected]> (cherry picked from commit d66eeff) Release adaptation: port the child notice assertion into the stable split wake fixture without changing cohort tests. #204748 is a focused fixture clock companion; #204178 and #204260 are later history redesigns, and other audit matches address separate features or fixtures. Co-authored-by: RomneyDa <[email protected]>


Problem
When a child (subagent) result could not be handed to its parent turn,
recordRequiredCompletionNoticewrote the notice as customTyperun-failed-before-reply. The Control UI renders that type as a failed reply: a red "Couldn't finish this reply" badge with "Report a bug". This happened even when no reply was running and the child ended days earlier.Seen in production. Child deliveries suspended by the old store-path veto (removed in #200760) stayed suspended. They expired after the 7-day retention, and the expiry sweep put red failed-reply badges under unrelated later turns. One notice was for a child that had been killed on purpose and had no captured result. The badge showed a raw session key, a run id, the word
killed, and the text "…then retry or resend your request", but there was no request to retry.#200760 fixed the root cause of the suspension. This PR fixes how the remaining failure, expiry and idle-expiry notices are shown.
Solution
All changes are in the notice owner,
recordRequiredCompletionNotice, and its copy:endedReason === "subagent-killed", not a steer restart, and no captured result text. Live siblings in the same batch still get their notice. A killed child that holds a captured result still shows it. There are no per-caller checks.customType: "subagent-completion", the child-result row kind the function already writes forkind === "result". No UI reader treats this type as a run error, so the red badge and "Report a bug" go away. No new customType. Old stored rows render as before.excludeFromContext: truefor all notices. That rested onpackages/agent-core/.../session.tsexcluding everyrun-failed-before-replyrow. That is one reader only. The SQLite model-context projection andcli-runner/session-history.tsread onlyexcludeFromContext. So an unconsumed failure notice did reach the parent model, asdocs/tools/subagents/announce.mddocuments ("available to the requester model if it never consumed the original result"). The existing conditional stays as it was: the notice enters model context only while a batch member's result is unconsumed (local review finding, round 3).completionTarget=parenthandoff or an uncaptured child has only identity and status. Each child section starts with its session key and run id, then the label and status. The heading label is bounded to 200 characters, so a long label cannot push the ids out of the 512-character header or the 32,000-character limit (local review findings, rounds 1-3).child_completion_delivery_failed) now reads "This reply was waiting for a child agent whose result couldn't be added to this conversation automatically. Check the child session for its outcome." It no longer says "retry or resend your request".Accepted edge cases (no code for them):
Impact
Evidence
subagent-registry.store-replaced.test.ts› "records a child-result notice for live children and none for a killed child":f595f0237a35: red. It writes the incident row,run-failed-before-reply, "…retry or resend your request",Child agent:main:subagent:killed … killed.run-failed-before-replyfor child-delivery notices. The gateway and e2e assertions that check for no failed reply stay as they are.ocx teston touched tests and every test that imports a changed source or test-support file (29 files). oxfmt and oxlint pass.pnpm check:changedpasses except the dead export scan, which flagsscripts/lib/docker-e2e-watchdog.mjs: parseTimeoutMs. That file is not in this diff.subagent-registry-worker.test.ts› "releases serialized payloads…" (GC retention) fails on basef595f0237a35too.subagent-registry-lifecycle.test.tsfailed on different tests in two loaded runs. It passed alone on head and on base.discardExpiredSubagentDelivery.