Repository navigation
fix(agents): stop queued Swarm collectors with their parent - #133076
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs maintainer review before merge. Reviewed August 30, 2026, 5:21 AM ET / 09:21 UTC. ClawSweeper reviewWhat this changesThis PR preserves a parent turn identity for Swarm collectors and changes Stop handling to hold and cancel its selected queued or running descendants, with matching Gateway, task, session, UI-test, and documentation updates. Regression provenancePossible regression — probable (reproduction; reviewed change). No predecessor PR is attributed. Merge readinessKeep open for explicit maintainer review. The branch addresses a source-proven queued-collector Stop failure and supplies real-provider after-proof; no blocking correctness finding was found, but its retained cancellation authority spans session, task, scheduler, and requester boundaries. Priority: P1 Review scores
Verification
How this fits togetherA parent agent turn registers sub-agent and Swarm collector work in the registry and scheduler. Gateway and chat Stop requests resolve that parent-owned tree, cancel eligible runtime work, and return task/session outcomes to clients and the Control UI. flowchart LR
A[Parent agent turn] --> B[Sub-agent registry]
B --> C[Swarm scheduler]
D[Gateway or chat Stop] --> E[Parent-run cancellation scope]
E --> B
E --> C
B --> F[Task and session state]
F --> G[Gateway response and Control UI]
Decision needed
Why: The direct producer fix is necessary, but the requested behavior also requires retained authority through asynchronous scheduler and lifecycle transitions; that merge-scope tradeoff needs maintainer intent. Before merge
Agent review detailsSecurityNone. PR surfaceSource +856, Tests +6493, Docs +43. Total +7392 across 70 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Keep parent-run association at registration and retain one explicit, fenced cancellation scope that holds selected reservations before parent cancellation and only withdraws work still owned by that scope. Do we have a high-confidence way to reproduce the issue? Yes, source-proven: current main drops the parent-run field for non-announcing collectors, while the supplied pre-fix report records an exact parent abort leaving one child running and another queued. Is this the best way to solve the issue? Yes, with maintainer scope review: repairing registration fixes the producer defect, and the reservation hold is the relevant protection against a queued child starting between selection and cancellation. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 6ddd598683fa. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (5 earlier review cycles)
|
a71aa8f to
49ec295
Compare
|
@clawsweeper re-review Updated to Current-head real-provider queued-child cancellation passed from the original non-admin requester, with three foreign-requester refusals and zero rescue mutations. UI Stop/video proof and exact-head CI are still pending, explicitly separated from historical evidence. This requests review only, not automerge. |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
Current-head verification and maintainer decisionHead The root defect was producer-owned: non-announcing collectors lost their exact parent-turn association. An association-only repair would still allow released capacity to dispatch queued work during cancellation. Maintainer scope decision: accept the retained lexical cancellation owner as the canonical boundary, including exact reservation holds, committed recovery/retirement checks, and final publication. This addresses the completed ClawSweeper review and its rank-up request. Ordinary replacements and foreign/protected work are not adopted. Delayed launch-label rewriting was removed; captured partials finalize through the existing transcript owner. The rebase preserves upstream pending-admission rejection, first-abort attribution and terminal-write durability, together with the exact first-turn session binding. Later-main drift through Production +2,000/−1,106 (net +894); tests/support +9,134/−1,073 (net +8,061); docs +49/−6. Pure moves add no capability. The production growth supplies retained cancellation ownership plus truthful queued visibility/direct-child Stop; a smaller association-only change cannot protect the demonstrated dispatch, replacement and publication races. No schema, table, index, new durable field, storage format, configuration option or protocol version was added. The queued read projection selects an existing payload field; the review's stored-data warning concerned test fixtures, not a production migration. Fresh real UI proofBoth recordings used the new build, a fresh isolated browser profile, and a task-owned Gateway. The actual Stop buttons were exercised. Supplied labels, running/queued state, unset queued execution duration, original session identity, complete history and cleanup were checked. Authentication was trimmed; both screenshot pairs, video timelines and terminal frames were inspected. All visible data is synthetic. Parent Stop: the original admitting UI connection stops its exact parent. Both collectors are cancelled, the queued child's complete history stays empty, and all three original sessions become idle. swarm-2daa-parent-stop-2daa-public.mp4Queued-child Stop: a foreign requester is refused first. The original UI connection stops only the selected queued child. Its sibling remains executing at acknowledgment, completes naturally, and the parent is not aborted. swarm-2daa-child-stop-2daa-public.mp4Before parent Stop, on the fixed build: After parent Stop: API and bounded parallel stressFive fresh real-provider API trials passed, including two concurrent pairs. All 172/172 health requests succeeded (maximum observed 129.44 ms), 11 foreign API cancellation requests were refused, and every case finished with zero rescue mutations and zero connection faults. The UI child-only trial additionally refused its foreign requester.
Parent-cancellation history/activity became quiescent in 15.02–15.16 seconds. The separate pre-existing definitive-error projection delay is explicitly retained as follow-up work; these timings are not evidence of continued guest execution. Child-only Stop deliberately allowed its untouched sibling to finish naturally, 21.04 seconds after acknowledgment. The isolated Gateway was stopped after all cases were verified idle. Regression, build and review evidenceThe final integration passed 539 tests in 17 files, all 111 responsive UI tests, and 182 private probe/observation tests. Core and core-test types, targeted lint, formatting, UI i18n, zero-cycle/zero-dead-export checks and classified guards passed. Runtime/UI and SDK builds passed, followed by SDK import verification without constructing a client or making a network request. The earlier CI fixture failures and hollow negative reactivation tests remain repaired; their original failing reproductions were retained. The fresh managed review completed all 26 bounded passes. It returned eight P2 duplicates for obsolete indexed Exact current-integration commands (serial test invocations, no worker/runtime overrides): pnpm installnode scripts/run-vitest.mjs src/agents/subagents/registry/subagent-control.recovery.test.ts src/agents/subagents/spawn/subagent-spawn.authority.test.ts src/gateway/server-methods/chat-send-session-binding.test.ts src/gateway/server-methods/sessions.abort-embedded.test.ts src/gateway/session-utils.queued-collector.test.ts src/gateway/server-methods/agent.test.ts src/gateway/server-methods/sessions.send-followup-status.test.ts src/gateway/session-utils.single-row-cache.test.ts src/gateway/session-utils.queued-collector-admission.test.ts src/gateway/chat-abort.test.ts src/gateway/chat-abort-lifecycle-internal.test.ts src/sessions/session-lifecycle-admission.test.ts src/sessions/session-lifecycle-admission.pending.test.ts src/gateway/server-worker-placement-cancel.test.ts src/gateway/server-methods/session-change-event.test.ts src/gateway/server-methods/session-active-runs.test.ts src/gateway/server.chat-first-turn-binding.test.tsnode scripts/run-vitest.mjs ui/src/pages/chat/chat-responsive.browser.test.tsnode scripts/check-changed.mjs --base 6e6319440e7a9a9758cdf18995ebdc6455d826d0 -- src/gateway/chat-abort.ts src/gateway/chat-abort-lifecycle-internal.ts src/gateway/agent-turn/agent-admission-controller.ts src/gateway/server-methods/chat-send-admission.ts src/gateway/server-methods/chat-send-agent-dispatch.ts src/gateway/server-methods/chat-send-pre-admission.ts src/gateway/server-methods/chat-send-setup.ts src/gateway/server-methods/chat-send-turn-adoption.ts src/gateway/server-methods/chat-user-turn-recorder.ts src/gateway/server-methods/chat-abort-handler.ts src/gateway/server-methods/chat-abort-runtime.ts src/gateway/server-methods/sessions-abort.ts src/gateway/server-worker-placement-cancel.ts src/sessions/session-lifecycle-admission.ts src/sessions/session-work-admission-handoff.ts src/agents/subagents/registry/subagent-control.recovery.test.ts src/agents/subagents/spawn/subagent-spawn.authority.test.ts src/gateway/server-methods/chat-send-session-binding.test.ts src/gateway/server-methods/sessions.abort-embedded.test.ts src/gateway/session-utils.queued-collector.test.ts src/gateway/server.chat-first-turn-binding.test.ts ui/src/pages/chat/chat-responsive.browser.test.tspnpm buildpnpm --filter @openclaw/sdk buildThe UI recorder accounts for exact selected-path 404/no-store workspace-icon responses with visible folder/label fallback; there were zero unexpected console errors and zero page errors. Earlier failed recorder receipts remain unchanged. No credentials or agent transcripts are attached. Remaining follow-up and merge stateA separate repair is in progress for definitive native cancellation being held behind the provider-retry grace window. It is repairing the existing persistence/finalization owner and a reproduced cron attempt/outer-fallback lifecycle gap, while preserving shipped The latest completed ClawSweeper review has no actionable correctness findings; its canonical-scope decision is accepted above. Its requested refresh still has a publisher failure and queued retry. Exact-head CI is green; native prepare/merge is the next step. This comment does not claim the PR has merged. |
Preserve exact parent-run ownership independently of completion delivery. Hold selected queue reservations before cancellation, retain lexical ownership through recovery and retirement, and publish task results only while that owner remains current. Bind first-turn chat cancellation to the prepared canonical session and preserve original transcript incarnations. Keep foreign and replacement work untouched, initiate native and ACP cancellation together, and report incomplete cancellation truthfully. Fixes #131553
Persist child labels at creation and project exact scheduler-owned queued work without inventing an execution context or start clock. Preserve operator renames when delayed launches begin. Route direct queued-child Stop through the existing fenced kill owner and shared Gateway cancellation plan. Preserve requester ownership, canonical abort markers, coexisting work, synchronous publication, and the original Stop reason during native preaccept admission draining. Finalize captured chat output even when later collector cancellation loses authority, and report incomplete cancellation instead of success when other owners keep the selected collector queued. Keep transcript snapshots and persistence in the existing transcript owner, with a lazy placement boundary instead of loading the cancellation owner. Cover session lists, history, events, typed Stop, exact Stop, native preaccept admission, replacement, retirement, and foreign requester cases. Consolidate the attachment layout regression with the upstream readiness fix while retaining desktop materialization and strict geometry checks.
7177dca to
2daa642
Compare
|
Merged via squash.
|
…#133076) * fix(agents): stop queued Swarm collectors with their parent Preserve exact parent-run ownership independently of completion delivery. Hold selected queue reservations before cancellation, retain lexical ownership through recovery and retirement, and publish task results only while that owner remains current. Bind first-turn chat cancellation to the prepared canonical session and preserve original transcript incarnations. Keep foreign and replacement work untouched, initiate native and ACP cancellation together, and report incomplete cancellation truthfully. Fixes openclaw#131553 * fix(tasks): keep cancellation contracts out of runtime cycles * test(ui): wait for responsive attachment layout * fix(agents): expose and cancel queued Swarm collectors Persist child labels at creation and project exact scheduler-owned queued work without inventing an execution context or start clock. Preserve operator renames when delayed launches begin. Route direct queued-child Stop through the existing fenced kill owner and shared Gateway cancellation plan. Preserve requester ownership, canonical abort markers, coexisting work, synchronous publication, and the original Stop reason during native preaccept admission draining. Finalize captured chat output even when later collector cancellation loses authority, and report incomplete cancellation instead of success when other owners keep the selected collector queued. Keep transcript snapshots and persistence in the existing transcript owner, with a lazy placement boundary instead of loading the cancellation owner. Cover session lists, history, events, typed Stop, exact Stop, native preaccept admission, replacement, retirement, and foreign requester cases. Consolidate the attachment layout regression with the upstream readiness fix while retaining desktop materialization and strict geometry checks. * test(gateway): repair session lifecycle fixtures * test(gateway): align cancellation fixtures with lifecycle cleanup
…#208578) The maintainer approved the turn-scoped Stop cascade on 2026-11-29. ## Problem Pressing Esc in the TUI, Stop on the Wear app, or Stop on a Workboard card without a recorded run stopped the agent's turn, but the subagents that turn had started kept running and spending. These clients send `chat.abort` with only a session key. On main, that call never cancels descendants. Only an exact-run `chat.abort`, `/stop` and `sessions.abort` do. The docs disagreed with each other. `docs/tools/subagents/nesting.md` promised that explicit cancellation cascades through the descendant tree. The RPC pages (`rpc-session-control.md`, `subagents/operations.md`, `control-ui/chat.md`, `session-controller.md`) documented the run-less exception, which #122909 and #133076 kept to limit the blast radius: "broad session cleanup violates sibling ownership". ## What changes A `chat.abort` without a `runId` now cancels the descendants of the runs it actually stops, the same way an exact-run Stop cancels its turn's descendants (#122909). - **Children of the stopped turn:** cancelled. Native harness children are tied to their turn's exec custody, which is captured for every selected run before any parent stops; registry children keep their spawning turn id and are selected after the runs stop. - **Work the call did not stop keeps its children:** a `/btw` side run kept by `preserveSideRuns`, another person's run, a worker run the call does not cancel, and children an earlier, finished turn started. `sessions.abort` and `/stop` still stop all of those. - **A yielded parent or a dormant child:** no turn is running, so a run-less `chat.abort` stops nothing there, as before. `sessions.abort` stops that paused work. - **Invited participants:** a participant may stop only their own runs (#204899). Their Stop, run-less or exact-run, now also cancels those runs' children, and never another member's. Before this change a participant's Stop never cancelled children, even with an exact run id. - **`/stop` and `sessions.abort`** keep their whole-session cascade. When it is blocked (for example, while a hidden run is active), they now stop at least the stopped turns' children instead of none. - **Permissions:** unchanged. Anyone who could stop a run before still can, and the cascade reaches only the descendants of runs that caller stopped. The owner is `abortChatRunsForSessionKeyWithPartials`. For an explicit user Stop (`announceRunStopped`) that is not a whole-session Stop, it captures the exec custody of every run the plan selected, stops the runs, then runs the exact-run descendant cancellation for each run that actually stopped. Native harness children follow their turn's exec custody, which ends when the turn unwinds, so it is captured before any parent stops. Worker-placement reclaim, session drain and queued-input discard do not mark an explicit Stop, so they cancel no descendants. There is no protocol, schema or config change. Docs: the four RPC pages and `nesting.md` now say the same thing. A run-less Stop is turn-scoped; `sessions.abort` and `/stop` are whole-session. ## Evidence Tests at the Gateway handler boundary, with real registry children: - `chat.abort-cascade.test.ts`, "a run-less Stop cancels only the children of the turn it stops": `preserveSideRuns` with a live `/btw`, the stopped turn's child, a child of a worker run the call does not stop, and an earlier turn's child. Only the stopped turn's child is cancelled; the `/btw` is not aborted. **Red on main, green here.** The exact-run case is the control (green on both). - `chat.abort-cascade.test.ts`, invited member, run-less and exact-run: the member's Stop cancels the child of their own turn and leaves the child of another member's turn running. **Red on main for both, green here.** - `chat.abort-cascade.test.ts`, native children: a run-less Stop that stops two live turns cancels the native harness children of both. **Red without the custody capture, green here.** - `chat.abort-cascade.test.ts`, blocked whole-session Stop: with a hidden run active, `sessions.abort`/`/stop` still cancel the stopped turn's child and leave an earlier turn's child running. **Red on main, green here.** - `sessions.abort-yielded.test.ts`: a run-less `chat.abort` on a yielded parent, and on the dormant child itself, stops nothing and leaves the paused child unchanged (control, green on both). - Gateway Stop suites: 28 files, 665 tests, plus the real-Gateway `run_stopped` hook e2e, all green. Live Gateway with a fake provider, main vs this branch, 3 runs each: | Scenario | main | this branch | |---|---|---| | Run-less `chat.abort {sessionKey}` (Wear's exact request, Workboard fallback) with a live child | child keeps running 3/3 | child killed 3/3 | | Exact-run `chat.abort` / typed `/stop` (controls) | child killed 3/3 | child killed 3/3 | | TUI Esc (`preserveSideRuns: true`) with a live `/btw`, a child of the stopped turn and a background child of an earlier turn | stopped turn's child keeps running 3/3; earlier child running; `/btw` reaches final | stopped turn's child killed 3/3; earlier child keeps running; `/btw` reaches final | | Invited send member's run-less Stop, with a child of their turn and a background child of the owner's earlier turn | member's child keeps running 3/3 | member's child killed 3/3; owner's child keeps running | Not benchmark-shaped: the change is in the one Stop owner, with no client, model or provider branches. ## Merge danger Two-way door: a revert fully restores the old behavior. Nothing is written, migrated or published differently, and the RPC schema is unchanged. Blast radius: every client that sends a run-less `chat.abort` (TUI Esc, Wear, the Workboard fallback, Android) now also stops the stopped turn's subagents. A user who presses Esc while a turn waits on `sessions_yield` still has to use `/stop` to end those children. Co-authored-by: Ayaan Zaidi <[email protected]>
…#208578) The maintainer approved the turn-scoped Stop cascade on 2026-11-29. ## Problem Pressing Esc in the TUI, Stop on the Wear app, or Stop on a Workboard card without a recorded run stopped the agent's turn, but the subagents that turn had started kept running and spending. These clients send `chat.abort` with only a session key. On main, that call never cancels descendants. Only an exact-run `chat.abort`, `/stop` and `sessions.abort` do. The docs disagreed with each other. `docs/tools/subagents/nesting.md` promised that explicit cancellation cascades through the descendant tree. The RPC pages (`rpc-session-control.md`, `subagents/operations.md`, `control-ui/chat.md`, `session-controller.md`) documented the run-less exception, which #122909 and #133076 kept to limit the blast radius: "broad session cleanup violates sibling ownership". ## What changes A `chat.abort` without a `runId` now cancels the descendants of the runs it actually stops, the same way an exact-run Stop cancels its turn's descendants (#122909). - **Children of the stopped turn:** cancelled. Native harness children are tied to their turn's exec custody, which is captured for every selected run before any parent stops; registry children keep their spawning turn id and are selected after the runs stop. - **Work the call did not stop keeps its children:** a `/btw` side run kept by `preserveSideRuns`, another person's run, a worker run the call does not cancel, and children an earlier, finished turn started. `sessions.abort` and `/stop` still stop all of those. - **A yielded parent or a dormant child:** no turn is running, so a run-less `chat.abort` stops nothing there, as before. `sessions.abort` stops that paused work. - **Invited participants:** a participant may stop only their own runs (#204899). Their Stop, run-less or exact-run, now also cancels those runs' children, and never another member's. Before this change a participant's Stop never cancelled children, even with an exact run id. - **`/stop` and `sessions.abort`** keep their whole-session cascade. When it is blocked (for example, while a hidden run is active), they now stop at least the stopped turns' children instead of none. - **Permissions:** unchanged. Anyone who could stop a run before still can, and the cascade reaches only the descendants of runs that caller stopped. The owner is `abortChatRunsForSessionKeyWithPartials`. For an explicit user Stop (`announceRunStopped`) that is not a whole-session Stop, it captures the exec custody of every run the plan selected, stops the runs, then runs the exact-run descendant cancellation for each run that actually stopped. Native harness children follow their turn's exec custody, which ends when the turn unwinds, so it is captured before any parent stops. Worker-placement reclaim, session drain and queued-input discard do not mark an explicit Stop, so they cancel no descendants. There is no protocol, schema or config change. Docs: the four RPC pages and `nesting.md` now say the same thing. A run-less Stop is turn-scoped; `sessions.abort` and `/stop` are whole-session. ## Evidence Tests at the Gateway handler boundary, with real registry children: - `chat.abort-cascade.test.ts`, "a run-less Stop cancels only the children of the turn it stops": `preserveSideRuns` with a live `/btw`, the stopped turn's child, a child of a worker run the call does not stop, and an earlier turn's child. Only the stopped turn's child is cancelled; the `/btw` is not aborted. **Red on main, green here.** The exact-run case is the control (green on both). - `chat.abort-cascade.test.ts`, invited member, run-less and exact-run: the member's Stop cancels the child of their own turn and leaves the child of another member's turn running. **Red on main for both, green here.** - `chat.abort-cascade.test.ts`, native children: a run-less Stop that stops two live turns cancels the native harness children of both. **Red without the custody capture, green here.** - `chat.abort-cascade.test.ts`, blocked whole-session Stop: with a hidden run active, `sessions.abort`/`/stop` still cancel the stopped turn's child and leave an earlier turn's child running. **Red on main, green here.** - `sessions.abort-yielded.test.ts`: a run-less `chat.abort` on a yielded parent, and on the dormant child itself, stops nothing and leaves the paused child unchanged (control, green on both). - Gateway Stop suites: 28 files, 665 tests, plus the real-Gateway `run_stopped` hook e2e, all green. Live Gateway with a fake provider, main vs this branch, 3 runs each: | Scenario | main | this branch | |---|---|---| | Run-less `chat.abort {sessionKey}` (Wear's exact request, Workboard fallback) with a live child | child keeps running 3/3 | child killed 3/3 | | Exact-run `chat.abort` / typed `/stop` (controls) | child killed 3/3 | child killed 3/3 | | TUI Esc (`preserveSideRuns: true`) with a live `/btw`, a child of the stopped turn and a background child of an earlier turn | stopped turn's child keeps running 3/3; earlier child running; `/btw` reaches final | stopped turn's child killed 3/3; earlier child keeps running; `/btw` reaches final | | Invited send member's run-less Stop, with a child of their turn and a background child of the owner's earlier turn | member's child keeps running 3/3 | member's child killed 3/3; owner's child keeps running | Not benchmark-shaped: the change is in the one Stop owner, with no client, model or provider branches. ## Merge danger Two-way door: a revert fully restores the old behavior. Nothing is written, migrated or published differently, and the RPC schema is unchanged. Blast radius: every client that sends a run-less `chat.abort` (TUI Esc, Wear, the Workboard fallback, Android) now also stops the stopped turn's subagents. A user who presses Esc while a turn waits on `sessions_yield` still has to use `/stop` to end those children. Co-authored-by: Ayaan Zaidi <[email protected]> (cherry picked from commit 9da8ce6) Release adaptation: keep the stable exact-run owner and use already admitted authorization. Capture direct and native descendants before unwind, deduplicate by canceled turn and cascade only for successful cancellation. Companion audit: search, partial text and digest fixes are independent; TUI stop-all and hint changes are separate behavior. Co-authored-by: RomneyDa <[email protected]>
…#208578) The maintainer approved the turn-scoped Stop cascade on 2026-11-29. ## Problem Pressing Esc in the TUI, Stop on the Wear app, or Stop on a Workboard card without a recorded run stopped the agent's turn, but the subagents that turn had started kept running and spending. These clients send `chat.abort` with only a session key. On main, that call never cancels descendants. Only an exact-run `chat.abort`, `/stop` and `sessions.abort` do. The docs disagreed with each other. `docs/tools/subagents/nesting.md` promised that explicit cancellation cascades through the descendant tree. The RPC pages (`rpc-session-control.md`, `subagents/operations.md`, `control-ui/chat.md`, `session-controller.md`) documented the run-less exception, which #122909 and #133076 kept to limit the blast radius: "broad session cleanup violates sibling ownership". ## What changes A `chat.abort` without a `runId` now cancels the descendants of the runs it actually stops, the same way an exact-run Stop cancels its turn's descendants (#122909). - **Children of the stopped turn:** cancelled. Native harness children are tied to their turn's exec custody, which is captured for every selected run before any parent stops; registry children keep their spawning turn id and are selected after the runs stop. - **Work the call did not stop keeps its children:** a `/btw` side run kept by `preserveSideRuns`, another person's run, a worker run the call does not cancel, and children an earlier, finished turn started. `sessions.abort` and `/stop` still stop all of those. - **A yielded parent or a dormant child:** no turn is running, so a run-less `chat.abort` stops nothing there, as before. `sessions.abort` stops that paused work. - **Invited participants:** a participant may stop only their own runs (#204899). Their Stop, run-less or exact-run, now also cancels those runs' children, and never another member's. Before this change a participant's Stop never cancelled children, even with an exact run id. - **`/stop` and `sessions.abort`** keep their whole-session cascade. When it is blocked (for example, while a hidden run is active), they now stop at least the stopped turns' children instead of none. - **Permissions:** unchanged. Anyone who could stop a run before still can, and the cascade reaches only the descendants of runs that caller stopped. The owner is `abortChatRunsForSessionKeyWithPartials`. For an explicit user Stop (`announceRunStopped`) that is not a whole-session Stop, it captures the exec custody of every run the plan selected, stops the runs, then runs the exact-run descendant cancellation for each run that actually stopped. Native harness children follow their turn's exec custody, which ends when the turn unwinds, so it is captured before any parent stops. Worker-placement reclaim, session drain and queued-input discard do not mark an explicit Stop, so they cancel no descendants. There is no protocol, schema or config change. Docs: the four RPC pages and `nesting.md` now say the same thing. A run-less Stop is turn-scoped; `sessions.abort` and `/stop` are whole-session. ## Evidence Tests at the Gateway handler boundary, with real registry children: - `chat.abort-cascade.test.ts`, "a run-less Stop cancels only the children of the turn it stops": `preserveSideRuns` with a live `/btw`, the stopped turn's child, a child of a worker run the call does not stop, and an earlier turn's child. Only the stopped turn's child is cancelled; the `/btw` is not aborted. **Red on main, green here.** The exact-run case is the control (green on both). - `chat.abort-cascade.test.ts`, invited member, run-less and exact-run: the member's Stop cancels the child of their own turn and leaves the child of another member's turn running. **Red on main for both, green here.** - `chat.abort-cascade.test.ts`, native children: a run-less Stop that stops two live turns cancels the native harness children of both. **Red without the custody capture, green here.** - `chat.abort-cascade.test.ts`, blocked whole-session Stop: with a hidden run active, `sessions.abort`/`/stop` still cancel the stopped turn's child and leave an earlier turn's child running. **Red on main, green here.** - `sessions.abort-yielded.test.ts`: a run-less `chat.abort` on a yielded parent, and on the dormant child itself, stops nothing and leaves the paused child unchanged (control, green on both). - Gateway Stop suites: 28 files, 665 tests, plus the real-Gateway `run_stopped` hook e2e, all green. Live Gateway with a fake provider, main vs this branch, 3 runs each: | Scenario | main | this branch | |---|---|---| | Run-less `chat.abort {sessionKey}` (Wear's exact request, Workboard fallback) with a live child | child keeps running 3/3 | child killed 3/3 | | Exact-run `chat.abort` / typed `/stop` (controls) | child killed 3/3 | child killed 3/3 | | TUI Esc (`preserveSideRuns: true`) with a live `/btw`, a child of the stopped turn and a background child of an earlier turn | stopped turn's child keeps running 3/3; earlier child running; `/btw` reaches final | stopped turn's child killed 3/3; earlier child keeps running; `/btw` reaches final | | Invited send member's run-less Stop, with a child of their turn and a background child of the owner's earlier turn | member's child keeps running 3/3 | member's child killed 3/3; owner's child keeps running | Not benchmark-shaped: the change is in the one Stop owner, with no client, model or provider branches. ## Merge danger Two-way door: a revert fully restores the old behavior. Nothing is written, migrated or published differently, and the RPC schema is unchanged. Blast radius: every client that sends a run-less `chat.abort` (TUI Esc, Wear, the Workboard fallback, Android) now also stops the stopped turn's subagents. A user who presses Esc while a turn waits on `sessions_yield` still has to use `/stop` to end those children. Co-authored-by: Ayaan Zaidi <[email protected]> (cherry picked from commit 9da8ce6) Release adaptation: Use the existing Gateway descendant cancellation owner and candidate Stop admission, capture custody before cancellation and cascade only for recorded stopped runs. Do not import the main-only extracted owners or parent-notice feature. Split the new turn-scoped regressions into a sibling test to keep the existing suite below its line cap. Co-authored-by: RomneyDa <[email protected]>
…openclaw#208578) The maintainer approved the turn-scoped Stop cascade on 2026-11-29. ## Problem Pressing Esc in the TUI, Stop on the Wear app, or Stop on a Workboard card without a recorded run stopped the agent's turn, but the subagents that turn had started kept running and spending. These clients send `chat.abort` with only a session key. On main, that call never cancels descendants. Only an exact-run `chat.abort`, `/stop` and `sessions.abort` do. The docs disagreed with each other. `docs/tools/subagents/nesting.md` promised that explicit cancellation cascades through the descendant tree. The RPC pages (`rpc-session-control.md`, `subagents/operations.md`, `control-ui/chat.md`, `session-controller.md`) documented the run-less exception, which openclaw#122909 and openclaw#133076 kept to limit the blast radius: "broad session cleanup violates sibling ownership". ## What changes A `chat.abort` without a `runId` now cancels the descendants of the runs it actually stops, the same way an exact-run Stop cancels its turn's descendants (openclaw#122909). - **Children of the stopped turn:** cancelled. Native harness children are tied to their turn's exec custody, which is captured for every selected run before any parent stops; registry children keep their spawning turn id and are selected after the runs stop. - **Work the call did not stop keeps its children:** a `/btw` side run kept by `preserveSideRuns`, another person's run, a worker run the call does not cancel, and children an earlier, finished turn started. `sessions.abort` and `/stop` still stop all of those. - **A yielded parent or a dormant child:** no turn is running, so a run-less `chat.abort` stops nothing there, as before. `sessions.abort` stops that paused work. - **Invited participants:** a participant may stop only their own runs (openclaw#204899). Their Stop, run-less or exact-run, now also cancels those runs' children, and never another member's. Before this change a participant's Stop never cancelled children, even with an exact run id. - **`/stop` and `sessions.abort`** keep their whole-session cascade. When it is blocked (for example, while a hidden run is active), they now stop at least the stopped turns' children instead of none. - **Permissions:** unchanged. Anyone who could stop a run before still can, and the cascade reaches only the descendants of runs that caller stopped. The owner is `abortChatRunsForSessionKeyWithPartials`. For an explicit user Stop (`announceRunStopped`) that is not a whole-session Stop, it captures the exec custody of every run the plan selected, stops the runs, then runs the exact-run descendant cancellation for each run that actually stopped. Native harness children follow their turn's exec custody, which ends when the turn unwinds, so it is captured before any parent stops. Worker-placement reclaim, session drain and queued-input discard do not mark an explicit Stop, so they cancel no descendants. There is no protocol, schema or config change. Docs: the four RPC pages and `nesting.md` now say the same thing. A run-less Stop is turn-scoped; `sessions.abort` and `/stop` are whole-session. ## Evidence Tests at the Gateway handler boundary, with real registry children: - `chat.abort-cascade.test.ts`, "a run-less Stop cancels only the children of the turn it stops": `preserveSideRuns` with a live `/btw`, the stopped turn's child, a child of a worker run the call does not stop, and an earlier turn's child. Only the stopped turn's child is cancelled; the `/btw` is not aborted. **Red on main, green here.** The exact-run case is the control (green on both). - `chat.abort-cascade.test.ts`, invited member, run-less and exact-run: the member's Stop cancels the child of their own turn and leaves the child of another member's turn running. **Red on main for both, green here.** - `chat.abort-cascade.test.ts`, native children: a run-less Stop that stops two live turns cancels the native harness children of both. **Red without the custody capture, green here.** - `chat.abort-cascade.test.ts`, blocked whole-session Stop: with a hidden run active, `sessions.abort`/`/stop` still cancel the stopped turn's child and leave an earlier turn's child running. **Red on main, green here.** - `sessions.abort-yielded.test.ts`: a run-less `chat.abort` on a yielded parent, and on the dormant child itself, stops nothing and leaves the paused child unchanged (control, green on both). - Gateway Stop suites: 28 files, 665 tests, plus the real-Gateway `run_stopped` hook e2e, all green. Live Gateway with a fake provider, main vs this branch, 3 runs each: | Scenario | main | this branch | |---|---|---| | Run-less `chat.abort {sessionKey}` (Wear's exact request, Workboard fallback) with a live child | child keeps running 3/3 | child killed 3/3 | | Exact-run `chat.abort` / typed `/stop` (controls) | child killed 3/3 | child killed 3/3 | | TUI Esc (`preserveSideRuns: true`) with a live `/btw`, a child of the stopped turn and a background child of an earlier turn | stopped turn's child keeps running 3/3; earlier child running; `/btw` reaches final | stopped turn's child killed 3/3; earlier child keeps running; `/btw` reaches final | | Invited send member's run-less Stop, with a child of their turn and a background child of the owner's earlier turn | member's child keeps running 3/3 | member's child killed 3/3; owner's child keeps running | Not benchmark-shaped: the change is in the one Stop owner, with no client, model or provider branches. ## Merge danger Two-way door: a revert fully restores the old behavior. Nothing is written, migrated or published differently, and the RPC schema is unchanged. Blast radius: every client that sends a run-less `chat.abort` (TUI Esc, Wear, the Workboard fallback, Android) now also stops the stopped turn's subagents. A user who presses Esc while a turn waits on `sessions_yield` still has to use `/stop` to end those children. Co-authored-by: Ayaan Zaidi <[email protected]>


