Repository navigation
[ENG-16829] fix(agents): stopped sub-agents restart or keep running after /stop - #276
Merged
Merged
Conversation
A user stop on a session with sub-agents left the parent model with wrong or missing facts, and some work outlived the stop: - A late end event of the killed child run replaced the kill with a timeout. `subagents list` then showed the child as timed out, and the parent model restarted the work on its own. - The parent model was not told which sub-agents the user stopped. The one-shot "previous run was aborted" note was also lost when the parent run reported its own aborted end after the stop, because that end was recorded as failed and cleared the flag. - A child run that was stopped before it became active still sent its first model request and ran its task. - In service mode, exec shells share the gateway's process group, so the kill reached only the shell. Its child processes survived. Keep a user kill in the sub-agent registry when a later timeout or error end of the same run arrives. A successful end still wins, as before. List killed runs as `killed`. On /stop and the abort words, queue one system event for the parent session that names the stopped sub-agents and says not to restart them. Reset does not queue it. Before the prompt is sent, end a sub-agent attempt whose registry record is already killed, without a model request. Keep the session abort flag when the stopped run's own end arrives with aborted set. Sub-agent sessions and runs matched by a restart marker keep the old rule, because restart and orphan recovery read the same flag. On Linux, when the exec shell is not a process group leader, signal its descendants found through /proc before the shell. The gateway, its parent and init are never signaled. Related: ENG-16829
There was a problem hiding this comment.
All reported issues were addressed across 19 files
Reply with feedback, questions, or to request a fix.
View guided diff | Turn on auto-fix | Re-trigger cubic
The new process-tree tests could leave a `sleep 300` running or fail by chance: - The teardown killed only the recorded shell when the `sleep` pid lookup timed out, so the shell's `sleep 300` child kept running. - The mocked /proc fixtures used fixed pids. When one matched the test process or its parent, the kill path skipped it on purpose and the assertion failed. - The Linux test needed bash. Kill matching descendants before the shell on teardown, pick fixture pids outside the range of the test process and its parent, and run the shell with sh. Related: ENG-16829
ikhsanuddin
approved these changes
Oct 10, 2026
orswn
added a commit
that referenced
this pull request
Oct 10, 2026
…e-boon5 Bring in #276 (ENG-16829) for the 2026.6.34-boon.5 release. It changes no versioned manifest.
orswn
added a commit
that referenced
this pull request
Oct 10, 2026
#276 (ENG-16829) merged into boon after the release bump. Add its entry: a sub-agent stopped by /stop stays killed, the parent session gets one note that names the stopped sub-agents, and stopping a service-mode exec shell on Linux also signals its descendants.
1 task done
orswn
added a commit
that referenced
this pull request
Oct 10, 2026
…-> 2026.6.34-boon.5 (#277) Cut the fork release that ships the two commits on boon since v2026.6.34-boon.4. The bundled boon-pdf-prep plugin queues inbound PDFs for background text preparation and adds a short preparation note to the model input, and cut attachment text now says where it stops (#273, ENG-21106). A sub-agent stopped by /stop stays killed, and stopping a service-mode exec shell on Linux also signals its descendants (#276, ENG-16829). Bump root package.json and npm-shrinkwrap.json, all 136 plugin manifests, and the version and openclaw peer floor in every extension npm-shrinkwrap.json. Add the 2026.6.34-boon.5 CHANGELOG.md section and the generated extensions/matrix/CHANGELOG.md entry. No dependency changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Related: ENG-16829, follows #272
What Problem This Solves
Fixes an issue where a user who stops a run that has sub-agents would see the agent keep or restart the stopped work:
sleep 300 && echo doneleftsleep 300running after the stop.This affects the Boon Web Stop button and
/stopor "stop" on Slack and Teams.Why This Change Was Made
The stop already ended the parent run, its sub-agents and their exec processes. The remaining gaps were in what OpenClaw records after the stop and in two race windows:
subagents listshowskilledfor these runs./stopand the abort words, OpenClaw queues one system event for the parent session: which sub-agents the user stopped, that they will not report back, and not to restart them unless the user asks. The next turn of that session reads it. Reset does not queue it./proc. The gateway, its parent and init are never signaled. Detached mode and other platforms are unchanged.Not changed: ACP children, the generic case of a stop that lands before a non-sub-agent run sends its prompt, and processes that the agent detached itself (
nohup … &).User Impact
/stopand "stop".Evidence
Focused tests on the final tree: abort and stop commands, the sub-agent registry, list, control and orphan recovery, the embedded attempt abort and the new pre-prompt gate, kill-tree, the process supervisor, system events, session lifecycle state and the server-chat agent events.
Each new test fails without its fix. Without the abort-flag condition, 8 session lifecycle tests fail.
The
finalAttempt=falsecase above is intermittent. It failed in 3 of about 19 runs of these files on this branch and in none of 8 runs on the base commit. It passed in the other runs, including a one-worker run of that file with the new service-mode test in both orders. The test file and the announce cleanup path it calls are not changed here.Channel suites, run against this change:
channel.actions.test.ts > exposes pinnedMessageId in the tool schemafails the same way on the base commit.src/auto-reply/replyas one directory run fails on the base commit and on this branch, with a different set of failures each run, because the files share module state. Every file that failed only on this branch passes on its own, on both trees.Local end-to-end run: Boon Web and a local gateway built from this change, Claude Opus 4.8 at medium thinking. The build was made before the last change, which keeps the old abort-flag rule for sub-agent sessions. That change is covered by the session lifecycle tests.
subagents listshowskilled. The agent says the sub-agent is no longer running and does not restart it.sleep 60 && echo, two sub-agents onsleep 300. Stop, then "status?" (run twice)sleepprocesses are gone within 1 s. In the first run the parent's own aborted end arrived 2 s after the stop, and the abort flag stayed set until the next turn read it. The next prompt has the abort note and names both stopped sub-agents. Both runs stay killed.sleep 300 && echo donesleep 300is gone within 1 s. Without the service marker (detached shell) it is also gone within 1 s.subagents listshowsdone.After Stop on an idle parent, the agent reports the stopped sub-agent as killed and does not restart it. Work Status shows the row as Stopped.
After Stop on a parent with a foreground command and two sub-agents, the agent reports all three as stopped.
Not tested: a live Slack or Teams workspace.
Known limits
Summary by cubic
Fixes user stops on runs with sub-agents so stopped work no longer restarts or keeps running, and adds a real-process Linux test cleanup so the new process-tree tests do not leak or flake.
subagents listshowskilled./proc, so commands likesleep 300 && echo donestop fully in service mode. The gateway, its parent, and init are never signaled.Refactors
sleepdescendants first,/procfixture pids avoid the test process and its parent, and the Linux test runs withshinstead of bash.Written for commit 72ec8dc. Summary will update on new commits.