Repository navigation
fix(infer): cancel model and embedding requests on interrupt - #192896
Conversation
infer embedding create runs a provider embedBatch without forwarding the CLI work-scope signal, so an accepted Ctrl+C cannot cancel the in-flight provider request and the command waits out the batch. Mirror the image, web and TTS capability commands by handing getAsyncWorkSignal() to the embedBatch call; runCapabilityCommand already suppresses late output for accepted interrupts. Precedent: #191176, #191628, #191635, #192818
|
🦞👀 Pull request received. I will update this pull request when review starts. |
Real PTY Ctrl+C: main twice, candidate twice, and uninterrupted controlsExact sweep head: Python stdlib Faithful local HTTP fixtures stream 40 successful Responses deltas at 250 ms intervals or return an ordinary embedding response after 10 seconds. All six uninterrupted controls complete successfully with a full response/vector and exit 0. Request IDs are unique and prior Gateway generations settle before the next case. Explicit owned profiles, HOME/state/config/workspace, config-file and database paths are captured from each exact binary before running. No real credentials, runtime monkeypatches, injected errors, fake Gateway, or live provider. Both main repetitions for all three paths end with SIGKILL after 2.05–2.27 seconds, without a cooperative cancellation drain. All six candidate repetitions exit naturally with status 130 in 30–56 ms. Local model and embedding sockets close before response completion in 1.4–2.8 ms. Gateway caller RPC closes in 1.5–2.1 ms through a passive byte-for-byte TCP/WebSocket observer. Gateway boundary: the provider stream behind the Gateway completes normally on both refs. This sweep cancels the caller RPC and its wait, not Gateway-owned generation. The HTTP completion counts below disclose that distinction. Actual visible PTY output on interrupted main and candidate runs: No interrupted candidate prints a success envelope or fixture inference content. All eighteen recorded outcomes follow; times are milliseconds measured using a monotonic clock: [
{
"lane": "base",
"path": "model_local",
"case": "control",
"exitCode": 0,
"signalToExitMs": null,
"httpCloseAfterSignalMs": [],
"rpcCallerCloseAfterSignalMs": [],
"requests": 1,
"completed": 1,
"resultOutputSuppressed": false,
"harnessSafetyKill": false
},
{
"lane": "base",
"path": "model_local",
"case": "interrupt1",
"exitCode": -9,
"signalToExitMs": 2054.957845,
"httpCloseAfterSignalMs": [
2052.883333
],
"rpcCallerCloseAfterSignalMs": [],
"requests": 1,
"completed": 0,
"resultOutputSuppressed": true,
"harnessSafetyKill": false
},
{
"lane": "base",
"path": "model_local",
"case": "interrupt2",
"exitCode": -9,
"signalToExitMs": 2182.997834,
"httpCloseAfterSignalMs": [
2180.986655
],
"rpcCallerCloseAfterSignalMs": [],
"requests": 1,
"completed": 0,
"resultOutputSuppressed": true,
"harnessSafetyKill": false
},
{
"lane": "base",
"path": "model_gateway",
"case": "control",
"exitCode": 0,
"signalToExitMs": null,
"httpCloseAfterSignalMs": [],
"rpcCallerCloseAfterSignalMs": [],
"requests": 1,
"completed": 1,
"resultOutputSuppressed": false,
"harnessSafetyKill": false
},
{
"lane": "base",
"path": "model_gateway",
"case": "interrupt1",
"exitCode": -9,
"signalToExitMs": 2157.856147,
"httpCloseAfterSignalMs": [],
"rpcCallerCloseAfterSignalMs": [
2155.567467
],
"requests": 1,
"completed": 1,
"resultOutputSuppressed": true,
"harnessSafetyKill": false
},
{
"lane": "base",
"path": "model_gateway",
"case": "interrupt2",
"exitCode": -9,
"signalToExitMs": 2271.223592,
"httpCloseAfterSignalMs": [],
"rpcCallerCloseAfterSignalMs": [
2269.672583
],
"requests": 1,
"completed": 1,
"resultOutputSuppressed": true,
"harnessSafetyKill": false
},
{
"lane": "base",
"path": "embedding",
"case": "control",
"exitCode": 0,
"signalToExitMs": null,
"httpCloseAfterSignalMs": [],
"rpcCallerCloseAfterSignalMs": [],
"requests": 1,
"completed": 1,
"resultOutputSuppressed": false,
"harnessSafetyKill": false
},
{
"lane": "base",
"path": "embedding",
"case": "interrupt1",
"exitCode": -9,
"signalToExitMs": 2165.214398,
"httpCloseAfterSignalMs": [
2163.520513
],
"rpcCallerCloseAfterSignalMs": [],
"requests": 1,
"completed": 0,
"resultOutputSuppressed": true,
"harnessSafetyKill": false
},
{
"lane": "base",
"path": "embedding",
"case": "interrupt2",
"exitCode": -9,
"signalToExitMs": 2218.354829,
"httpCloseAfterSignalMs": [
2216.358151
],
"rpcCallerCloseAfterSignalMs": [],
"requests": 1,
"completed": 0,
"resultOutputSuppressed": true,
"harnessSafetyKill": false
},
{
"lane": "cand",
"path": "model_local",
"case": "control",
"exitCode": 0,
"signalToExitMs": null,
"httpCloseAfterSignalMs": [],
"rpcCallerCloseAfterSignalMs": [],
"requests": 1,
"completed": 1,
"resultOutputSuppressed": false,
"harnessSafetyKill": false
},
{
"lane": "cand",
"path": "model_local",
"case": "interrupt1",
"exitCode": 130,
"signalToExitMs": 55.692114,
"httpCloseAfterSignalMs": [
2.787183
],
"rpcCallerCloseAfterSignalMs": [],
"requests": 1,
"completed": 0,
"resultOutputSuppressed": true,
"harnessSafetyKill": false
},
{
"lane": "cand",
"path": "model_local",
"case": "interrupt2",
"exitCode": 130,
"signalToExitMs": 47.564692,
"httpCloseAfterSignalMs": [
1.78526
],
"rpcCallerCloseAfterSignalMs": [],
"requests": 1,
"completed": 0,
"resultOutputSuppressed": true,
"harnessSafetyKill": false
},
{
"lane": "cand",
"path": "model_gateway",
"case": "control",
"exitCode": 0,
"signalToExitMs": null,
"httpCloseAfterSignalMs": [],
"rpcCallerCloseAfterSignalMs": [],
"requests": 1,
"completed": 1,
"resultOutputSuppressed": false,
"harnessSafetyKill": false
},
{
"lane": "cand",
"path": "model_gateway",
"case": "interrupt1",
"exitCode": 130,
"signalToExitMs": 30.181924,
"httpCloseAfterSignalMs": [],
"rpcCallerCloseAfterSignalMs": [
1.4633
],
"requests": 1,
"completed": 1,
"resultOutputSuppressed": true,
"harnessSafetyKill": false
},
{
"lane": "cand",
"path": "model_gateway",
"case": "interrupt2",
"exitCode": 130,
"signalToExitMs": 34.504742,
"httpCloseAfterSignalMs": [],
"rpcCallerCloseAfterSignalMs": [
2.072262
],
"requests": 1,
"completed": 1,
"resultOutputSuppressed": true,
"harnessSafetyKill": false
},
{
"lane": "cand",
"path": "embedding",
"case": "control",
"exitCode": 0,
"signalToExitMs": null,
"httpCloseAfterSignalMs": [],
"rpcCallerCloseAfterSignalMs": [],
"requests": 1,
"completed": 1,
"resultOutputSuppressed": false,
"harnessSafetyKill": false
},
{
"lane": "cand",
"path": "embedding",
"case": "interrupt1",
"exitCode": 130,
"signalToExitMs": 40.024314,
"httpCloseAfterSignalMs": [
1.441133
],
"rpcCallerCloseAfterSignalMs": [],
"requests": 1,
"completed": 0,
"resultOutputSuppressed": true,
"harnessSafetyKill": false
},
{
"lane": "cand",
"path": "embedding",
"case": "interrupt2",
"exitCode": 130,
"signalToExitMs": 38.162262,
"httpCloseAfterSignalMs": [
1.392633
],
"rpcCallerCloseAfterSignalMs": [],
"requests": 1,
"completed": 0,
"resultOutputSuppressed": true,
"harnessSafetyKill": false
}
]Focused verification: 110 capability/real-HTTP embedding tests pass; all three cancellation regressions fail on frozen main. Final three image/default-fixture cases, focused test typecheck, typed lint and formatting pass. Tests total +120/-122 (net -2), production +11/-2 (net +9), docs +5; no allocation or baseline increase. Both source fixes from @wangmiao0668000666 (#192818, #192846) retain contributor authorship. |
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Codex review: needs maintainer review before merge. What this changesThis PR forwards the existing CLI cancellation signal to local model requests, Gateway model RPCs, and embedding batches. Example: Press Ctrl+C while
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep open: this maintainer-authored PR fixes a current cancellation bug with a focused change; no actionable correctness or security defects were found. Priority: P2 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherInfer commands translate CLI input into provider requests or Gateway RPCs; the invocation work scope owns cancellation, while existing command and resource owners handle output suppression and cleanup. flowchart TD
A[CLI invocation] --> B[Invocation work scope]
B --> C[Infer command]
C --> D[Local model transport]
C --> E[Gateway caller RPC]
C --> F[Embedding provider]
D --> G[Cleanup and output suppression]
E --> G
F --> G
Technical reviewBest possible solution: Land the existing signal forwarding and cancellation regressions once the required CI gates pass, preserving Gateway generation ownership. Do we have a high-confidence way to reproduce the issue? The supplied shipped-CLI PTY runs reproduce forced termination on the base across local model, Gateway caller, and embedding paths; fetched main retains the same affected production code, and this review executed no target code. Is this the best way to solve the issue? Forwarding the invocation's existing signal is the smallest complete fix: requests receive cancellation while existing owners retain resource drainage, exit status, and output suppression. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against d79c89f95190. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +9, Tests -2, Docs +5. Total +12 across 5 files. Added test files: 0. View PR surface stats
Review metrics
Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. 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 Reviewed November 4, 2026, 11:55 AM ET / 16:55 UTC. |
CI classification: inherited UI type errorExact head: All three fail at This exact location/message is already reproduced identically on the CI merge and its exact main parent in the shared inherited-failure receipt, item 3. That comparison used Node 24.22.1 Docker with CI settings and ran the failing scripts typecheck on both refs. This is the browser-panel TS2322 case, not the older en-terminal/view-pairing failures. This sweep changes only inference CLI signal forwarding, related tests, and CLI docs. The UI file, its prop types, and typecheck configuration are untouched; the new cancellation wiring cannot cause this static UI assignment error. Focused changed-test typechecking, 110 capability/integration tests, formatting and typed lint pass. All other selected hosted checks succeeded or were intentionally skipped. Product-test cancellations: 0; the one cancelled check is ClawSweeper Dispatch, not a test job. The fresh exact-head ClawSweeper review is ready, 5/6, no findings. No unrelated repair, hosted rerun, re-push, or main merge was made to change this result. The 18-case real-PTY cancellation proof remains applicable. |
|
Maintainer override: the only reds are check-prod-types, check-test-types and core-5, all on ui/src/components/browser/browser-panel-render.tsx:149 TS2322, in a file this PR doesn't touch. It fails identically on the exact main parent. Receipts: #192857 (comment) and #192896 (comment) |
|
Landed in 958ae1a. Thanks @wangmiao0668000666. Ctrl+C now stops infer model and embedding runs right away. |
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: openclaw/openclaw#192896 (comment). Thanks @wangmiao0668000666. Co-authored-by: wangmiao0668000666 <[email protected]> Co-authored-by: Ayaan Zaidi <[email protected]>
…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]>
…193893) fix(infer): stop audio transcription on Ctrl+C `openclaw infer audio transcribe` did not pass the invocation's abort signal to the media execution context, so Ctrl+C did not cancel the provider request and the CLI hung until it was force-killed. The existing signal is now forwarded, as #192896 did for model and embedding runs. No API, default or policy change. Evidence: built CLI with a real PTY SIGINT during transcription against a slow local provider, twice per ref. Main ended in SIGKILL after about 2 seconds; with this change the CLI exits with 130 in 103 to 117 ms, the HTTP request closes within 4 ms, and no late transcript is printed. Uninterrupted controls match. Details: #193893 (comment). Thanks @wangmiao0668000666. Co-authored-by: Ayaan Zaidi <[email protected]>
…penclaw#193893) fix(infer): stop audio transcription on Ctrl+C `openclaw infer audio transcribe` did not pass the invocation's abort signal to the media execution context, so Ctrl+C did not cancel the provider request and the CLI hung until it was force-killed. The existing signal is now forwarded, as openclaw#192896 did for model and embedding runs. No API, default or policy change. Evidence: built CLI with a real PTY SIGINT during transcription against a slow local provider, twice per ref. Main ended in SIGKILL after about 2 seconds; with this change the CLI exits with 130 in 103 to 117 ms, the HTTP request closes within 4 ms, and no late transcript is printed. Uninterrupted controls match. Details: openclaw#193893 (comment). Thanks @wangmiao0668000666. Co-authored-by: Ayaan Zaidi <[email protected]>
`infer tts convert --gateway` did not pass the invocation's abort signal to the gateway call, so Ctrl+C did not cancel the pending RPC and the CLI hung until it was force-killed. The existing signal (from getAsyncWorkSignal) is now forwarded, as openclaw#192896 did for model and embedding runs. Uninterrupted runs are unchanged.
What Problem This Solves
Ctrl+C is accepted by
infer model runandinfer embedding create, but their execution calls omit the invocation's existing abort signal. A pending local request or Gateway RPC therefore holds cleanup until the shipped launcher escalates instead of completing the command's cancellation drain.User Impact
Interrupted local model requests and embedding batches cancel promptly when the provider honors cancellation. Interrupted Gateway model runs disconnect the caller's RPC promptly. All three paths exit naturally with status 130 and publish no inference result after interruption. Uninterrupted commands are unchanged.
Gateway-owned generation has a separate lifetime: this patch does not cancel that server-side work when its caller disconnects. The proof observes that boundary explicitly rather than claiming upstream cancellation through the Gateway.
Why This Change Was Made
Use
getAsyncWorkSignal()from the established CLI work scope at the three existing execution boundaries: local completion options,callGateway, and embedding batch options. No new cancellation owner, timeout, configuration, API, auth behavior, schema, retry guidance, or stored-state format.This sweep includes @wangmiao0668000666's fixes from #192818 and #192846. Both fix commits were cherry-picked with contributor authorship preserved:
5aa763166e4aand3d1a8d1d9029. The source PRs remain open for resolution after this sweep lands.Replaced successful-call signal-presence assertions with pending-work cancellation regressions. The tests close the invocation scope, observe the execution boundary's abort listener, verify output suppression, and retain resource cleanup assertions. Existing provider selection, image/media, authorization, profile-reference, dimensions, and cleanup-failure coverage remains. Test setup is consolidated rather than allocated.
Evidence
Full real-PTY terminal capture, request-close measurements, and all 18 recorded outcomes
Built source: main
7c2ff8f775acca3e5c93c9c22b6247e37df29bae; combined candidate production636fb5a0766739fbce2d289cfc376c9fcc6aa868. Final head54221c9eaa45d3a022090153598118ccf03586cachanges only tests/docs afterward. Both runtime builds and all runs are secretlessnode:24.22.1Docker with explicit task-owned profiles, HOME/state/config/workspace and database paths printed by the exact built CLI.The shipped
openclaw.mjsruns in a real controlling PTY (pty.fork). Writing the terminal's Ctrl+C byte delivers actual SIGINT while a faithful local Responses/embeddings HTTP request is pending. No runtime imports, monkeypatches, injected failures, fake Gateway, or real provider credentials. Gateway calls pass through a passive byte-for-byte TCP/WebSocket observer to the real built Gateway.Two interrupted main runs and two interrupted candidate runs per path, plus one uninterrupted control per path/ref: 18 cases.
model run --localmodel run --gatewayembedding createAll six uninterrupted controls complete normally with exit 0 and their complete response/vector result. All six interrupted candidates suppress result output; local and embedding HTTP responses do not complete. Gateway upstream streams complete normally on both refs, separately recorded and correlated by unique request IDs. No harness safety kill occurred in any case.
110 focused tests pass, including real-HTTP embedding integration; all three new cancellation cases fail on main. The final image-fixture consolidation's three cases, focused test typecheck, typed lint, and formatting pass.
Whole-PR deltas: production +11/-2 (net +9; 13 gross changed lines), tests +120/-122 (net -2), docs +5. The over-cap main capability test file shrinks by 39 lines. No test allocation or baseline growth.
Merge danger
Two-way door: reverting restores the old caller wait-out behavior; no migration or persisted-state changes. Blast radius is cancellation of model-run local requests, model-run caller RPCs, and embedding batches, plus their existing cleanup/output boundaries. Gateway generation ownership, provider selection, ordinary failure handling, and uninterrupted results are unchanged.