Skip to content

fix(infer): pass the interrupt signal to embedding batches - #192846

Closed
wangmiao0668000666 wants to merge 1 commit into
openclaw:mainfrom
wangmiao0668000666:fix/infer-embedding-signal
Closed

wangmiao0668000666 wants to merge 1 commit into
openclaw:mainfrom
wangmiao0668000666:fix/infer-embedding-signal

Conversation

@wangmiao0668000666

Copy link
Copy Markdown
Contributor

What Problem This Solves

openclaw infer embedding create runs its provider embedBatch without forwarding the CLI work-scope cancellation signal, so an accepted Ctrl+C cannot cancel the in-flight provider request. The command then waits out the batch before the shared runCapabilityCommand suppresses the late output — inconsistent with the other infer capability commands, which cancel immediately.

User Impact

Interrupting a slow embedding batch now cancels the upstream request promptly instead of waiting for it to finish. Uninterrupted runs are unchanged, and accepted interrupts still exit without publishing a failure (the existing runCapabilityCommand contract).

Why This Change Was Made

runCapabilityCommand already acquires the CLI work-scope signal and suppresses output for accepted interrupts, but embedding create never handed that signal to the work itself: embedBatch was called with only { inputType: "document" }. This change mirrors the image (#191176), web (#191628), TTS (#191635) and model run (#192818) interrupt fixes in the same infer family — those siblings already document their interrupt contract in docs/cli/infer.md; embedding did not. The EmbeddingProviderCallOptions.signal field already exists and is consumed by the embedding adapters (for example GitHub Copilot withRemoteHttpResponse({ signal }), ClawRouter, Google, llama.cpp), and the in-tree memory host already forwards it through embedMemoryDocuments. No new timeout, owner, configuration, or API is introduced.

Behavior classification: behavior-completing — completes the sibling interrupt contract for the last infer capability command that lacked it.

Evidence

Base 1835c9cad10a936fbd079a52e65bb2ede5ef1e38 (current origin/main). Head 3d1a8d1d902 (fix/infer-embedding-signal).

All runs in the repository test harness (vitest CLI shard, Node 24.22.1, --user 0:0, OPENCLAW_VITEST_RUNTIME=node).

Regression (new case, capability-cli.embedding.test-support.ts — "passes the interrupt signal to the embedding batch and suppresses late output"):

State Command Result
RED (embedding.ts without signal) vitest run src/cli/capability-cli.test.ts -t "passes the interrupt signal" AssertionError: expected [] to have a length of 1 but got +0 at expect(received).toHaveLength(1) / expect(received[0]!.aborted).toBe(true)
GREEN (this change) same command ✓ passes the interrupt signal to the embedding batch and suppresses late output — 1 passed

The red assertion is on the exact missing behavior: the embedBatch options carried no signal (empty array), so the batch was not cancellable; with the change the received signal is aborted === true and late output is suppressed.

Full suite (no regression):

Suite Result
capability-cli.test.ts (includes all existing embedding cases via registerEmbeddingCapabilityCliTests) 107 passed (107)
capability-cli/embedding.clawrouter.integration.test.ts (real ClawRouter HTTP path) 1 passed (1)

Static checks: run-format --check clean; tsgo --noEmit clean (exit 0); oxlint 0 warnings / 0 errors on both changed files.

Not tested: no live-Gateway --gateway Ctrl+C run is claimed (the signal hand-off is unit-asserted; provider transports that ignore mid-stream abort still fall back to the post-run suppression). No Windows or macOS run. No real provider credentials were used.

Impact Surface

File Change Risk
src/cli/capability-cli/embedding.ts acquire getAsyncWorkSignal() and pass to embedBatch options Low — one call-site option addition; runCapabilityCommand already owns the accepted-interrupt exit path
src/cli/capability-cli.embedding.test-support.ts regression case asserting signal pass-through + output suppression Low — test-only

No migrations, persisted state, config schema, or public API changes. Two-way door: reverting restores the previous wait-out behavior with no state changes.

Maintainer Edits

  • Check the box "Allow edits from maintainers" — not set; branch is on the contributor fork (wangmiao0668000666/openclaw, fix/infer-embedding-signal).

Maintainer Options

  • Land-ready rationale: the fix is 2 production lines reusing the existing shared getAsyncWorkSignal() owner, with the sibling infer commands (#191176/#191628/#191635/#192818) already shipped through this exact shape. Embedding adapters already consume signal.
  • Alternative approaches: forward the signal inside createEmbeddingProvider instead of at the CLI call site — larger blast radius, touches the facade, not needed since the CLI is the only non-forwarding caller.
  • Scope: strictly infer embedding create; no change to memory-side embedding (already forwards the signal), providers list, or other commands.

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: openclaw#191176, openclaw#191628, openclaw#191635, openclaw#192818
@clawsweeper

clawsweeper Bot commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added cli CLI command changes size: XS labels Nov 4, 2026
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. P2 Normal backlog priority with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. labels Nov 4, 2026
@clawsweeper

clawsweeper Bot commented Nov 4, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge.

What this changes

Forward the CLI cancellation signal to embedding batches and add an interruption regression.

Example: Press Ctrl+C while openclaw infer embedding create --text "friendly lobster" --json awaits a slow HTTP embedding response.

  • Before: The provider request receives no cancellation signal, so cleanup keeps waiting until completion or process escalation.
  • After: Providers that honor cancellation can abort the request, while the existing command wrapper suppresses interrupted output.

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) The runtime fix is focused and source-supported, but required cancellation proof is mock-only and the added test growth causes a CI failure.
Proof confidence 🧂 unranked krab (1/6) Real behavior proof is necessary before merge. See Before merge.
Patch quality 🦐 gold shrimp (3/6) 1 actionable review finding remain.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Accepted Ctrl+C cannot cancel an in-flight embedding batch because the provider never receives the invocation signal.
Reason: This completes an existing cancellation contract through an existing provider option without adding an owner, setting, or API.

Merge readiness

⛔ Blocked before merge - 2 items remain

Keep open: this PR addresses a current cancellation defect with a focused runtime change, but its added regression causes a test-budget CI failure.

Priority: P2
Reviewed head: 3d1a8d1d90298b9b975997259ce1316b220eca4d

Before merge

  • Add real behavior proof - The full PR body and comments supply a red/green Commander test with a mocked embedBatch, not a shipped embedding cancellation run; the cited real-HTTP integration test exercises ordinary requests without interruption. Please attach terminal output or redacted logs for the shipped-CLI scenario, removing IPs, API keys, phone numbers, and non-public endpoints. After adding proof, update the PR body, then request a new review with @clawsweeper re-review. The PR author or someone with repository write access can request it.
  • Keep the interruption regression within the test-line budget (P2) - This addition contributes 21 counted test lines without changing the ceiling. The pinned tree is already 216 lines over budget before this PR, and check-test-lines-ratchet permits that inherited debt only for non-growing changes; this positive delta therefore turns the check into a failure, as the exact-head annotation confirms. Retain the regression while consolidating or offsetting its 21 added lines. Do not raise the shared baseline or allocate inherited debt; an allocation of only 21 lines would still leave this positive-growth tree over its ceiling.

Findings

  • [P2] Keep the interruption regression within the test-line budget — src/cli/capability-cli.embedding.test-support.ts:86-89

Tests

  • Missing end-to-end proof: Provide a shipped-CLI embedding run showing a real SIGINT during an outstanding HTTP request, transport cancellation, natural exit 130 without late output, and an uninterrupted control.
Agent review details

How this fits together

The embedding CLI resolves the selected provider, submits text through embedBatch, closes the provider, and publishes vectors through the shared cancellation-aware output wrapper.

flowchart LR
  A[CLI invocation] --> B[Async work scope]
  B --> C[Embedding command]
  C --> D[Embedding provider]
  D --> E[HTTP transport]
  D --> F[Provider cleanup]
  F --> G[Cancellation-aware output]
Loading

Technical review

Best possible solution:

Keep the existing signal-forwarding fix and preserve its regression within the repository's test-line budget.

Do we have a high-confidence way to reproduce the issue?

Source confirms that current main drops the existing cancellation signal before embedBatch; the contributor reports a matching red/green regression, but no target code was executed during this review.

Is this the best way to solve the issue?

Forwarding the existing work-scope signal at the CLI call site is the smallest complete runtime fix and preserves provider selection, cleanup, and shared output ownership.

Full review comments:

  • [P2] Keep the interruption regression within the test-line budget — src/cli/capability-cli.embedding.test-support.ts:86-89
    This addition contributes 21 counted test lines without changing the ceiling. The pinned tree is already 216 lines over budget before this PR, and check-test-lines-ratchet permits that inherited debt only for non-growing changes; this positive delta therefore turns the check into a failure, as the exact-head annotation confirms. Retain the regression while consolidating or offsetting its 21 added lines. Do not raise the shared baseline or allocate inherited debt; an allocation of only 21 lines would still leave this positive-growth tree over its ceiling.
    Confidence: 0.99

Overall correctness: patch is incorrect
Overall confidence: 0.94

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 07e545e113f1.

Provenance checked

  • Embedding batch invocation keeps the original intent (6938f6e: The adapter simplification moved an existing call into its sole CLI consumer while preserving lifecycle boundaries; its removed helper already omitted the signal.)

Testing

Proof path: unit tests only.

Security

None.

Evidence

Acceptance criteria:

  • pnpm test src/cli/capability-cli.test.ts --maxWorkers=1
  • pnpm check:test-lines-ratchet --base 1835c9c --no-merge-base
  • pnpm exec oxlint src/cli/capability-cli.embedding.test-support.ts
  • git diff --check

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit 6938f6e adds src/cli/capability-cli/embedding.ts:65 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 6938f6e782a9; files: src/cli/capability-cli/embedding.ts)

