Repository navigation
fix(agents): deliver a child's end state as parent history, not a turn obligation - #204178
Conversation
…n obligation - Append the child's status once to the requester transcript (model-visible, not displayed) when its steer or wake did not consume the result, then settle delivered. - A consumed completion turn is delivered whatever it replied; remove visible-reply and message-tool enforcement and the failed_notice channel send. - Remove suspended delivery, the 7-day and 30-minute expiries, backlog warnings, failure/delayed/result notices, the settle-wake retry ladder and the child_completion_delivery_failed lifecycle error; a yielded requester whose wake never ran ends as an ordinary run. - Settle legacy suspended rows once on the next sweep. 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. |
…vers - Share one 32,000-character budget across a cohort's status entry (8,000 per child at most). - Skip children already delivered so a batch settle never repeats their status. - Remove the deleted authority-notice test from the worker test list and the perf script that measured the removed notice settlement. Co-authored-by: obviyus <[email protected]>
- Count truncation notes and separators against the status budget so a cohort entry stays within 32,000 characters. - Drop discardTerminalDelivery and the removed block/expiry steps from bench and perf scripts; remove the restart-delivery expiry harness. - Legacy suspended rows stay maintenance-protected regardless of timestamp until the sweeper settles them. Co-authored-by: obviyus <[email protected]>
- sessions_history caps each text block at 4,000 characters; a truncated status now tells the parent to ask the child with sessions_send. Co-authored-by: obviyus <[email protected]>
|
Rejected review findings: none rejected; every local review finding was fixed. Two review rounds were used, so the last fix lands on targeted tests instead of a third full round.
|
…chet - Reword the give-up settlement refusal and shrink the session identity allowlist for the removed pins. Co-authored-by: obviyus <[email protected]>
|
Maintainer override: the only red job fails in a test this PR does not touch or import, and it fails on main too. |
|
Maintainer override: both red jobs fail in tests this PR does not touch or import.
|
|
Codex review: blocked before merge. What this changesThis PR records otherwise undelivered child outcomes in parent model history and removes delivery retries and visible failure notices. Example: Child A returns ALPHA while its parent's wake fails, then Child B returns BRAVO.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness⛔ Blocked before merge - 3 items remain Keep open: this maintainer-authored PR addresses a concrete delivery problem, but its quiet-settlement shortcut also bypasses required-result checks for non-child completions. Priority: P2 Before merge
Findings
Provenance
Tests
Agent review detailsHow this fits togetherThe subagent registry tracks completed children, announcement code attempts requester delivery, and the completion store persists fallback history before settling delivery. flowchart TD
A[Child terminal outcome] --> B[Subagent registry]
B --> C[Requester steer or wake]
C --> D[Consumed parent input]
C --> E[Unconsumed outcome]
E --> F[Hidden parent transcript entry]
D --> G[Delivery settled]
F --> G
Technical reviewBest possible solution: Keep child fallback settlement in the existing transcript owner while preserving non-child required-result checks. Do we have a high-confidence way to reproduce the issue? The inspected before/after Gateway screenshots and current-main fallback source establish the reported behavior; this read-only review executed no target code. Is this the best way to solve the issue? History-first child settlement is a coherent simplification, but its success shortcut must remain scoped to child completion sources. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against e2973f933f10. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceAcceptance criteria:
What I checked:
PR surfaceSource -716, Tests -2627, Docs -49, Other -457. Total -3849 across 75 files. Added test files: 1. 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, 2:00 PM ET / 19:00 UTC. |
- Requester-wake e2e supports, retry-grace e2e, completion replay, yielded settle and subagent list now expect delivered settlement and the model-visible status entry; cases for removed retries, fallbacks and suspension are deleted. Co-authored-by: obviyus <[email protected]>
- Delete cleanup removes the child session, so the truncation note only points at sessions_send for kept children. Co-authored-by: obviyus <[email protected]>
|
Maintainer override: the only red job fails in a test this PR does not touch or import, and it fails on main too. |
|
Landed in cded11f.
Follow-up (separate PR): remove the |
…drop delivery dispositions (#204260) ## Problem #204178 made a child's status entry in the parent's history the delivery, but left the old delivery dispositions behind: `permanent_failure`, `ambiguous`, `intentional_non_delivery`, the announce error classifier that produced them, and a 5-minute retry/give-up ladder for announces without an explicit completion mode. Generated-media completion still read the shared dispositions. One more gap showed up in the live run: when the user pressed Stop on the parent's turn while a finished child's completion was waiting to steer in, the steer was cancelled, the delivery settled, and the child's result was dropped (the session's status was `killed`, and the history append skipped killed requesters). The parent's next turn did not have the result. ## Fix Deletion only. A child's completion is either delivered, owned by a queue or mailbox, waiting for its requester, or not delivered. "Not delivered" settles into requester history on the first failure; nothing retries it. - `SubagentAnnounceDeliveryResult` loses `disposition` and `terminal`. "A queue or mailbox owns this" is `path: "queued"`. - Deleted: `classifyAnnounceDeliveryError`, `isPermanentAnnounceDeliveryError` and the permanent error pattern list, `sourceOwnerChangedResult`, ten never-read failure reasons, `resolveDeferredCleanupDecision`, the optional-announce retry/backoff and its 5-minute expiry (`ANNOUNCE_EXPIRY_MS`, resume-time expiry, `finalizeResumedAnnounceGiveUpInBackground`, the "failed" give-up branch, `logAnnounceGiveUp`), the `delivery_suppressed → failed` branch, the yielded-batch `intentional_non_delivery` marker, and the pause-notice clear on intentional outcomes. - Announces without an explicit completion mode now settle into history on the first failure, like required ones. Children spawned with `expectsCompletionMessage: false` are unchanged. - Generated-media completion no longer reads shared dispositions: delivered → delivered; `path: "queued"` → the durable media queue owns it; anything else → not confirmed (no retry, no "ambiguous counts as delivered"). - A Stopped parent still receives a finished child's status entry (one-line guard removal). Stop ends that turn; it does not discard work that already finished. A deleted requester still receives nothing. - Persisted rows: no schema or DDL change. `delivery.disposition` stays in `payload_json`; old rows that carry a retired value decode unchanged and no reader looks at it. Legacy `suspended` rows keep their sweeper settlement, and legacy `failed` rows (results an older build gave up on) are settled into requester history the same way, once, instead of being removed by session retention. Accepted edge cases: - Media: a transient wake failure (for example a transcript conflict) now ends as "completion delivery was not confirmed" instead of retrying for up to 2 minutes; a partly sent wake reply is reported as not confirmed instead of delivered. - An ended child whose yielded requester re-armed its batch now counts as an unsettled descendant until that batch settles (it was marked settled through the deleted marker). This can only delay an ancestor's own completion until the yielded batch wakes. ## User impact The parent always gets a child's end state in its history when the wake did not consume it, including after the user stops the parent's turn. No retries, no give-up logs, no user-visible delivery rows. ## Evidence Scratch Gateway from this branch (`ocx src`, real Claude route via cliproxy, isolated state). The parent spawns a child whose task is `echo zeta-$(date +%N)` (unguessable), then runs `sleep 150` without yielding; the child finishes while the parent is in the shell call; the user Stops that parent turn (`chat.abort`, `userInitiated`); then the user asks "What did the child you spawned report?". - Before the guard removal (the #204178 rule): the completion steer was cancelled, the row settled `delivered` with no history entry, and the parent had nothing to read (its answer only matched because that child's task text contained the answer). - After: log `Subagent status appended to requester history`; the parent transcript gets the model-visible entry `Child "…" (session agent:main:subagent:…, run …): completed — zeta-080312000`; the parent's next turn answers `zeta-080312000`, the value the child printed. - Gateway logs for both runs: 0 `Subagent completion delivery` lines, 0 `delivery discarded`, 0 give-up lines. Tests: tests that asserted the removed behavior were deleted (classifier and retry tables, optional-announce backoff and 5-minute expiry, permanent/ambiguous/intentional holds, media ambiguous-to-delivered, `logAnnounceGiveUp`); remaining fixtures moved to the new outcomes (`undelivered`, `path: "queued"`, history settlement). `ocx test src/agents/subagents/registry` 1,222 passed (1 failure, `subagent-registry-worker.test.ts` serialized-payload retention, fails the same way on the base); announce, completion, media, cron, gateway and SDK touched files 972 passed (1 Gateway-readiness timeout in `test/gateway-completion-replay.e2e.test.ts` before its scenario ran; it passed in the previous run). `tsgo:core` and `tsgo:core:test` clean. `pnpm check:changed`: everything green except the dead-export scan, whose remaining entries (`appendChildStatusToRequester`, two registry test-support fixtures, `runWindowsGatewayTaskSupervisor`, `ProjectGrant`) are unused on the base too; this PR's own leftover (`isReplaySafeTranscriptConflict`, whose only caller was the deleted classifier) is removed. ## Size Production code (excluding tests and docs): `src/` +193 / −829 (net −636); with scripts +196 / −835 (net −639). Tests +209 / −948. Docs +9 / −9. ## Merge danger Two-way door; no schema, protocol or dependency change. Blast radius: subagent completion delivery, requester settle, generated-media completion wake. Co-authored-by: Ayaan Zaidi <[email protected]>
…drop delivery dispositions (openclaw#204260) ## Problem openclaw#204178 made a child's status entry in the parent's history the delivery, but left the old delivery dispositions behind: `permanent_failure`, `ambiguous`, `intentional_non_delivery`, the announce error classifier that produced them, and a 5-minute retry/give-up ladder for announces without an explicit completion mode. Generated-media completion still read the shared dispositions. One more gap showed up in the live run: when the user pressed Stop on the parent's turn while a finished child's completion was waiting to steer in, the steer was cancelled, the delivery settled, and the child's result was dropped (the session's status was `killed`, and the history append skipped killed requesters). The parent's next turn did not have the result. ## Fix Deletion only. A child's completion is either delivered, owned by a queue or mailbox, waiting for its requester, or not delivered. "Not delivered" settles into requester history on the first failure; nothing retries it. - `SubagentAnnounceDeliveryResult` loses `disposition` and `terminal`. "A queue or mailbox owns this" is `path: "queued"`. - Deleted: `classifyAnnounceDeliveryError`, `isPermanentAnnounceDeliveryError` and the permanent error pattern list, `sourceOwnerChangedResult`, ten never-read failure reasons, `resolveDeferredCleanupDecision`, the optional-announce retry/backoff and its 5-minute expiry (`ANNOUNCE_EXPIRY_MS`, resume-time expiry, `finalizeResumedAnnounceGiveUpInBackground`, the "failed" give-up branch, `logAnnounceGiveUp`), the `delivery_suppressed → failed` branch, the yielded-batch `intentional_non_delivery` marker, and the pause-notice clear on intentional outcomes. - Announces without an explicit completion mode now settle into history on the first failure, like required ones. Children spawned with `expectsCompletionMessage: false` are unchanged. - Generated-media completion no longer reads shared dispositions: delivered → delivered; `path: "queued"` → the durable media queue owns it; anything else → not confirmed (no retry, no "ambiguous counts as delivered"). - A Stopped parent still receives a finished child's status entry (one-line guard removal). Stop ends that turn; it does not discard work that already finished. A deleted requester still receives nothing. - Persisted rows: no schema or DDL change. `delivery.disposition` stays in `payload_json`; old rows that carry a retired value decode unchanged and no reader looks at it. Legacy `suspended` rows keep their sweeper settlement, and legacy `failed` rows (results an older build gave up on) are settled into requester history the same way, once, instead of being removed by session retention. Accepted edge cases: - Media: a transient wake failure (for example a transcript conflict) now ends as "completion delivery was not confirmed" instead of retrying for up to 2 minutes; a partly sent wake reply is reported as not confirmed instead of delivered. - An ended child whose yielded requester re-armed its batch now counts as an unsettled descendant until that batch settles (it was marked settled through the deleted marker). This can only delay an ancestor's own completion until the yielded batch wakes. ## User impact The parent always gets a child's end state in its history when the wake did not consume it, including after the user stops the parent's turn. No retries, no give-up logs, no user-visible delivery rows. ## Evidence Scratch Gateway from this branch (`ocx src`, real Claude route via cliproxy, isolated state). The parent spawns a child whose task is `echo zeta-$(date +%N)` (unguessable), then runs `sleep 150` without yielding; the child finishes while the parent is in the shell call; the user Stops that parent turn (`chat.abort`, `userInitiated`); then the user asks "What did the child you spawned report?". - Before the guard removal (the openclaw#204178 rule): the completion steer was cancelled, the row settled `delivered` with no history entry, and the parent had nothing to read (its answer only matched because that child's task text contained the answer). - After: log `Subagent status appended to requester history`; the parent transcript gets the model-visible entry `Child "…" (session agent:main:subagent:…, run …): completed — zeta-080312000`; the parent's next turn answers `zeta-080312000`, the value the child printed. - Gateway logs for both runs: 0 `Subagent completion delivery` lines, 0 `delivery discarded`, 0 give-up lines. Tests: tests that asserted the removed behavior were deleted (classifier and retry tables, optional-announce backoff and 5-minute expiry, permanent/ambiguous/intentional holds, media ambiguous-to-delivered, `logAnnounceGiveUp`); remaining fixtures moved to the new outcomes (`undelivered`, `path: "queued"`, history settlement). `ocx test src/agents/subagents/registry` 1,222 passed (1 failure, `subagent-registry-worker.test.ts` serialized-payload retention, fails the same way on the base); announce, completion, media, cron, gateway and SDK touched files 972 passed (1 Gateway-readiness timeout in `test/gateway-completion-replay.e2e.test.ts` before its scenario ran; it passed in the previous run). `tsgo:core` and `tsgo:core:test` clean. `pnpm check:changed`: everything green except the dead-export scan, whose remaining entries (`appendChildStatusToRequester`, two registry test-support fixtures, `runWindowsGatewayTaskSupervisor`, `ProjectGrant`) are unused on the base too; this PR's own leftover (`isReplaySafeTranscriptConflict`, whose only caller was the deleted classifier) is removed. ## Size Production code (excluding tests and docs): `src/` +193 / −829 (net −636); with scripts +196 / −835 (net −639). Tests +209 / −948. Docs +9 / −9. ## Merge danger Two-way door; no schema, protocol or dependency change. Blast radius: subagent completion delivery, requester settle, generated-media completion wake. Co-authored-by: Ayaan Zaidi <[email protected]>
…penclaw#204299) ## What Problem This Solves QA Smoke CI (profile 3/6) fails on every `main` run since 7172fc1 (openclaw#204178): scenario `subagent-empty-completion-recovery` reports `empty completion did not produce exactly one system failure notice`. The last green run was on 954c6f8. ## Why openclaw#204178 delivers a child's end state as parent history. A completion turn that consumes the child's result is delivered, whatever it replied, and the missing-reply notice ("No answer was returned. Ask again if you still need one.") was removed. The scenario still required exactly one notice. The failing run's outbound shows only the "Working" card and the parent acknowledgement, which is the new behavior. ## Change (test only) - Replace the one-notice assertion with the new contract: the parent completion turn consumes the failed child outcome exactly once (one provider request with `[Internal task completion event]`). - The notice text moves to `forbiddenReplies`, so a returning notice fails the existing leak checks. - After the Gateway restart: no completion request replays (unchanged); the notice-identity checks are removed. - The child checks are unchanged: failed terminal outcome, one real write, two tool-free finalizations, no fabricated result. ## Evidence - Failing scheduled run 45259316971, job "QA Smoke CI (profile 3/6)": outbound = `Working` card + `QA-SUBAGENT-EMPTY-PARENT-ACK`, no notice. - The scenario YAML parses (45 flow actions). The QA Smoke CI shard on this PR is the run proof. Co-authored-by: Ayaan Zaidi <[email protected]>
…jobs (openclaw#204314) ## Result A selected (PR) Node job no longer inherits the 120-minute whole-config timeout from a group it does not run. `test/scripts/ci-changed-node-test-plan.test.ts` "retains precise process ownership and independent timing keys (github)" passes again. ## Cause `createSelectedNodeTestShardBundles` projects each job of a subset compact plan onto the selected files, and copies the job's fields with `...shard`. When that subset job also held a whole-config group (no `includePatterns`), it carried `COMPACT_WHOLE_NODE_TEST_TIMEOUT_MINUTES` (120). The projection drops the unselected whole group but kept its 120-minute timeout. So an exact-file job could run with twice its canonical owner's deadline. It is latent and depends on packing. openclaw#204178 (`7172fc1f5015`) added a test to `databaseWorkerCoreTestFiles`, which changed the subset packing for the GitHub profile. After that, `agentic-agents-embedded-base-3` (canonical owner timeout 60) shared a subset job with the whole `agentic-agents-embedded-run` group and got 120. A planner replay of the test's two targets shows it: at `447aed3e` (parent) the selected job has timeout 60; at `7172fc1f` it has 120. The canonical owner jobs are the same at both commits. openclaw#204292 did not change this path: `main` fails the same way before and after it. ## Fix The projection keeps the whole-config timeout only when a retained group is still a whole group (`!includePatterns`). Every other timeout, such as the long-unfitted 90 minutes or a cron minimum, is copied as before. ## Evidence - Planner replay (GitHub profile, the test's two embedded targets): before, `checks-node-changed-compact-large-35` has `timeoutMinutes: 120`; after, no override (60 default). The single-file `embedded-run` job no longer gets 120 either, which matches its canonical owner, since its whole group is not selected. - `test/scripts/ci-changed-node-test-plan*.test.ts`, `ci-node-test-plan.test.ts`, `ci-workflow-planning.test.ts`: 11 files, 1,285 tests pass on the head. The named case fails on `main` (`expected 120 to be less than or equal to 60`), the same as scheduled run 45288712101 (small-18). - CI green on the head; local ClawSweeper: patch is correct, no findings. Co-authored-by: Ayaan Zaidi <[email protected]>
…openclaw#204367) ## What Problem This Solves Closes openclaw#204267. The QA smoke scenario `subagent-empty-completion-recovery` asserted the child delivery failure notice that openclaw#204178 removed. openclaw#204299 already replaced that notice assertion with "the parent's completion turn consumes the failed child outcome exactly once" (provider-request count). The scenario still did not check the new contract where it lives: the parent's history. ## Change (test only) The scenario now reads the parent transcript after the child fails, and again after the Gateway restart, and asserts: - exactly one entry carries the failed child's status (the `[Internal task completion event]` input or a `subagent-completion` entry), and it is hidden (`display: false`) but model-visible; - no `run-failed-before-reply` row and no displayed `subagent-*` row (the removed "System" dump of the child's raw result and the "delivery delayed" row); - the restart does not change any of this. The existing checks stay unchanged: failed terminal outcome, one real write, two tool-free finalizations, no fabricated result, one parent completion request, and no replay after the restart. Production-code line delta: 0 (scenario YAML only, +21 −2). ## Evidence - Head, same lane as CI (`OPENCLAW_BUILD_PRIVATE_QA=1 pnpm build qaRuntime`, then `node openclaw.mjs qa run --qa-profile smoke-ci --scenario subagent-empty-completion-recovery`): `passed=1 failed=0`. - Parent transcript on head (synthetic run): the child status is one hidden `openclaw.runtime-context` entry carrying `[Internal task completion event]` with the child session key. There is no `subagent-completion` entry (the completion turn consumed it) and no `run-failed-before-reply` row. - Base (`main` after openclaw#204299): the old scenario passes too, so this PR does not repair a red; it adds the history assertions that openclaw#204299 left out. Co-authored-by: Ayaan Zaidi <[email protected]>
…jobs (#204314) A selected (PR) Node job no longer inherits the 120-minute whole-config timeout from a group it does not run. `test/scripts/ci-changed-node-test-plan.test.ts` "retains precise process ownership and independent timing keys (github)" passes again. `createSelectedNodeTestShardBundles` projects each job of a subset compact plan onto the selected files, and copies the job's fields with `...shard`. When that subset job also held a whole-config group (no `includePatterns`), it carried `COMPACT_WHOLE_NODE_TEST_TIMEOUT_MINUTES` (120). The projection drops the unselected whole group but kept its 120-minute timeout. So an exact-file job could run with twice its canonical owner's deadline. It is latent and depends on packing. #204178 (`cded11f81d55`) added a test to `databaseWorkerCoreTestFiles`, which changed the subset packing for the GitHub profile. After that, `agentic-agents-embedded-base-3` (canonical owner timeout 60) shared a subset job with the whole `agentic-agents-embedded-run` group and got 120. A planner replay of the test's two targets shows it: at `dae98a63` (parent) the selected job has timeout 60; at `cded11f8` it has 120. The canonical owner jobs are the same at both commits. #204292 did not change this path: `main` fails the same way before and after it. The projection keeps the whole-config timeout only when a retained group is still a whole group (`!includePatterns`). Every other timeout, such as the long-unfitted 90 minutes or a cron minimum, is copied as before. - Planner replay (GitHub profile, the test's two embedded targets): before, `checks-node-changed-compact-large-35` has `timeoutMinutes: 120`; after, no override (60 default). The single-file `embedded-run` job no longer gets 120 either, which matches its canonical owner, since its whole group is not selected. - `test/scripts/ci-changed-node-test-plan*.test.ts`, `ci-node-test-plan.test.ts`, `ci-workflow-planning.test.ts`: 11 files, 1,285 tests pass on the head. The named case fails on `main` (`expected 120 to be less than or equal to 60`), the same as scheduled run 45288712101 (small-18). - CI green on the head; local ClawSweeper: patch is correct, no findings. Co-authored-by: Ayaan Zaidi <[email protected]> (cherry picked from commit 0921f9f) Co-authored-by: RomneyDa <[email protected]>
…a child wake (#204602) ## Problem `test/gateway-yield-restart.e2e.test.ts` ("preserves yielded work through an actual Gateway restart (policy-unavailable)") fails on `main`: `expected '[{"role":"user",…' to contain 'REQUESTER_RECEIVED_CHILD_COMPLETION'`. No scheduled CI lane runs this file. The case injects one transient access-policy outage while the child's completion wakes its yielded requester. It then waits for a second, retried wake turn. #204178 removed that retry. When a wake does not consume the child's result, the child's end state is appended once to the requester transcript as model-visible history (a hidden `subagent-completion` entry), and the delivery settles. A debug run on `main` shows exactly that: `Subagent completion direct announce failed … Gateway access policy is unavailable`, then `Subagent status appended to requester history`. ## Solution Test-only change. For `policy-unavailable`, the test now asserts the #204178 contract: exactly one hidden `subagent-completion` entry in the requester transcript, naming the child session with status `completed` and the child's result (`PARKED_CHILD_COMPLETED`). The other cases are unchanged. The existing checks still apply: the outage was injected, and restart recovery did not refuse the input. ## Impact No change to production code or user behavior. ## Evidence - Before: `policy-unavailable` fails on `main` (`27dc1533`) with the error above; a debug run shows the history append. - After: `policy-unavailable` passes on a built Gateway with this change. - Not covered by this PR: in the same full-file run, 4 other cases (`completed-before`, `continue`, `root-main-legacy-stopped`, `root-main-tool-stopped`) failed with `SyntaxError: Unexpected end of JSON input` at `test/gateway-restart.test-support.ts:95` (the fake provider parses an empty request body). This change does not touch those cases or that fixture. They pass on `main` in other runs; the empty-body cause is tracked separately. Co-authored-by: Ayaan Zaidi <[email protected]>
…a child wake (openclaw#204602) ## Problem `test/gateway-yield-restart.e2e.test.ts` ("preserves yielded work through an actual Gateway restart (policy-unavailable)") fails on `main`: `expected '[{"role":"user",…' to contain 'REQUESTER_RECEIVED_CHILD_COMPLETION'`. No scheduled CI lane runs this file. The case injects one transient access-policy outage while the child's completion wakes its yielded requester. It then waits for a second, retried wake turn. openclaw#204178 removed that retry. When a wake does not consume the child's result, the child's end state is appended once to the requester transcript as model-visible history (a hidden `subagent-completion` entry), and the delivery settles. A debug run on `main` shows exactly that: `Subagent completion direct announce failed … Gateway access policy is unavailable`, then `Subagent status appended to requester history`. ## Solution Test-only change. For `policy-unavailable`, the test now asserts the openclaw#204178 contract: exactly one hidden `subagent-completion` entry in the requester transcript, naming the child session with status `completed` and the child's result (`PARKED_CHILD_COMPLETED`). The other cases are unchanged. The existing checks still apply: the outage was injected, and restart recovery did not refuse the input. ## Impact No change to production code or user behavior. ## Evidence - Before: `policy-unavailable` fails on `main` (`3f8dcfb5`) with the error above; a debug run shows the history append. - After: `policy-unavailable` passes on a built Gateway with this change. - Not covered by this PR: in the same full-file run, 4 other cases (`completed-before`, `continue`, `root-main-legacy-stopped`, `root-main-tool-stopped`) failed with `SyntaxError: Unexpected end of JSON input` at `test/gateway-restart.test-support.ts:95` (the fake provider parses an empty request body). This change does not touch those cases or that fixture. They pass on `main` in other runs; the empty-body cause is tracked separately. Co-authored-by: Ayaan Zaidi <[email protected]>
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]>
…4098) ## Problem In a Control UI chat, when a child finished and the parent sent its update with the `message` tool, the user saw two bubbles: the update, then a second, third-person one ("I sent the user the corrected dates... Still waiting on: ..."). Cause: the requester-settle wake is an inter-session turn. Since #164860, every inter-session internal-sink send was treated as transcript-only. The tool told the model "Recorded reply in the current chat history ... did not deliver it to an external channel", and neither the embedded delivery fact nor the Claude CLI tracker (#170534) counted the send as the turn's answer. A reply was still owed, so the model wrote an epilogue to the inter-session sender, and Control UI showed it as a normal assistant row. ## Solution - One fact, computed where the message tool is built: an internal-sink send is transcript-only only when the turn is inter-session **and** the session has an external delivery record (`sessionDeliveryChannel(entry)`, the same record `resolveAnnounceOrigin` treats as the external binding). It feeds the receipt and the embedded delivery fact (`messageDelivery.sourceReplyDelivered`). - The Claude CLI tracker no longer runs its own `inputProvenance.kind !== "inter_session"` check. It reads the message tool's `messageDelivery.sourceReplyDelivered` fact, which it already consumed. The duplicate branch is deleted. - The settle-wake instruction for yielded deliverables now says child results are not a message from the user, and the answer goes to the user of the original conversation, addressed to them directly. The #164860 case stays fixed: a WhatsApp/Telegram DM-scope main session gets `delivery.kind = "external"` during session init before its first agent turn (`src/auto-reply/reply/session.ts`), and Control UI turns do not replace an external record (`session-delivery.ts`, `metadata-projection.ts`). So a route-less inter-session turn there still gets the transcript-only receipt. Accepted edge (no code): a session used from both an external chat and the Control UI keeps today's behavior (transcript-only receipt on inter-session turns). Not changed: later assistant finals after a send are not hidden; the private-completion path and NO_REPLY policy for completion turns are unchanged. ## User impact Control UI users get one message, addressed to them, when a delegated task finishes. External-chat sessions behave as before. ## Evidence - Regression tests, red on merge base `59b0aec099f5`, green on head: - `message-tool.internal-source-reply.integration.test.ts` › "answers a Control UI user from an inter-session result turn": visible receipt and `sourceReplyDelivered: true`. - `cli-runner.reliability.test.ts` (via `cli-runner.reply-completion.test-support.ts`) › "ends a Control UI child-result turn at its final message-tool answer": real message tool, CLI run settles as success with one assistant row. - The #164860 test now seeds an external delivery record and still gets the transcript-only receipt (green on base and head). - Importers of every changed source: 47 test files that import a changed source or test-support file: all green (`ocx test`, vitest-source). `pnpm check:changed`: typecheck, lint, format and guards pass; the one red is the dead-export scan on `scripts/lib/docker-e2e-watchdog.mjs`, which this PR does not touch. - `pnpm prompt:snapshots:check` (clean HOME): current. ### Control UI E2E: before and after **Proof tier:** source (`ocx src`, pinned Bun fork). Two isolated scratch Gateways (merge base `59b0aec099f5` and head `5505abef8ce2`; the later head commit `56262188568a` changes only a test fixture type). Real Anthropic model (`anthropic/claude-sonnet-4-6`), driven through the Control UI in a browser. Embedded OpenClaw runtime. **Steps (same on both sides, fresh dashboard session per trial):** one prompt: "Delegate a quick schedule check to a child using sessions_spawn ..., wait with sessions_yield. When it finishes, send me the update with the message tool." The child runs `sleep 15` and reports. The requester-settle wake (`inter_session`, `subagent_settle`) sends a targetless `message` with `final: true`. | | Receipt on the settle wake (3/3) | Visible settle bubbles per trial | |---|---|---| | Before (merge base) | `Recorded reply in the current chat history via internal-ui. This send did not deliver it to an external channel.` | 1, **2**, 1 (the other two ended with hidden `NO_REPLY`) | | After (this PR) | `Sent visible reply to the current source conversation via internal-ui.` | 1, 1, 1 (no later model message in the settle run) | The duplicate on the base (trial 2) was a second model response in the same settle run: "Done! The child subagent finished its `sleep 15` and reported back. Here's the summary it delivered: ..." No empty-response or incomplete-turn errors on either side. **Gaps:** - Claude CLI runtime: real CLI runs worked on both sides, but in this scratch setup the settle-wake message tool did not receive inter-session provenance on the base either (base receipt was already "Sent visible ..."), so the live CLI runs did not reach the changed condition. The CLI path is covered by the regression test that drives the real CLI runner and the real message tool (`cli-runner.reliability.test.ts`, red on base, green on head). - The `sessions_send`-to-a-kept-child variant was not run; the spawn + yield variant reaches the same settle wake. - The model's wording varied; the head reply was a direct update to the user in each trial.   Diff: production +9 / −14 (one fact, one deleted tracker branch, one prompt line, one comment). Co-authored-by: Ayaan Zaidi <[email protected]> (cherry picked from commit a9c1dd8) Follow-ups: cded11f fix(agents): deliver a child's end state as parent history, not a turn obligation (#204178) [not selected for this narrow backport] Co-authored-by: RomneyDa <[email protected]>
…jobs (#204314) A selected (PR) Node job no longer inherits the 120-minute whole-config timeout from a group it does not run. `test/scripts/ci-changed-node-test-plan.test.ts` "retains precise process ownership and independent timing keys (github)" passes again. `createSelectedNodeTestShardBundles` projects each job of a subset compact plan onto the selected files, and copies the job's fields with `...shard`. When that subset job also held a whole-config group (no `includePatterns`), it carried `COMPACT_WHOLE_NODE_TEST_TIMEOUT_MINUTES` (120). The projection drops the unselected whole group but kept its 120-minute timeout. So an exact-file job could run with twice its canonical owner's deadline. It is latent and depends on packing. #204178 (`cded11f81d55`) added a test to `databaseWorkerCoreTestFiles`, which changed the subset packing for the GitHub profile. After that, `agentic-agents-embedded-base-3` (canonical owner timeout 60) shared a subset job with the whole `agentic-agents-embedded-run` group and got 120. A planner replay of the test's two targets shows it: at `dae98a63` (parent) the selected job has timeout 60; at `cded11f8` it has 120. The canonical owner jobs are the same at both commits. #204292 did not change this path: `main` fails the same way before and after it. The projection keeps the whole-config timeout only when a retained group is still a whole group (`!includePatterns`). Every other timeout, such as the long-unfitted 90 minutes or a cron minimum, is copied as before. - Planner replay (GitHub profile, the test's two embedded targets): before, `checks-node-changed-compact-large-35` has `timeoutMinutes: 120`; after, no override (60 default). The single-file `embedded-run` job no longer gets 120 either, which matches its canonical owner, since its whole group is not selected. - `test/scripts/ci-changed-node-test-plan*.test.ts`, `ci-node-test-plan.test.ts`, `ci-workflow-planning.test.ts`: 11 files, 1,285 tests pass on the head. The named case fails on `main` (`expected 120 to be less than or equal to 60`), the same as scheduled run 45288712101 (small-18). - CI green on the head; local ClawSweeper: patch is correct, no findings. Co-authored-by: Ayaan Zaidi <[email protected]> (cherry picked from commit 0921f9f) Follow-up audit: 6f93bcc volume baselines, 2c645bf UI/runtime eligibility, d7246e9 test tiers, b9ef0d7 scheduling coverage, 1e0c8f8 inventory, ad2f629 build selection, and 5754fac importer scope are independent planner changes; b5263df and b59c1b2 cover agent QA/history. Keep baseline build placement and relative timing. Release adaptation: Retained baseline pretest build mode and timing projection; only changed inherited timeout handling. Co-authored-by: RomneyDa <[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]>
…arent Ayaan approved one notice on top of #204178: the status entry stays hidden and model-visible, and an idle requester's chat gets one chat-only line naming the child and the reason. A running requester turn reads the entry, so it gets none.
…208772) ## Approved scope Maintainer decision (@obviyus, 2026-11-30 08:29 IST, "yes"), quoted verbatim: > the child's result stays HIDDEN exactly as #204178 has it, PLUS ONE separate short displayed line at the same owner, emitted only for the give-up case where no parent turn consumed the hidden row: 'Child <label> finished, but its result couldn't reach this chat: <reason>. Send a message to continue.' No result dump; nothing else in #204178 changes. ## What Problem This Solves A child's completion that no parent turn consumes settles at once as a hidden, model-visible status entry in the parent's history (#204178). The parent model reads that entry on its next turn and decides what to tell the person. When no parent turn is running, nothing else wakes the parent, so the person never learns that the child finished. One example is a parent whose completion turn was refused before it started by its access-program check. - Production, one Gateway, 14.7 h: 85 of 91 refused completions settled this way within 2 s. - 14 parent sessions never ran again, and their people saw nothing. Reproduced on `main` with a real Gateway (local fake provider, the real OpenAI route through a managed proxy): - A parent bound to a managed worktree spawns a child. The child finishes, and the parent's completion turn is refused before start. - The parent chat shows nothing after the parent's own tool turn. The hidden entry holds the child's result. - 3/3 runs. ## Solution This adds one notice on top of #204178 and changes nothing else in it. `appendChildStatusToRequester` is the single owner that every undelivered child completion passes through: the requester-settle batch, the announce give-up, media-queue recovery and the legacy suspended-row sweep. 1. It writes the hidden status entry exactly as before. The result stays hidden. 2. Then, only if no turn is running on the parent's own session, it writes ONE separate displayed line: > Child "<label>" finished, but its result couldn't reach this chat: <reason>. Send a message to continue. **How "no parent turn consumed the hidden row" is decided at the owner:** - The owner runs only on give-up. Children whose input a parent turn already consumed, and delivered children, never reach it. - At the moment of give-up, `isSessionRunActive(<parent session id>)` is checked. - **Running:** that turn reads the entry on its next model call, so no line is written. - **Not running:** nothing will read the entry until the person sends a message, so the line is written. - The check uses the physical session id, so another agent's session that shares a raw key such as `global` does not hide the line. **What the line is:** - It is `display: true, excludeFromContext: true`. The model context is unchanged, and the line carries no result. - It is deduped by the same status id. - No retry, timer or new state is added. - `formatAnnounceDeliveryError` no longer repeats the delivery error as a `direct-primary:` phase, so the reason in the line reads once. ## User Impact - **Idle Control UI and task parents:** when a child's result cannot reach the parent, the chat shows one short line with the reason. Sending a message lets the parent read the result. - **Running parents, delivered completions and channel parents:** unchanged. The #207194 channel notice stays as it is, and the line is a history row that is not sent to the channel. - **Accepted edge:** while the cause persists, the person's next message can be refused too. An access-program refusal is fixed separately. - **Accepted edge, not coded:** a give-up that lands after a running parent turn's last model call gets no line, and the next turn reads the entry. This is rare: a completion for a running parent normally joins that turn. ## Evidence - `subagent-child-status-history.test.ts`: - **Red on the merge base, green here:** - an idle parent gets exactly one line after a settle-path give-up, and after an announce-path give-up, with the label and the reason; - **no displayed row contains the child's result**, and the result is still in the hidden entry; - another agent's running session with the same raw key does not hide the line. - **Green on both:** - a running parent gets no line; making the check key-scoped or removing it turns this or the shared-key case red; - a delivered completion writes neither row; - the existing entry, budget, compaction and mid-turn tests pass, which shows the line stays out of the model context. - **Real Gateway, F3** (a refused completion into an idle managed-worktree parent): merge base 3/3 with no line; this branch 3/3 with the line shown and the result kept only in the hidden entry. Before/after screenshots are below. - **Tests that import the changed modules, and the delivery and settlement suites:** 26 files green. One case, `subagent-completion-replay.test.ts` "does not replay an announcement settled in requester history", failed once inside the 25-file batch under host load, with a residual root at teardown (28.6 s instead of about 4 s). It passes alone on this branch and on the merge base. ## The system-cancelled completions on one production Gateway (deploy window, exact scorecard rows) None would get the line; all end delivered: - **6 pause wakes** (`requester-settle … :pause`): yield acknowledgements, not child results. Paused children never reach the give-up owner, and the results arrived later through normal completions. - **3 expired announces** (`announce:v1`, one parent): all three expired while the parent's own run was auto-compacting (17:56:29 start, 17:57:43 "succeeded; retrying prompt"; the third during the retried prompt). That run was active, so no line; its retried model call read the hidden entries written at +0 s. Co-authored-by: Ayaan Zaidi <[email protected]>
Problem
When a child agent's result could not reach its parent through a parent turn, OpenClaw parked, retried, expired or "failed" the delivery and showed the user artifacts they could not act on: a System row dumping the child's raw result, a "delivery delayed" row, a red "Couldn't finish this reply" lifecycle error, or a failure notice after a 7-day or 30-minute expiry. The parent model often never saw the child's end state at all.
Reproduced on
mainwith a scratch Gateway and a real Claude route: a parent yields on two children, its wake turn for child A fails at the provider, and the chat shows a System rowChild <Child A> (run …) ok ALPHA(log:Subagent completion delivery result).Fix
The child's end state is history, not a turn obligation:
completed+ result capped at 8,000 chars per child and 32,000 per entry; a truncated result says to ask the child for the rest withsessions_send,failed: …,timed out,interrupted by Gateway restart,killed) and, for failures, "If you still need this work, resume it with sessions_send or start a new child with sessions_spawn."failed_noticechannel send, expiry farewell orchild_completion_delivery_failedlifecycle error. A yielded requester whose continuation never ran ends as an ordinary run.suspendedstill decode and are settled once on the next sweep by appending their status (no wake).collect/expectsCompletionMessage !== trueexclusions, the message-tool-only text fallback, and cleanup's storage write retry (which now also retries a failed append).Mid-turn: if the status lands between a tool call and its result, the existing replay pairing repair moves it after the result, so provider role order stays valid (covered by the new test).
Accepted edge case: the transcript report owner dedupes against the latest status entry only. If a child's status append commits, its registry write then fails, and another child's status appends before the retry, the retry repeats the first entry. It is a repeated history line, never a lost result; a per-child receipt would need a new transcript identity mechanism.
User impact
The parent decides whether to tell the user, resume the child or start a new one. The user sees the parent's reply and the child card; no System dumps, delayed rows or delivery error badges.
Evidence
Scratch Gateway from source on a real Claude route, before (
main) and after (this branch):Child … ok ALPHA, logSubagent completion delivery result. After: no System row and zeroSubagent completion delivery/delivery discardedlog lines; the parent's next wake answersChild A: ALPHA — Child B: BRAVO. The red "Couldn't finish this reply" in both is the parent's own provider failure (the injected fault), not a child row.failed: unknown provider …, respawns without the override and reportsPONG.spawn_agentwith an unknown model): the parent sees the error and respawns; no user-visible delivery rows.Before:

After:

Tests: new
subagent-child-status-history.test.tsproves, through the real transcript append and model-context read, that the status entry is model-visible exactly once for an idle parent, survives compaction, and keeps tool call/result adjacent at the provider boundary when it lands mid-turn. Existing suites were updated: tests that asserted notices, suspension, expiry, retry ladders or permanent/ambiguous holds were deleted; ownership, consumption, rollback and write-retry coverage stays.Size
Production code (excluding tests and docs):
src/+264 / −980 (net −716); with the bench/perf scripts that exercised the removed paths, +266 / −1,439. Tests: +539 / −3,166. Docs: about +50 / −100.Not in this PR (follow-up): removing the
permanent_failure/ambiguous/intentional_non_deliverydisposition values and the announce error classifier. Generated-media completion delivery still consumes them, so they need their own cut.Merge danger
Two-way door for code; no schema change (delivery state lives in
payload_json). Settled legacysuspendedrows becomedeliveredand are not restored by a revert. Blast radius: subagent completion delivery and requester wake settlement.