Repository navigation
fix: stop remote tools when Code Mode abandons their response - #200647
Merged
Merged
Conversation
Contributor
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review in progressClawSweeper is reviewing this revision. This supersedes any previous blocked status. |
Contributor
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
steipete
enabled auto-merge (squash)
November 17, 2026 15:10
Contributor
Author
|
Merged via squash auto-merge.
|
This was referenced Nov 17, 2026
RomneyDa
added a commit
that referenced
this pull request
Nov 17, 2026
Backport the merged worker proxy cancellation fix to 2026.11.6. Preserve parked Node and QuickJS calls until resumed; cancel only an abandoned transport observer through the existing Gateway owner. (cherry picked from commit bb36860) Co-authored-by: RomneyDa <[email protected]>
github-actions Bot
pushed a commit
to Desicool/openclaw
that referenced
this pull request
Nov 18, 2026
RomneyDa
pushed a commit
that referenced
this pull request
Nov 19, 2026
(cherry picked from commit bb36860) Co-authored-by: RomneyDa <[email protected]> Release adaptation: none; source change applies to the pinned beta baseline. Follow-up disposition: bounded pinned-main same-path audit recorded in the lane report; cross-lane changes remain parent-owned. (cherry picked from commit 3268deb86f53d0ba4e6d4e06c734a3043aecab48)
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: #200601
What Problem This Solves
When a worker-hosted Code Mode tool request times out while waiting for its Gateway response, the guest receives an error but the remote tool can keep running. Its cancellation listener was removed when the transport wait rejected, leaving ongoing work without its observer.
The November 17 production incident contained nine watchdog-aborted runs (eight user turns and one subagent spawn), each stalled on
callValuefor 15–41 minutes. The clearer sequences showed an earlier bridge timeout/abort followed by local workspace reconciliation lease waits and another stalled host call; retries re-hung. This PR reproduces a cancellation leak consistent with that sequence, without claiming that it proves the cause of every incident lease wait.User Impact
Abandoned worker Gateway tool invocations now receive cancellation promptly, so cooperative tools can release their resources. Parked Code Mode calls continue running and remain resumable through
wait. No config, tool deadline, execution budget, watchdog threshold, protocol/schema, or lease policy changes.Why This Change Was Made
Both incident release
a117ca50and this PR's base already create a per-request AbortController, relay cell abort, and pass that signal to host dispatch (src/agents/code-mode-state.ts:496–525). Adding another controller would duplicate the existing owner. The missing cancellation was in the worker Gateway proxy: a rejected transport wait exited before its signal aborted, andfinallyremoved the only remote-cancellation listener.The proxy now requests cancellation for that exact issued invocation when
invokeGatewayToolrejects (src/worker/worker-gateway-tools.ts:58). It shares the existing abort handler and requests cancellation once. The Gateway's existing call controller delivers the abort to the host tool (src/gateway/worker-environments/worker-gateway-tool-runtime.ts:219–235,296–301). Reconnection retries still stay insideinvokeGatewayTool; they are not abandoned attempts.Abandoned versus parked:
src/agents/code-mode-execution.ts:550; explicit abort/error paths cancel at lines 489, 516, and 523. Successful guests first drain dispatched calls.src/agents/code-mode-state.ts:358–373; cell/catalog closure aborts the owner at lines 166–176; dropped/expired continuations cancel at lines 327–331.src/agents/code-mode-execution.ts:497, retaining pending calls. It is not abandonment. A transport wait that finally rejects is abandonment of that remote invocation even if the guest catches its error.Lane 2559 owns lease fairness separately; no lease code is changed. #200601 supplies pending-tool attribution on watchdog aborts; this change repairs cancellation rather than diagnostic attribution. Release-note context: stop remote Gateway work when a worker Code Mode call abandons its transport response.
Evidence
The regression runs actual Node and QuickJS guests through the worker proxy and real Gateway tool owner. A synthetic host tool awaits its AbortSignal; fixed transport I/O rejects the response wait while the host remains active. On base
46982ac40764b40cd06ede122d4397a1532757c8, the regression failed in both executors atexpect(signal.aborted).toBe(true): received false (2 failed, 27 skipped). With the fix, both abandonment cases abort and settle the host, and parked-then-resumed controls complete without aborting it.Commands and results:
pnpm test src/gateway/worker-environments/worker-gateway-tool-runtime.test.ts --maxWorkers=1 -- -t 'cancels abandoned transport calls': 2 failed / 27 skipped; 44.83s wrapper wall.pnpm test src/gateway/worker-environments/worker-gateway-tool-runtime.test.ts --maxWorkers=1: 29 passed; 39.50s wrapper wall, 34.34s Vitest duration (89% transform, 7% tests). The compiled-worker boundary accounts for setup cost.pnpm test src/worker/worker-gateway-tools.test.ts --maxWorkers=1: 4 passed; 47.30s wrapper wall, 42.08s Vitest duration (91% transform, 4% tests).Net test growth is 75 lines, below the 400-line allocation threshold. Net production growth is 11 lines: a transport rejection handler and deduplication of its cancellation with signal abort. The author simplification pass retains the existing owners and cancellation protocol.
Limits: this is a production-owner integration test with synthetic transport I/O, not a deployed incident or live model replay. Sandbox shell operations forward signals (
src/agents/sandbox/local-workspace.ts:294–300) and foreground exec kills its process on abort (src/agents/bash-tools.exec-run.ts:610–636). However, sandbox exec preparation callsprojection.provisionwithout a signal (src/agents/sandbox/local-workspace.ts:305–315), andbuildExecSpechas no signal parameter (src/agents/sandbox/backend-handle.types.ts:79–87). Termination/checkpoint settlement also deliberately continues without the canceled call's signal (src/agents/sandbox/local-workspace.ts:217–228). Therefore this cancellation fix cannot guarantee release of a lease stuck in those paths; their behavior is unchanged.All local checks passed: core production typecheck, a targeted two-file test typecheck, production/test type-aware lint, formatting, docs MDX validation,
git diff --check, andpnpm build(3m 19.7s). Build returned zero with UI bundle-budget advisories; no UI files are changed. Exact-head CI run 44108637926 completed successfully, without retries. All 14 selected Node test jobs passed in 4,748 aggregate runner-seconds including setup. This is the complete selected test-lane cost, not a per-file or marginal cost; per-file CI timing artifacts are unavailable.Codex autoreview of the complete local diff against
46982ac40764b40cd06ede122d4397a1532757c8, through P2:scoped-clean, no accepted/actionable findings. The reviewer received the unchanged Code Mode state/execution owners, Gateway tool runtime, and worker connection replay owner as context. It did not independently run tests in its empty sandbox.