PR surface

Source +2, Tests +21. Total +23 across 2 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 1 3 1 +2
Tests 1 21 0 +21
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 24 1 +23

Labels

Label changes:

  • add P2: A bounded CLI cancellation defect leaves slow embedding requests running after an accepted interrupt.
  • add rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🦐 gold shrimp.
  • add status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Label justifications:

  • P2: A bounded CLI cancellation defect leaves slow embedding requests running after an accepted interrupt.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🦐 gold shrimp.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Rating scale

6/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.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

Reviewed November 4, 2026, 10:30 AM ET / 15:30 UTC.

@obviyus

obviyus commented Nov 4, 2026

Copy link
Copy Markdown
Collaborator

Thank you — your embedding fix commit is preserved with authorship in #192896, together with the model-run sibling. Real controlling-PTY Ctrl+C now proves both candidate embedding requests close promptly and exit naturally with status 130, while main requires SIGKILL; uninterrupted controls pass. The combined regression coverage has net-negative test lines without an allocation. Original PRs remain open until the sweep lands.

obviyus added a commit that referenced this pull request Nov 4, 2026
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]>
@obviyus

obviyus commented Nov 4, 2026

Copy link
Copy Markdown
Collaborator

Thanks @wangmiao0668000666. Your commit landed as part of sweep #192896 (958ae1a), together with the related interrupt fix. Closing this one as included.

@obviyus obviyus closed this Nov 4, 2026
@wangmiao0668000666
wangmiao0668000666 deleted the fix/infer-embedding-signal branch November 4, 2026 22:52
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 5, 2026
…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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cli CLI command changes P2 Normal backlog priority with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: XS status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants