Repository navigation
fix: stop yielded commands with their Gateway request - #166753
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 7, 2026, 9:44 PM ET / October 8, 2026, 01:44 UTC (Revision 5). ClawSweeper reviewWhat this changesThe branch makes Gateway request Stop cancel ordinary yielded commands, await physical cleanup, and report cleanup uncertainty while preserving explicitly independent services. Example: The user starts an ordinary command and presses Stop.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review This PR addresses a necessary cancellation defect with convincing browser and process-lifecycle evidence. No actionable introduced bug was found, and current main still lacks the request-owned cancellation contract. Priority: P1 Before mergeNone. FindingsNone. Provenance
Agent review detailsHow this fits togetherThe Gateway accepts chat and agent requests and dispatches their command tools to the process supervisor or sandbox. This change carries the accepted request identity into command execution so cancellation can reach commands after their tool calls return. flowchart TD
A[Chat or agent request] --> B[Accepted request owner]
B --> C[Command tool]
C --> D{Independent service?}
D -->|Yes| E[Separate process lifetime]
D -->|No| F[Request-owned process]
G[Authorized Stop] --> B
B --> F
F --> H[Cleanup result and retained output]
Technical reviewBest possible solution: Keep cancellation in the existing Gateway authorization and process-lifecycle owners, with separate channel and continuation follow-ups retaining their stated boundaries. Do we have a high-confidence way to reproduce the issue? Yes: the real-Gateway fixture starts an ordinary yielded command, then uses composer Stop or typed /stop and checks whether its socket remains open when Stop replies. Recorded baseline failures and unchanged current-main ownership gaps support the defect; this read-only review did not execute it. Is this the best way to solve the issue? Yes: separating request cancellation from disposable tool-call lifetime repairs the owning boundary while preserving independent services, normal completion, caller checks, and managed-worker lifetime. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 954012f95a6a. Provenance checked
TestingProof path: shipped entry point. Added test files: 11. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +602, Tests +1225, Docs +3. Total +1830 across 35 files. View PR surface stats
Review metrics
LabelsLabel changes: No label 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)
|
9e006fd to
1b79448
Compare
|
Fixed: Gateway Stop now cancels ordinary yielded commands owned by the selected request and waits for their cleanup. |
Stop ordinary yielded commands with their selected Gateway request, wait for physical cleanup, and retain cleanup uncertainty after output eviction. Preserve explicitly independent services and suppress cancellation completion notifications.
What Problem This Solves
A command that outlives
exec's yield window can keep running after the user stops its Gateway request. The model turn ends, but the command retains its process and can later produce a completion notification. This is especially confusing in the browser, where Stop appears to have finished the work.User Impact
The browser's Stop button and typed
/stopnow cancel ordinary commands owned by the selected request, including commands that already returned a process handle. Gateway cancellation waits for physical process cleanup and reports uncertainty if cleanup cannot be confirmed. Retained command output remains available, and stopping a command does not create a new completion notification.Deliberately independent
background: trueservices remain running until their own process handle is stopped. Normal model completion, completed model receipts, unrelated work, and later human turns retain their existing behavior. This contribution covers the Gateway request and its ordinary commands; channel cancellation, completion continuations, and commands retained by native descendants have separate owners. Managed-worker behavior is unchanged.Why This Change Was Made
Tool-call disposal and request cancellation have different lifetimes. An ordinary yielded command needs to retain its request owner after the tool call returns, while an explicitly independent service does not. The Gateway's
chat.sendandagentdispatch owners now carry their admitted identity through embedded execution and lazy/Code Mode tool binding into the process lifecycle.Cancellation captures the selected owners before asynchronous work, preserves the existing actor and session-generation checks, and joins the process supervisor or sandbox's cleanup. Native finalization retains the cleanup verdict on the request owner, so a command registered after selection cannot lose its failure when process output is evicted. Accepted initial session binding and compaction update that ownership. If authority changes after cancellation was already accepted, cleanup is still observed and any uncertainty is reported without rewriting a completed model receipt. The general reply runner does not need to read Gateway cancellation registries.
Evidence
The real-Gateway browser regression fails before the repair for both the Stop button and typed
/stop: the model request is interrupted while the ordinary command remains physically alive. With this change, both controls join command cleanup, cancel the existing model descendant, preserve retained output, suppress a cancellation completion notification, and allow a new instruction to complete. The native three-file browser batch passed all four cases. Before and after use the same fixture, Linux host architecture, Node 24.19.0, managed Chromium 153.0.8010.12, and 1440 × 1000 viewport.The lifecycle regression also reproduced two lost cleanup failures after selection, late command registration, cancellation, and output eviction. Both fail before the producer repair and pass afterward. The corrected cleanup, Stop/Code Mode, and Gateway cascade batch passed 38 cases. First-turn identity, accepted/rejected compaction, newer-request isolation, completed model receipts, explicit independent services, and managed-worker preservation are covered by the focused owner suites. The nine single-worker commands passed 217 cases; overlapping runs are not summed.
The ordinary selected baseline completed 316 files: 315 passed and one skipped, with 5,492 passing and 29 skipped cases. Applicable earlier static/security, full compiler, package-boundary, and unchanged-file results are retained with their original revisions; the final private-QA build passed on the composition with #166786. That prerequisite repairs the independently reproduced Workboard manifest failure in the PR's historical CI run. Current Node/tooling CI jobs passed; the failed build and aggregate gate retain their actual historical failure status, qualified against the repaired result. Independent engineering review and the separate required automated review have no unresolved source finding.
Test cost
The following are literal
pnpm test <file> --maxWorkers=1command wall times on remote macOS arm64. CI seconds are whole shared job durations, not per-file charges; repeated job durations must not be summed.bash-tools.exec-runtime.cleanup.test.tsbash-tools.exec.background-abort.test.tsrun.session-prompt-state.test.tschat-abort.test.tschat.abort-cascade.test.tssessions.abort-dedupe-currentness.test.tsserver.chat-first-turn-binding.test.tsworker.runtime.test.tsvitest-ui-e2e-config.test.tsThe existing background-work browser file took 27.927 s and the two-case Stop file took 59.781 s in Vitest’s retained file-duration cache; these include real Gateway and provider lifecycle setup. Exact per-case Vitest durations were not emitted by the reporter.
The new ordinary-yield worker case takes 0.224 s; the 55.88 s command includes the existing 86-case process-lifecycle suite. The first-turn case reuses the existing Gateway fixture. The real-Gateway browser row runs through its canonical serial owner and took 179.28 s in Vitest, or 184.63 s for the native test helper including preparation. It proves the browser-to-Gateway-to-process boundary that a unit test cannot establish. Dedicated browser CI was unselected, so that skipped job supplies neither a timing nor a pass.
The complete selected UI coverage is reused from the exact-head CI run: 1,634 unit files across three shards, 676 mocked UI files across eight shards, and the browser-extension case. Their source trees, ordered selections, owners, dependency lock, pinned Bun runtime, and worker caps match the native composition. Six ordinary E2E owners also passed in that run. An extra native UI attempt lost its SSH transport and remains incomplete; it is not counted as a pass.
The remaining eight agent E2E files executed through the native owner: six files passed, with 156 passing and 19 failing cases overall. The same 19 failures reproduced on clean base
950bd83e: 17 encounter an existing auth-controller mock missingcreateEmbeddedAuthProfileAdmission, and two expect an older admission-error message. The affected fixture and producer paths are unchanged by this PR, and source tracing confirms the new request-owner wrapper does not change their ordering or errors. These inherited fixture failures remain recorded; they are not relabeled as passing tests. The changed cancellation behavior passes the focused lifecycle suites and real-Gateway browser scenarios.Visual evidence
Button Stop, then typed /stop: physical cleanup and a new instruction
both-stop-controls-final.mp4
Visual verification
e8c75f7bb4ff90333c3bbd4e2e4caf19fd93fc2e