Closes #131553 — stopping an exact parent leaves Swarm collectors running or queued.
What Problem This Solves
Stopping a parent turn could report success while its Swarm collectors kept running or remained eligible to start. An association-only repair was insufficient: the follow-up live reproduction caught the previously queued collector entering admission after parent cancellation.
Real UI testing then exposed a connected ownership gap: a queued collector did not retain its accepted label, was omitted from the Swarm count, and displayed an execution clock before it started. Making that work correctly visible exposed the ordinary child-chat Stop path, which previously missed the selected queued collector itself.
Why This Change Was Made
Registration preserves the spawning turn independently of announcement policy. The existing cancellation owner captures its exact tree and holds queued reservations before signals can release capacity. Its lexical authority follows only committed recovery receipts, rejects ordinary replacements, retains captured descendants through legitimate retirement, and remains held through synchronous result publication. Gateway, task, tool, and channel callers reuse that owner rather than rediscover descendants after asynchronous work.
The current follow-through binds visible queued work to its exact registry object and scheduler reservation, persists labels at creation, and removes delayed label rewriting and creation-time-as-execution-time fallback. Direct queued-child Stop uses the existing kill owner and shared Gateway cancellation plan, including real native preaccept and coexisting chat admissions. It preserves requester ownership and foreign work, keeps canonical abort markers and the original Stop reason, and reports incomplete cancellation when the selected collector remains queued. Already-aborted ordinary chat output is finalized even if a later collector ownership check rejects the operation.
Transcript snapshots and persistence now live in the existing transcript owner; placement uses a lazy transcript boundary instead of importing the cancellation orchestrator. The first-turn admission owner still shares its prepared canonical session binding with the controller, recorder, and queued adoption. Native and ACP cancellation begin without waiting on the other backend and are joined through exceptional exits.
Scope decision: retain this lexical cancellation owner as the canonical boundary. An association-only change demonstrably permits queued admission during Stop; broad session cleanup violates sibling ownership; fresh lookups cannot distinguish committed recovery from ordinary replacement. Queued work needs truthful visibility and cancellation without inventing executable authority. This is the intended owner-level repair, not a second cancellation engine.
No new config/environment option, protocol version, database schema, persistent field, or durable sidecar. Selecting existing
execution.statusinto a compact read DTO is not a schema/store-format change. The automated stored-data warning names test-support fixtures, not a production migration. The focused native requester-ownership repair remains intact.User Impact
Parent Stop cancels its selected collectors without admitting an already queued child. Queued collectors appear with their supplied labels and queued state, without a fabricated start clock; an operator rename survives delayed launch. The normal queued-child Stop action cancels that child without cancelling its parent or running sibling.
SDK
Run.cancel(), exactchat.abort, typed/stop, controllerless native Stop, task cancellation, and channel Stop retain their intended scopes. Foreign/protected work and ordinary replacements remain untouched. Normal completion, yield, and timeout do not implicitly cancel accepted children. Ordinary no-runchat.abortremains non-cascading; explicit full-session Stop can handle orphans. Acknowledgment does not promise instantaneous runtime cleanup, and incomplete cancellation returns an error rather than success.Evidence
Current committed candidate
13aaeb30632302d7851878ab56a0d4a7b7d32682. Current-head CI and successful UI Stop/video proof are pending; neither earlier CI nor earlier live runs are presented as proof of this new head.The current candidate passed 157 focused tests across ten files, the changed formatting/type/lint/guard gate, and the full architecture gate (zero runtime and zero type-inclusive cycles). These include actual ordinary and native preaccept admissions, mixed requester ownership, transcript persistence/incarnation fences, cascade ordering, and worker abandonment. The preceding queued-owner candidate also passed 245 boundary and 915 sibling test executions; those broader runs are retained as earlier evidence, not claimed rerun after the two final outcome repairs.
A fresh five-pass managed Codex review covered the entire incremental candidate plus 70 complete source/context files and returned no actionable P0–P2 findings. The large UI source was partitioned losslessly; no source bytes were omitted, and reviewer isolation/secret scanning stayed enabled. Review was static; tests and live evidence are separate. Two findings from the preceding review were independently reproduced and repaired: lost captured output after parent retirement, and misleading queued-Stop success with mixed ordinary chat owners. The proposed distinct-ID hidden-agent witness was rejected by the real collector preflight; the regression uses supported ordinary admissions instead.
The full runtime/UI build passed in 202.87 s, the public SDK build in 1.36 s, and both built SDK entrypoints imported on Node 24.20.0 without creating a client or making a network request. The build metadata names this exact commit. Source, 14,632 runtime/SDK artifacts, and the actual eight-package SDK dependency closure were sealed. No ineffective-dynamic-import diagnostic was emitted.
Current-head real-provider proof
An isolated loopback Gateway used native OpenClaw Code Mode, OpenAI
gpt-5.6-luna, concurrency one per group, two collectors, and no channels. The original non-admin admitting connection cancelled only the selected queued child in 39.89 ms. Three foreign-requester controls were refused, including the child-session Stop. At acknowledgment the selected child was cancelled with no start timestamp and an empty transcript, while its sibling was still executing. The sibling completed naturally and the parent was not aborted; all three sessions were then idle. Natural settlement took 21.26 s after acknowledgment—this is the separate untouched-sibling phase, not a relaxed parent-cancellation deadline. Zero rescue mutations and zero connection faults; independent health reads passed 38/38, maximum 110.21 ms.The concurrent fresh-profile UI trial was rejected before Stop by the exact-program guard: the generated program omitted the 20-character
run shell commands,phrase from one duplicated child instruction. The failed trial is not counted as cancellation proof. Its parent and both children were independently observed naturally settled, with no cleanup mutation or source change. A workspace-icon resource error is being checked against the documented optional-icon/folder-fallback contract, rather than blanket-ignored. The next UI attempt retains exact-program, ownership, queue, and terminal checks.UI CI reconciliation and size
Main independently added attachment row materialization and layout settling. The candidate uses main's mobile block verbatim plus one desktop materialization step; every strict geometry assertion is unchanged. That exact test passed 111/111 and a default three-way merge against pinned main produced byte-identical output. No production UI/CSS changed. The earlier alternative that still conflicted is retained as a failed merge experiment, not claimed successful.
Whole-feature judged LOC: production +2003/-1106 (net +897); tests/support +9068/-1012 (net +8056); docs +49/-6 (net +43). The latest increment is production +581/-165 (net +416), tests/support +1218/-30 (net +1188). Pure helper moves do not represent new capability. Remaining growth provides the previously missing queued-work authority/projection/Stop boundary and its failure reporting; it removes delayed label mutation, fake start-time fallback, duplicated traversal/publication decisions, and duplicated prepared-session bookkeeping. No checker, baseline, timeout, or assertion was weakened.
Remaining proof: successful real UI parent and child Stop recordings, additional current-head parent cancellation/stress runs, exact-head CI, and native prepare/merge. The timer scenario does not claim live buffered-partial production; that boundary has full-dispatch SSE and real ordinary-admission regressions. A named follow-up will align the existing progress-widget docs with Control UI cards/task lists versus native marker grids.
Earlier candidate evidence and exact cohort commands (historical, not current-head proof)
The following evidence describes f6ff8c9 and earlier candidates. The current head, new repairs, current proof, and remaining gates are stated above.
Earlier candidate:
f6ff8c9beee8e1af10f9014a0c23e3badce2bf49, based on65beb1e9b1124d1a0f1302fa880bc028d74586cb. The last commit changes only the responsive attachment test; runtime source is byte-identical to the live-testedd8f21c9a4dd79832065783ffea1389f3ce04401f. The rebase resolved a moved resolver import, its test mock, and an obsolete test-shard rebalance without changing cancellation behavior. Rebase proof passed runtime/SDK builds, the full changed gate, canonical shard validation, 70 selected files / 1,788 test executions, and a six-chunk managed integration review. The extra tests cover newer main's accepted-input custody, human-input recovery waits, Gateway response handling, tool metadata, and compaction cancellation.CI repair: run 33294932324 exposed a type-inclusive import cycle: the task-control type leaf imported its own runtime barrel. The three-file repair makes that existing leaf own the shared cancellation contract and has no executable behavior change. Madge reproduced RED before the fix; the full architecture gate now reports zero runtime and zero type-inclusive cycles. Core/core-test typechecks, 295 cancellation tests in seven files, lint/format, fresh runtime/SDK builds, the full changed gate, and a fresh managed review all passed. No checker, baseline, or ignore was weakened. Earlier-head CI passed the topology gate but exposed a separate mixed-attachment responsive-layout test failure (status-reason right edge 539 > 320). Read-only native resize instrumentation captured mobile CSS while the shell still reserved its 258-pixel desktop sidebar: the reason's right edge was 549 before the responsive owner committed and 291 afterward. The unmodified full file and exact shard pass naturally on this Mac; the diagnostic is event-boundary evidence, not a claim of a spontaneous local reproduction of CI's later query. The test-only readiness/materialization repair is now committed in
f6ff8c9beee8e1af10f9014a0c23e3badce2bf49: it waits for committed responsive state and makes the target row visible before measuring, with every strict assertion unchanged. The full file passed 111/111 tests; the retained 264-file CI selection passed 256 files / 3,920 tests, with eight files / 40 tests skipped on this Mac. Scoped checks passed, and an independent two-pass managed review returned no actionable P0–P2 finding. Production delta is zero; test delta is +28/-21 (net +7). Fresh CI run 33302870668 completed successfully on this exact test-only head; the prior failed run is retained as before-proof.Earlier runtime authority-chain proof: two concurrent real-provider trials on the rebuilt
d8f21c9a4dd79832065783ffea1389f3ce04401fsource passed: agent admission/public SDK cancellation (672 ms ACK; all three sessions idle 14.76 s after ACK), and first-turn chat/exactchat.abort(966 ms; 14.90 s). Each first observed the running child's actual native timer and one queued collector, refused both foreign-requester cancellation methods while the parent remained active, then accepted cancellation from the admitting connection. Both selected task records remained cancelled; the queued child'sstartedAtremained absent and transcript empty. Zero rescue mutations or connection faults. Independent health observers passed 66/66 requests (maximum 253 ms). Source and 14,630 runtime/SDK artifacts were sealed; the build was made from the reviewed index before committing, so its embedded Git metadata names the preceding commit, while exact source hashes bind the tested bytes to the d8f21c9 source. The previous-head refresh also passed two concurrent trials (68/68 health reads). Initial pre-hello connection failures are retained separately; they admitted no turns, and their cause remains unestablished. Real UI Stop/video proof remains in progress.Real-provider after-proof: isolated loopback Gateway, Node 24.20.0, OpenClaw native Code Mode, OpenAI
gpt-5.6-luna, Swarm concurrency 1 per group, two collectors per parent, no channels. Each successful trial observed the actual authored parent program and the running child's 30-second native timer before Stop. The same admitting non-admin connection issued cancellation; two foreign abort methods were refused while the parent remained active.Run.cancel()chat.send/ SDK/stopchat.abortchat.abortAll six trials retained both selected collector tasks as cancelled at acknowledgment. Every originally queued collector still had no
startedAtand a complete empty transcript; all three sessions became idle inside the unchanged 20-second observation window. Retained parent outcomes carried the correct cancellation reason. Chat trials also matched the native start, explicit Stop receipt, native terminal, and persisted parent row to the same canonical session ID. Zero rescue mutations and zero connection faults in every passing trial.The two stress parents overlapped for approximately 16 seconds and issued cancellation 1 ms apart. Both independent read-only health observers passed 33/33 calls; maximum observed latency was 144 ms. This is bounded two-parent/four-collector stress, not an exhaustive load benchmark.
Earlier failed trials remain recorded, not counted as successes: one private probe incorrectly required the intentionally hidden
sessions.resolvemethod in hello discovery; three stopped before collector registration because the unfenced authored prompt let the model copy trailing prose into JavaScript. The exact malformed argument matched the program plus that instruction suffix. The probe was corrected against the descriptor/docs contract and given clearly fenced code blocks, without weakening exact-program, ownership, queue, or terminal assertions. All 103 private offline checks passed afterward. Those failed parents were separately observed idle with no child tasks and no cleanup mutation.Deterministic regression proof: 59 selected test files, five sequential cohorts, 1,595 successful test executions (including shared Gateway suites executed in multiple projects), zero failures. Original failure ordering was retained for the control, registry, Gateway lifecycle, and abort cohorts; normal isolation/cache were unchanged. Coverage includes reservation/preactivation races, partial selection failure, post-await publication, same-object completion, ordinary supersession, accepted recovery followed by retirement, stale spawn authority, declined parent Stop, aliases, ACP initiation/error ordering, original-incarnation persistence, archive/delete siblings, and full WebSocket first-turn session binding. The first-turn test uses the actual Gateway/native flow with only provider output supplied by a loopback SSE fixture.
Passed commands:
The test cohorts used
node scripts/run-vitest.mjswithOPENCLAW_VITEST_MAX_WORKERS=1; detailed selections are below. Source remained unchanged through every gate and live trial. Runtime/SDK artifacts were fingerprinted, including the actual installed SDK dependency closure; both built public entrypoints imported successfully on Node 24.Earlier independent review: six managed Codex source views, 26 complete chunks, covering the entire candidate plus complete relevant owner/caller source; zero actionable P0–P2 findings. Reviewer isolation and secret scanning were preserved. Review was static; the runtime evidence above is separate.
Earlier size and best-fix judgment: production +1514/-1033 (net+481); tests/support +7899/-1031 (net +6868); no test-configuration delta; docs +43. The incremental CI fix adds four net erased-type/import-formatting lines, not runtime logic. The growth buys the previously missing lexical cancellation ownership boundary and irreversible supersession/retirement observation—not a second cancellation implementation. Duplicate caller traversal, stale result re-projection, and duplicated prepared-session bookkeeping are removed or absorbed. An association-only change demonstrably admits queued work during cancellation; broad session cancellation violates sibling ownership; fresh run/session lookups cannot distinguish accepted recovery from ordinary replacement. The scoped owner is the canonical repair.
Earlier proof limits: Control UI video is pending. Current project guidance explicitly permits isolated development browsers, so the recording uses a fresh profile in verified signed Chrome, without touching the signed-in profile, browser registration, or operator Gateway. Its first attempt failed before any turn because isolated HOME hid the existing Playwright video executable; a credential-free reproduction identified the missing path, and the runner now points to the already-installed matching video runtime. The next real UI attempt reached the running/queued pair, but the progress card counted only one collector and the queued sidebar row lacked its accepted label/status. It failed before Stop; all three sessions were independently observed naturally settled with zero rescue mutation. That visibility discrepancy is under investigation, and no successful UI Stop/media proof is claimed yet. The timer scenario does not claim live buffered-partial production; that boundary is covered by the full-dispatch SSE regression. The automated stored-data warning names test-support fixtures, not a production schema/store-format change; this repair adds no persistent field or schema migration. A named follow-up will align the existing progress-widget docs with the Control UI's cards/task list versus native status-marker grids.
Exact selected test cohorts
Task-local sequencers preserved original failure order in the first four cohorts; they changed ordering only, not isolation, cache, environment, assertions, or timeouts.
Post-rebase neighboring-owner cohort: