Repository navigation
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs maintainer review before merge. Reviewed August 31, 2026, 3:34 PM ET / 19:34 UTC. ClawSweeper reviewWhat this changesThe PR makes bundled Language Server Protocol tools reject retained and pending requests once their runtime begins disposal, before the child-process shutdown handshake. Merge readinessKeep this PR open: current main still admits bundled LSP requests during disposal and leaves pending abort listeners active until after the shutdown wait, while the introduced owner-boundary ordering closes both paths. No blocking defect was found in the patch. Priority: P2 Review scores
Verification
How this fits togetherBundled LSP tools send editor-style requests to a child language-server process. Runtime disposal must stop tool traffic while still completing the child process shutdown and exit sequence. flowchart LR
A[Agent tool call] --> B[Bundle LSP runtime]
B --> C[Pending request registry]
B --> D[Language server child]
E[Runtime disposal] --> B
B --> F[Reject retained and pending calls]
B --> G[Shutdown then exit]
D --> G
Before merge
Agent review detailsSecurityNone. PR surfaceSource +10, Tests +82. Total +92 across 2 files. View PR surface stats
Review metrics
Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Keep one lifecycle-owner rule: synchronously reject non-shutdown calls and detach pending abort listeners at disposal entry, then land once exact-head CI is green. Do we have a high-confidence way to reproduce the issue? Yes, source-reproducible: on current main, invoke a retained LSP tool or abort an in-flight tool request after disposal begins but before its shutdown wait completes. The supplied body also describes a matching real-child process scenario, though its detailed output was outside the supplied excerpt. Is this the best way to solve the issue? Yes. Closing the shared request owner at disposal entry handles both new retained calls and already-pending abort listeners; per-tool guards or cleanup after the shutdown wait would leave one of those paths open. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 0820b89d3b20. 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 (1 earlier review cycle)
|
Reject retained tools at disposal and release outstanding request abort listeners before the shutdown handshake. Preserve normal cancellation, shutdown, exit, and final cleanup. Co-authored-by: qingminlong <[email protected]>
|
@clawsweeper re-review The lifecycle repair now closes pending requests before shutdown as well as rejecting retained calls. The updated body includes inspectable real-child before/after evidence for the cancellation race,24 passing owner tests, fresh type/lint checks, and complete-candidate Codex review. New-head CI is required before landing. |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
Merged via squash.
|
* fix(agents): reject bundle LSP calls after disposal * fix(agents): close LSP requests before shutdown Reject retained tools at disposal and release outstanding request abort listeners before the shutdown handshake. Preserve normal cancellation, shutdown, exit, and final cleanup. Co-authored-by: qingminlong <[email protected]> --------- Co-authored-by: Peter Steinberger <[email protected]> Co-authored-by: qingminlong <[email protected]>
What Problem This Solves
A retained bundle LSP tool could still send requests after its runtime began disposal. The child remains alive during the shutdown handshake, so waiting for process exit lets stale hover, definition, and references calls succeed. An outstanding request also retained its abort listener: aborting it during shutdown sent
$/cancelRequestaftershutdown.Why This Change Was Made
Close requests at their lifecycle owner. The canonical request function rejects new tool calls as soon as the existing session is disposed, while permitting the internal shutdown handshake. Disposal synchronously rejects outstanding requests before sending shutdown; the pending-request registry releases their abort listeners, so late caller aborts cannot write cancellation notifications. The final rejection remains to clean up a timed-out shutdown request. This preserves the LSP shutdown contract: only exit may follow shutdown.
User Impact
Retained LSP handles and outstanding requests reject promptly when their runtime closes. Normal requests, cancellation before disposal, and the shutdown/exit handshake keep working. All three materialized tools share the same owner; no configuration, protocol, or persistent state changes.
Evidence
Before editing production, independently authored regressions on trusted main
37db48c3e93cef9330bad6de67fd7d77183e05dashowed all three retained methods succeeding during shutdown and afterdispose()returned. The expanded tests first perform valid requests and then assert rejection without further child requests. A separate outstanding-request test failed on the initial request-gate-only repair: a caller abort during held shutdown won over disposal and emitted cancellation. After moving pending-request rejection to disposal entry, all 24 tests insrc/agents/agent-bundle-lsp-runtime.test.tspass, including normal cancellation, transport failure, final stdout drainage, framing, and global cleanup.The real-process harness below uses
createBundleLspToolRuntime, production spawn/framing/cleanup, and a synthetic Node child whose shutdown reply is held. The first probe showed each method reaching the live child twice before the repair and once afterward. The extended probe preserves normal pre-disposal cancellation, then starts another outstanding request and aborts it during shutdown. Before the owner-order repair it records a second cancellation after shutdown; afterward the outstanding request rejects as disposed and the only cancellation precedes shutdown. Retained tool calls still reject, shutdown/exit are recorded, and the child closes. This is a real local LSP-process boundary, not editor or external-provider proof.Node 24.20.0 extended real-process wall times were 4.07 seconds before the owner-order repair and 5.85 seconds after; the JSON below records process RSS and the measured harness duration. These are proof observations, not a performance claim. The full repaired 24-test command took 25.69 seconds, maximum RSS 1,710,211,072 bytes. The recorded passing source hash precedes only an explanatory lifecycle comment; production behavior and tests are identical to the candidate. Contributor code was not executed locally.
Production +11/-1 (net+10), tests +82/-0. The bounded growth adds one shared lifecycle gate, centralizes the disposal error, releases pending requests before protocol shutdown, and explains both ordering constraints. A per-tool guard or another cancellation guard would duplicate ownership. This addresses the latest ClawSweeper production-growth note. Contributor ancestry and credit are preserved. Thanks @qingminglong.
Changed-scope validation passed formatting, core and core-test typechecks, targeted lint, and required repository guards. The full checker covered the initial guard and poll repair; the added pending-request repair passed fresh core/test typechecks, targeted lint, formatting, the full 24-test owner suite, and the real-child probe. The temporary full-check checkout initially lacked the UI workspace dependency link and resolved an older root pako without declarations; linking the existing pinned UI installation corrected that checkout layout, with no dependency or source change.
Published-head CI is green. The real-child runtime results above are from separately authored equivalents on trusted main; hosted CI also executes the exact published source.
Run from the reviewed, dependency-complete checkout with Node 24:
node --import ./scripts/tsx.mjs /path/to/probe.mts "$PWD"Inspectable synthetic proof harness
Before owner-order repair: retained requests blocked, outstanding abort still leaks after shutdown
{ "passed": false, "sourceSha256": "28e047dd5ee03987546da352ab3b76d45e0db12b0a1bf330b55e8b8943aec8fe", "node": "v24.20.0", "platform": "darwin", "observations": [ { "tool": "lsp_hover_proof", "phase": "shutdown-pending", "outcome": "LSP session disposed" }, { "tool": "lsp_definition_proof", "phase": "shutdown-pending", "outcome": "LSP session disposed" }, { "tool": "lsp_references_proof", "phase": "shutdown-pending", "outcome": "LSP session disposed" } ], "requestCounts": { "textDocument/hover": 3, "textDocument/definition": 1, "textDocument/references": 1 }, "methods": [ "initialize", "initialized", "textDocument/hover", "textDocument/definition", "textDocument/references", "textDocument/hover", "$/cancelRequest", "textDocument/hover", "shutdown", "$/cancelRequest", "exit" ], "outstandingOutcome": "caller aborted during shutdown", "normalAbortOutcome": "normal caller abort", "closeCode": null, "closeSignal": "SIGTERM", "wallMs": 3881.992875, "rssBytes": 346505216 }After owner-order repair: normal cancellation preserved, no cancellation after shutdown
{ "passed": true, "sourceSha256": "1a038c6967b10889c9598d59c31b09b2f73f5e5df82871945c1a9583538830c7", "node": "v24.20.0", "platform": "darwin", "observations": [ { "tool": "lsp_hover_proof", "phase": "shutdown-pending", "outcome": "LSP session disposed" }, { "tool": "lsp_definition_proof", "phase": "shutdown-pending", "outcome": "LSP session disposed" }, { "tool": "lsp_references_proof", "phase": "shutdown-pending", "outcome": "LSP session disposed" } ], "requestCounts": { "textDocument/hover": 3, "textDocument/definition": 1, "textDocument/references": 1 }, "methods": [ "initialize", "initialized", "textDocument/hover", "textDocument/definition", "textDocument/references", "textDocument/hover", "$/cancelRequest", "textDocument/hover", "shutdown", "exit" ], "outstandingOutcome": "LSP session disposed", "normalAbortOutcome": "normal caller abort", "closeCode": null, "closeSignal": "SIGTERM", "wallMs": 5327.99325, "rssBytes": 353878016 }The exact published commit
5820ed59acc3224fef2a32c6ee6ce418a5af9a3dpasses CI attempt 2. All 24 LSP owner tests, including the three retained-tool cases and pending-abort ordering regression, passed in the original LSP test job.The first full run failed during an unchanged UI shared-page startup: the fixture did not become visible before its existing deadline, and the rejected setup promise propagated to later cases. The complete UI, test harness, workflow and dependency inputs matched a successful companion run. One failed-jobs-only rerun, with no code, deadline or assertion change, passed all affected cases in their original order. The initial render stall remains unexplained; a repeat should capture page, request and Vite diagnostics at shared setup rather than increase timeouts.