Repository navigation
fix(subagents): notify the parent agent when Stop cancels sub-agents - #205641
Merged
Merged
Conversation
Contributor
|
🦞👀 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. |
Contributor
|
Codex review: stale review; fresh review needed. Summary Next step Review history (1 earlier review cycle)
|
This was referenced Nov 27, 2026
Preserve the subagent runtime cancellation owner and opt into the existing notice only from explicit Stop adapters. Access-loss cancellation retains its own notification behavior.
vyctorbrzezowski
marked this pull request as ready for review
November 29, 2026 17:22
tideclaw-bot
pushed a commit
that referenced
this pull request
Nov 30, 2026
…205641) * fix(gateway): tell the requester which sub-agents a Stop cancelled * fix(subagents): share the Stop notice with chat /stop * fix(subagents): clarify the Stop notice * test(gateway): match the clarified Stop notice * fix(subagents): match the Stop notice to reviewed wording (cherry picked from commit 50016b3) Release adaptation: Keep the beta Gateway cancellation owner and its existing authority fences; only explicit Stop entry points opt into a notice after cancellation settles. Co-authored-by: RomneyDa <[email protected]>
github-actions Bot
pushed a commit
to Desicool/openclaw
that referenced
this pull request
Nov 30, 2026
…penclaw#205641) * fix(gateway): tell the requester which sub-agents a Stop cancelled * fix(subagents): share the Stop notice with chat /stop * fix(subagents): clarify the Stop notice * test(gateway): match the clarified Stop notice * fix(subagents): match the Stop notice to reviewed wording
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.
What Problem This Solves
When a person presses Stop in the Control UI (or the macOS app that hosts it) while the agent itself is idle but its sub-agents are still working, the app sends a session-wide
sessions.abort. That Stop also cancels every running sub-agent of the session, which is the documented behavior. But canceled children never deliver a completion, and nothing else tells the parent agent what happened, so the agent keeps waiting for results that will never come, or later sees only bare process-exit failures. An orchestrator running several long sub-agents loses hours of work with no trace of why.Why This Change Was Made
Stop keeps its current meaning; the defect is the silence. Every explicit Stop that cancels sub-agents now queues one system notice for the parent session. It names the canceled sub-agents, says the Stop was deliberate and what kind it was, and tells the agent not to restart the work unless the user asks:
For a single sub-agent the sentence is singular ("It won't report back. Check its session…"). Empty labels are skipped, and names beyond the first ten are counted ("slow-a and 2 more").
src/agents/subagents/registry/subagent-stop-notice.tsbuilds the notice and enqueues it through the existing system-event owner (enqueueSystemEvent). Zero kills queue nothing; labels are normalized, empty ones dropped, and at most 10 are named.abortControlledSubagents, calls it once per request after the cascade settles, when the caller passes an explicitstopSource: session-widesessions.abort(client-session, "An explicit session Stop from a connected app"), exact-runchat.abort/sessions.abort(client-run, "An explicit Stop of your turn"). An exact-runsessions.aborteither stops an embedded run directly or forwards to thechat.aborthandler; both paths passclient-run. A session-widesessions.abortthat lands on an active embedded run takes the same turn-scoped path, so its notice reads as a Stop of that turn./stop(stopSubagentsForRequester) uses the same helper (channel-user, "A user /stop command"). It already replied "Stopped N sub-agents" to the person; now the agent learns it too.docs/tools/subagents/operations.md("Stopping").No protocol, schema or config change. Which sub-agents a Stop selects is unchanged.
User Impact
After an explicit Stop, the parent agent's next turn says which sub-agents were canceled and by what kind of Stop, so it stops waiting for them, can inspect their sessions, and does not restart work a person just stopped. Non-explicit cancellations (shutdown, timeouts) are unchanged.
Not in this PR: whether the Control UI should offer a session-wide Stop (or map Escape to it) when only sub-agents are running. That is a product decision and is left for a follow-up.
Evidence
src/gateway/server-methods/chat.abort-cascade.test.ts"tells the requester's next turn which children a session/exact run Stop canceled" — red on the base, green with the fix.src/agents/subagents/registry/subagent-stop-notice.test.tscovers the singular sentence, an empty label, one name with more remaining, and two names with more remaining.chat.abort*,sessions.abort*,agent.abort*suites insrc/gateway/server-methodsplussubagent-control.test.tsand the auto-reply abort tests pass (32 files on the final head). oxlint and oxfmt clean on touched files;git diff --checkclean.openai/gpt-6.1-solthrough the Codex runtime): the parent spawns two sub-agents that runsleep 900, ends its turn, then the script sends exactly what the Control UI Stop sends when no local run id is known:sessions.abort {key, clearQueued: true, userInitiated: true}. Both runs: the sub-agents are killed and their processes are gone. Then the parent is asked whether its sub-agents are still running.origin/main, P0 and P2 thresholds: no findings (the reviewer saw the diff only). I checked by hand that the twosessions.abortbranches are exclusive, so one request queues one notice.🦞 Made with OpenClaw