Repository navigation
fix: drain native subagent commands on parent stop - #166832
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. Reviewed October 8, 2026, 2:23 AM ET / 06:23 UTC (Revision 5). ClawSweeper reviewWhat this changesParent Stop drains ordinary commands owned by selected native subagents, including completed and routed children, while preserving completed results and independent background services. Example: The user stops a parent after its native child finishes its model reply.
Review scores
ProductKind: Bug fix · Worth it: Yes Merge readiness✅ Ready for maintainer review This PR remains useful: current main does not drain commands retained by completed native children. The prior conflict blocker is resolved, the supplied behavior proof supports the repair, and no actionable patch defect was found. Priority: P2 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherNative subagents perform delegated work and can leave shell commands running after their model replies finish. The cancellation owner receives authorized Stop requests, selects the owned child tree, and reports model cancellation and physical command cleanup separately. flowchart TD
A[Parent Stop request] --> B[Current caller and session authority]
B --> C[Capture original request ownership]
C --> D[Select native child tree]
D --> E[Cancel ordinary commands]
E --> F[Join physical cleanup]
F --> G[Report cancellation or cleanup failure]
D --> H[Preserve completed results and independent services]
Technical reviewBest possible solution: Keep native descendant cleanup within the existing cancellation owner, using captured request custody and current generation checks while preserving completed receipts and explicit background services. Do we have a high-confidence way to reproduce the issue? Yes: current-main source omits completed children retaining ordinary commands, and the supplied real-Gateway comparison demonstrates that failure. This read-only review did not execute a reproduction. Is this the best way to solve the issue? Yes: the patch extends the existing native cancellation and request-ownership contracts, with final-effect controls for foreign callers, replacement generations, revocation, and later human work. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 2b988ee83444. Provenance checked
TestingProof path: shipped entry point. Added test files: 12. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +729, Tests +1964, Docs +12. Total +2705 across 35 files. View PR surface stats
Review metrics
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 HistoryReview history (4 earlier review cycles)
|
17f964a to
5323982
Compare
d8a6537 to
4b9d1ca
Compare
9945186 to
71e3277
Compare
4b9d1ca to
0358bd3
Compare
|
Fixed: parent Stop drains selected native subagent commands while preserving completed results and independent services. |
Parent Stop drains ordinary commands from selected native subagents, including completed and routed children, while preserving completed results and independent services. Refs openclaw#160742.
…166832 et al.) Conflicts: spawn-pipeline + subagent-spawn + run-launch (openclaw#166832 exec-request owners ride our ownership-checked registration and acceptance hold), queue types (upstream retired skillWorkshopProposalRevision; ours kept), plugin-sdk surface budget 3641 upstream + 11 feature = 3652 (measured), generated inventory/config baseline regenerated. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Jhynq2GVpzuVQQieebEubg
What Problem This Solves
A parent Stop could leave an ordinary command running after its native subagent completed its model response. Active child cancellation could also lose a command-cleanup failure and report success without confirming termination. Children started by a continuation routed into another session were absent from the original request's selection, including after heartbeat consumed the completion notification.
An awaited channel-binding lookup exposed another selection race: selecting children afterward could include later human work, while merely freezing the earlier list missed a child accepted by the original request during that lookup.
User Impact
Parent Stop drains ordinary commands belonging to its selected native child tree, including completed children and nested descendants. Session Stop and channel
/stopcan select that request's bound native children after the continuation and notification finish. Children accepted by the captured original request during Stop preparation join the same cancellation scope; later human work stays outside it.Completed child results stay completed, and command-only cleanup adds no canceled model runs. Explicit
background: trueservices, unrelated work, replacement generations, current caller authority, administrative-root behavior and managed-worker behavior are preserved. Historical exact-run requests remain inactive after their original active, process and event ownership has ended. No configuration, protocol or storage migration is introduced.Related: #160742. This is the native descendant contribution and depends on the command and continuation cancellation contracts in #166764 and #166775.
Why This Change Was Made
The native kill owner captures ordinary command ownership before awaited checks and observes the same native runtime again before signaling it. This covers commands and request owners created after selection. Accepted cleanup is joined on every exit, including caller revocation, replacement and process-output eviction. A committed model-kill result is recorded before later command checks can fail, preserving truthful counts while fencing further effects after an ownership failure.
Successful native registration binds the runtime to the actual original request owner. Exact-run selection requires current request custody; fresh session selection can use the retained binding under the original session's current authority and generation. The existing registry publication listener admits new native roots only through captured owner objects during preparation, acquiring their queued holds synchronously. Observation ends before parent effects and is disposed on failure. This preserves FIFO scheduling without broad session reselection or persistent ancestry.
Gateway and channel callers retain descendant command acceptance and cleanup errors separately from model-run counts. Supported native records without an optional requester-agent field use the existing canonical controller ownership check.
Evidence
The original regression reproduced omitted completed-child cleanup and false success for uncertain, failed or evicted cleanup. Separate failures demonstrated consumed-notification selection loss and lost kill counts after accepted cancellation. The channel lookup probes reproduced both later-human over-selection and omission of a newly accepted original child. The corrected cases exercise real request ownership, native registration, scheduler holds and cancellation rather than accepting ancestry identifiers as authority.
On the tested dependency composition, 114 cases across the native cancellation, ordinary-command cleanup, Gateway authorization and normal Stop owners passed, followed by all eight routed cases. These include failure/revocation, replacement, independent-service and later-human controls. Changed formatting/lint, current compiler discovery and affected production/test graphs passed. The five remaining static owners, including the complete architecture aggregate, passed in 260.57 seconds. The full private-QA build, including declarations, passed in 199.75 seconds. Earlier unaffected compiler, boundary and selected hosted results remain retained at their actual inputs.
The matching real-Gateway browser runs below start a native child through the actual model tool path, wait for its successful model completion, then click parent Stop. Before the change, the ordinary PID/socket remained live and its process panel read Running. Afterward the PID was extinct, the socket closed and the panel read Stopped. Both runs preserved the completed receipt, explicit background service, parent-only aborted model IDs and a later human reply. Model responses were synthetic over loopback. The candidate scenario took 28.93 seconds and the baseline 30.23 seconds, including setup; each case body took about 12.6 seconds.
The four new lookup cases took 17.83 seconds through
pnpm test src/agents/subagents/registry/subagent-control.test.ts --maxWorkers=1 -t 'tracks only the original request|channel ACP lookup', including preparation, with 3.89 summed case seconds on macOS. Their estimated incremental CI case cost is about four seconds; shared startup is additional. Earlier Linux runs measured 56.6 summed case seconds for the 27 native/routed cases and 52.99/51.72 seconds for their single-worker commands. Physical cleanup and native lifecycle boundaries require these owner-level cases.The command and continuation prerequisites are now delivered on main. This PR applies the byte-identical native patch tested at
689c128bb6f10f0890bb66720f851295c2699f4bto that delivered base; all 35 changed files retain their tested contents. The newer admission, storage and claim-settlement changes were checked against the affected cancellation contracts. The media retains its actual runtime identities. Current-head CI completed with 56 successful jobs and 23 unselected jobs. Selected type, lint, boundary, Node and browser checks passed, as did launcher and built-CLI smoke checks. Independent review is complete; the later recovery-owner change on main was qualified against the same cancellation contracts without relabeling the earlier runtime proof.Visual evidence
Parent Stop, later human reply and native child process inspection
[email protected]
Visual verification
689c128bb6f10f0890bb66720f851295c2699f4b