Repository navigation
fix(infer): stop model run after accepted interrupt - #192818
wangmiao0668000666 wants to merge 2 commits into
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. What this changesPass the CLI invocation’s cancellation signal to local model completion and Gateway model-run requests. Example: Press Ctrl+C during
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep this PR: current main still omits cancellation wiring for model runs, and the focused patch fixes it without changing cleanup ownership. No introduced correctness or security defect was found; exact-head CI remains pending. Priority: P2 Before mergeNone. FindingsNone. Tests
Agent review detailsHow this fits togetherThe inference CLI prepares model input and routes it to local completion or a Gateway RPC; the existing work scope owns interruption, cleanup, and output suppression. flowchart TD
A[CLI model run] --> B[Invocation work scope]
B --> C[Local completion]
B --> D[Gateway RPC client]
C --> E[Provider transport]
D --> F[Gateway agent run]
B --> G[Cleanup and exit]
Technical reviewBest possible solution: Forward the existing invocation signal to both execution transports while retaining the current cleanup and output owners. Do we have a high-confidence way to reproduce the issue? Current-main source shows the missing signal at both call sites, and contributor-supplied built-CLI traces demonstrate the failure on the base; no target code was executed during this review. Is this the best way to solve the issue? The production change is the smallest complete repair: it connects existing cancellation contracts without adding state, timeouts, wrappers, or a competing owner. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 7c2ff8f775ac. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +7, Tests -1, Docs +1. Total +7 across 3 files. Added test files: 0. View PR surface stats
LabelsLabel changes:
Label justifications:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
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 (1 earlier review cycle)
Reviewed November 4, 2026, 11:11 AM ET / 16:11 UTC (Revision 2). |
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Thank you — your model-run fix commit is preserved with authorship in #192896, together with the embedding sibling. The sweep includes real controlling-PTY Ctrl+C proof on main and candidate twice per path, uninterrupted controls, and consolidated cancellation regressions with net-negative test lines. Original PRs remain open until the sweep lands. |
fix(infer): stop model and embedding runs on Ctrl+C `openclaw infer model run` (local and Gateway) and the embedding command did not pass the existing work-scope abort signal, so Ctrl+C did not stop the request. The CLI hung until it was force-killed about 2 seconds later. The commands now pass the signal: the local or embedding provider request closes, the Gateway caller RPC closes, and the CLI exits with 130. Gateway-side generation keeps its existing behavior. Uninterrupted runs are unchanged. Sweep of #192818 and #192846; both contributor commits are kept. Evidence: built CLI with a real PTY and SIGINT, against slow local provider and Gateway fixtures, twice per ref for each path. Main reached SIGKILL after 2.05 to 2.27 s; with this change the CLI exited with 130 in 30 to 56 ms, and the provider HTTP request or Gateway RPC closed within 3 ms. All uninterrupted controls pass. Details: #192896 (comment). Thanks @wangmiao0668000666. Co-authored-by: wangmiao0668000666 <[email protected]> Co-authored-by: Ayaan Zaidi <[email protected]>
|
Thanks @wangmiao0668000666. Your commit landed as part of sweep #192896 (958ae1a), together with the related interrupt fix. Closing this one as included. |
…w#192896) fix(infer): stop model and embedding runs on Ctrl+C `openclaw infer model run` (local and Gateway) and the embedding command did not pass the existing work-scope abort signal, so Ctrl+C did not stop the request. The CLI hung until it was force-killed about 2 seconds later. The commands now pass the signal: the local or embedding provider request closes, the Gateway caller RPC closes, and the CLI exits with 130. Gateway-side generation keeps its existing behavior. Uninterrupted runs are unchanged. Sweep of openclaw#192818 and openclaw#192846; both contributor commits are kept. Evidence: built CLI with a real PTY and SIGINT, against slow local provider and Gateway fixtures, twice per ref for each path. Main reached SIGKILL after 2.05 to 2.27 s; with this change the CLI exited with 130 in 30 to 56 ms, and the provider HTTP request or Gateway RPC closed within 3 ms. All uninterrupted controls pass. Details: openclaw#192896 (comment). Thanks @wangmiao0668000666. Co-authored-by: wangmiao0668000666 <[email protected]> Co-authored-by: Ayaan Zaidi <[email protected]>
What Problem This Solves
Fixes:
openclaw infer model runkeeps waiting on the in-flight provider/Gateway request after Ctrl+C is accepted. The CLI printsCommand interrupted by SIGINT. Waiting for cleanup before exiting.and the cleanup drain then sits on a generation that has no cancellation wired in, so the shipped entry's signal-exit grace expires and the running command is terminated by escalation instead of finishing its own drain.User Impact
User impact: interrupting a long
model runnow cancels the request immediately (the local HTTP call is aborted, the Gateway RPC is disconnected) and the command exits cleanly with status 130 in about 0.2 s instead of being force-ended roughly two seconds in with the drain never completed. Uninterrupted runs are unchanged.Why This Change Was Made
runCapabilityCommandalready acquires the CLI work-scope signal and suppresses output for accepted interrupts, butmodel runnever handed that signal to the work itself: the local completionoptionsand thecallGatewaycall both omitted it, so nothing cancelled the in-flight request. This change passes the existing signal to both, mirroring the image (#191176), TTS (#191635) and web (#191628) interrupt fixes in the sameinferfamily — those siblings already document their interrupt contract indocs/cli/infer.md;model rundid not. No new timeout, owner, configuration or API is introduced.Evidence
Base
e25fdc28da1cdfa64a047c64612319a4dbd5d9fe→ Candidate5aa763166e4a2dc42c26e1d913dd3ed5c12cc0bb(CI retrigger head1d431a2291cis an empty commit; the diff is unchanged).Environment: NewStartOS V4.4.2 (Linux x86_64), Node v24.22.1, built CLI via
node --import ./scripts/tsx.mjs scripts/build-all.mts, secretless local proof: a slow Responses-API HTTP fixture on127.0.0.1:18973(45 deltas × 350 ms; fixture and drivers live in.artifacts/proof/and are not part of the PR) with an isolatedOPENCLAW_STATE_DIR. Two transports go through the real built entry:--local(the fixture acts as the provider) and--gateway(an isolated foregroundopenclaw gateway runbound to loopback port 18974 from the same isolated state, shared-secret lane). Each SIGINT run waits for the fixture's request log, delivers SIGINT ~1.5 s later, and measures signal→exit latency; control runs deliver no signal. Every transcript below is the verbatim driver capture (exit status, stdout, stderr, fixture events) reproduced from the per-run JSON — the transcripts contain no keys and only loopback fixture endpoints.Unit red-on-base (final tree of both revisions,
node scripts/run-vitest.mjs run src/cli/capability-cli.test.ts):prepares local model content and instructions (ChatGPT API: false)authorizes Gateway model override Anthropic/CLAUDE-HAIKU-4-5 and preserves profile refsauthorizes Gateway model override Anthropic/CLAUDE-OPUS-4-7@work and preserves profile refs3 failed | 101 passed104 passed, 143 sThe red assertions are the new signal-identity checks (local completion
options.signal,callGatewaysignal), each inside anAsyncWorkScope.trackrun exactly as the image-interrupt precedent does.Shipped CLI —
--local:tok1…tok45tok1…tok45Command interrupted by SIGINT. Waiting for cleanup before exiting.Shipped CLI —
--gateway:tok1…tok45tok1…tok45Raw run transcripts (verbatim captures, one block per run):
base7-sigint— build base e25fdc2,--local, mode=sigintbase8-sigint— build base e25fdc2,--local, mode=sigintbasegw-sigint-1— build base e25fdc2,--gateway, mode=sigintbasegw-sigint-2— build base e25fdc2,--gateway, mode=siginthead-sigint-1— build head 5aa7631,--local, mode=siginthead-sigint-2— build head 5aa7631,--local, mode=sigintheadgw-sigint-1— build head 5aa7631,--gateway, mode=sigintheadgw-sigint-2— build head 5aa7631,--gateway, mode=sigintbase8-control— build base e25fdc2,--local, mode=controlbasegw-smoke— build base e25fdc2,--gateway, mode=controlhead-control-1— build head 5aa7631,--local, mode=controlheadgw-control— build head 5aa7631,--gateway, mode=controlStatic checks:
node scripts/run-format.mts --checkclean;pnpm exec oxlint <both src files>0 warnings/errors;check-line-cap-ratchetOK (no growth in the over-cap test file — the wrapper compaction nets the file −1 line);check-max-lines-ratchetOK;check-test-lines-ratchetOK (6,453,895 / ceiling 6,453,925, slack 30).Whole-PR delta: production
model.ts+9/−1 (net +8), tests +9/−10 (net −1), docs +1.Notes and negative statements:
base8-sigint); its drain is static-verified to await the command action (signal-exit-barrier.ts), which is what the new signal now releases. In base--localthe fixture abort happens only at that kill (delta 11); on the candidate it happens right after SIGINT (delta 5).throwIfAbortedand the post-run output suppression still apply).check-test-types,check-test-types-core-4,check-lint-core-4,checks-fast-baseline-ratchets) failed on upstream main's own defects — the duplicatecloseSessionTitle(TS1117) inui/src/i18n/locales/en-terminal.tsplus mock-export annotations in upstream-touched UI tests — none of this PR's changed files are implicated, and the local equivalents for the touched files (format, oxlint, line-cap/max-lines/test-lines ratchets, prod types) pass. Upstream has since fixed the duplicate key (single occurrence on current main); CI was retriggered on head1d431a2291c.Focused Checks and Simplification
getAsyncWorkSignal()from the CLI work scope; no second cancellation mechanism, no timeout added, no schema/config/API change. Four production lines of behavior (signal into local completion options, signal intocallGateway, one acquisition, one import), the rest is import re-formatting.AsyncWorkScope.trackpattern fromcapability-cli.image-options.test.ts; assertions were folded into the existing local/Gateway cases so the over-capcapability-cli.test.tsdoes not grow (line-cap gate) and test-lines net is −1.#171681(model.ts L224–239, test L821–941) and#191080(model.ts L92–137, test L51–70/302–343/1814–1873) have hunks disjoint from this PR's edits (model.ts import/action/options/gateway-call; test 787/938);docs/cli/infer.mdneighbors#190279(Web section),#190287(Audio),#190209(Embedding) are section-disjoint from this Model-section bullet.git merge-tree HEAD origin/main(main at7aa96ecca2f) reports no conflicts.Compatibility and Merge Risk
Two-way door: reverting restores the previous wait-out behavior with no migrations or persisted-state changes. Blast radius is
infer model run's own cancellation wiring: local completion requests, the Gateway model-run call, and the interrupt exit path for that command. Unchanged neighboring behavior: uninterrupted runs (proven ×3), output suppression for accepted interrupts (pre-existingrunCapabilityCommandcontract), otherinfersubcommands (their own signal wiring untouched), and the exit codes for ordinary failures.