Skip to content

fix(cli): stop capability video downloads on interrupt - #187563

Merged
obviyus merged 3 commits into
openclaw:mainfrom
SunnyShu0925:fix/capability-video-download-interrupt
Oct 29, 2026
Merged

obviyus merged 3 commits into
openclaw:mainfrom
SunnyShu0925:fix/capability-video-download-interrupt

Conversation

@SunnyShu0925

@SunnyShu0925 SunnyShu0925 commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

An accepted Ctrl-C or SIGTERM during openclaw infer video generate --output … did not cancel the provider-URL download. The CLI kept streaming until the launcher's shutdown deadline killed it, leaving partial staging output.

What changed?

  • Reuse the invocation's existing private cancellation signal for the download fetch and streaming pipeline.
  • Check cancellation before download/write handoff and before reporting command success.
  • Keep atomic output cleanup on the existing owner; no SDK export, new helper, configuration or public API.
  • Extend the existing atomic-output test to cover cancellation before and during download, with no increase in registered tests.

Original fix by @SunnyShu0925; follow-up preserves the contributor commits.

Evidence

Complete main and candidate source trees were built on Node 24.22.1 in secretless Docker. The real built CLI used the bundled DeepInfra provider with a local HTTP fixture serving a valid 67 MB MP4 slowly. SIGINT and SIGTERM were each exercised twice per build after actual streaming and staging began.

Main continued downloading, then the launcher killed it after 2.1–2.3 seconds, leaving partial staging files in all four cases. Candidate exited 130/143 in 36–45 ms, closed the transfer, emitted no success envelope, and left neither target nor staging. Both completed-download controls replaced an existing target with the exact full video. This is full-build proof, not substitution of compiled modules.

Formatting passed; focused capability CLI suite passed 103/103. Detailed exact-head measurements are in the proof comment.

Limits and merge danger

Provider-generation lifetime, already-started buffered writes, already-published renames, and earlier assets in multi-video results are unchanged. This is a two-way door: reverting restores prior cancellation behavior without migrations or persisted-contract changes. Blast radius is capability command completion under an accepted interruption and video provider-URL downloads; normal completed downloads retain their existing atomic-output behavior.

The capability video command downloaded provider URLs with no signal, so an
accepted interrupt left the transfer running: a body that finished inside the
launcher's shutdown budget was published over --output with a success envelope,
and a slower one ended in the launcher's SIGKILL with the staging directory left
beside the destination. Thread the ambient work signal into the request, the
temp pipeline and the publish handoff, and stop the shared capability command
wrapper from emitting after an accepted interrupt.

Ref: BUG-259-capability-video-download-ignores-interrupt (local finding)
@clawsweeper

clawsweeper Bot commented Oct 29, 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 docs Improvements or additions to documentation cli CLI command changes size: S labels Oct 29, 2026
@SunnyShu0925

Copy link
Copy Markdown
Contributor Author

Observed captures

Same harness, same commit ecb8aa9fc6ab6d7344ca57d550669189078323f2, same built dist; only src/cli/capability-cli/{video,providers-command}.ts differ between the two revisions. output.mp4 starts as existing-video (sha256 eaa36232e54003172b18e5daaceb4a5c46d27cd795d527f8e7e46f715762ec62).

The 137 exits are the launcher's own shutdown budget, not the harness: strace -f -e trace=kill shows kill(<cli>, SIGINT) -> kill(-<cli>, SIGTERM) -> kill(-<cli>, SIGKILL) on the child the CLI keeps running (base only). Nothing in the harness kills the CLI.

base - 1.5 s body: interrupt accepted, then the finished download is published

  • The CLI reports the accepted interrupt, keeps streaming, publishes the partial bytes over the destination and prints a success envelope 1.45 s later.
$ SIGINT delivered 250 ms after GET /slow.mp4   (base-sigint-fast)
exit: 130 signal: None  after 1450 ms
stderr: Command interrupted by SIGINT. Waiting for cleanup before exiting.
stdout: {
  "ok": true,
  "capability": "video.generate",
  "transport": "local",
  "provider": "deepinfra",
  "model": "Pixverse/Pixverse-T2V",
  "attempts": [],
  "outputs": [
    {
      "path": "/home/code/github/contributions/BUG/BUG-259-evidence/runs/base-sigint-fast/output.mp4",
      "mimeType": "video/mp4",
      "size": 19
    }
  ],
  "ignoredOverrides": []
}
destination: 'partial-video-bytes'  sha256=a76c07775674296496bded40bd6c4754777df0d43df0c62fcbe2bbff90744cd9
run dir: cli.stderr, cli.stdout, config.json, output.mp4, server.log, state

base - 25 s body: launcher reaps the still-downloading process

  • Exit is the launcher's SIGKILL; the staging directory fs-safe-output-* stays behind next to the destination.
$ SIGINT delivered 250 ms after GET /slow.mp4   (base-sigint-a)
exit: null signal: SIGKILL  after 2089 ms
stderr: Command interrupted by SIGINT. Waiting for cleanup before exiting.
stdout: <empty>
destination: 'existing-video'  sha256=eaa36232e54003172b18e5daaceb4a5c46d27cd795d527f8e7e46f715762ec62
run dir: cli.stderr, cli.stdout, config.json, fs-safe-output-4XM9L7, output.mp4, server.log, state

head - 1.5 s body: nothing published

  • Same scenario as the first capture, one revision later.
$ SIGINT delivered 250 ms after GET /slow.mp4   (fix-sigint-fast)
exit: 130 signal: None  after 185 ms
stderr: Command interrupted by SIGINT. Waiting for cleanup before exiting.
stdout: <empty>
destination: 'existing-video'  sha256=eaa36232e54003172b18e5daaceb4a5c46d27cd795d527f8e7e46f715762ec62
run dir: cli.stderr, cli.stdout, config.json, output.mp4, server.log, state

head - 25 s body: exits with the interrupt's own status

  • No staging directory, no late stdout.
$ SIGINT delivered 250 ms after GET /slow.mp4   (fix-sigint-a)
exit: 130 signal: None  after 193 ms
stderr: Command interrupted by SIGINT. Waiting for cleanup before exiting.
stdout: <empty>
destination: 'existing-video'  sha256=eaa36232e54003172b18e5daaceb4a5c46d27cd795d527f8e7e46f715762ec62
run dir: cli.stderr, cli.stdout, config.json, output.mp4, server.log, state

head - SIGTERM: 143

$ SIGINT delivered 250 ms after GET /slow.mp4   (fix-sigterm)
exit: 143 signal: None  after 178 ms
stderr: Command interrupted by SIGTERM. Waiting for cleanup before exiting.
stdout: <empty>
destination: 'existing-video'  sha256=eaa36232e54003172b18e5daaceb4a5c46d27cd795d527f8e7e46f715762ec62
run dir: cli.stderr, cli.stdout, config.json, output.mp4, server.log, state

head - control run (no interrupt): still publishes

$ SIGINT delivered 250 ms after GET /slow.mp4   (fix-control)
exit: 0 signal: None  after - ms
stderr: <empty>
stdout: {
  "ok": true,
  "capability": "video.generate",
  "transport": "local",
  "provider": "deepinfra",
  "model": "Pixverse/Pixverse-T2V",
  "attempts": [],
  "outputs": [
    {
      "path": "/home/code/github/contributions/BUG/BUG-259-evidence/runs/fix-control/output.mp4",
      "mimeType": "video/mp4",
      "size": 19
    }
  ],
  "ignoredOverrides": []
}
destination: 'partial-video-bytes'  sha256=a76c07775674296496bded40bd6c4754777df0d43df0c62fcbe2bbff90744cd9
run dir: cli.stderr, cli.stdout, config.json, output.mp4, server.log, state

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 29, 2026
@clawsweeper

clawsweeper Bot commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR cancels provider-hosted video downloads on interruption and suppresses late capability-command output.

Example: Send SIGTERM while downloading a 67,113,789-byte generated MP4 through openclaw infer video generate --output output.mp4 --json.

  • Before: The download continues until the launcher kills the process, leaving partial staging output.
  • After: The transfer closes, staging is removed, and the CLI exits 143 without a success envelope.

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) A narrow repair with exact-head shipped CLI proof, preserved output contracts, and no actionable findings; normal CI remains pending.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (live_output): Exact-head full builds exercise the shipped inference CLI, bundled provider, real HTTP transfer, and atomic output in secretless Docker; accepted SIGINT/SIGTERM close transfers without staging or success output, while completed controls publish the complete matching MP4.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: After the CLI accepts Ctrl-C or SIGTERM, a generated-video download continues and may leave staging output or report late success.
Reason: Cancellation restores the existing invocation lifecycle contract without adding configuration, public APIs, or another output owner.

Merge readiness

✅ Ready for maintainer review

Keep open: this PR provides a focused, proven fix for a current-main interruption bug, with no actionable correctness findings.

Priority: P2
Reviewed head: e5e1fee04823ab1deb8a9c98699d477baf96aea8

Before merge

None.

Findings

None.

Agent review details

How this fits together

The inference CLI receives generated video URLs, downloads them through the guarded HTTP client, and publishes completed files through the existing atomic-output owner; the invocation lifecycle owns cancellation and exit status.

flowchart TD
  A[Inference CLI] --> B[Video provider]
  B --> C[Guarded URL download]
  C --> D[Atomic output publication]
  D --> E[Command result]
  F[Invocation cancellation] --> C
  F --> E
Loading

Technical review

Best possible solution:

Reuse invocation cancellation throughout video downloading while retaining the existing atomic publication and signal-exit owners.

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

Current-main source exposes the uncancelled download path, and the supplied full-build comparison reproduces continued transfer and leftover staging after accepted signals; this review ran no target code.

Is this the best way to solve the issue?

The patch is the smallest complete production repair: propagate the existing signal through download and streaming, reject cancelled publication handoffs, and let the existing lifecycle owner settle exit status.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 74f111a74dbd.

Provenance checked

  • Video validation and atomic output keeps the original intent (83fa625: Reject invalid downloads and preserve an existing destination when a provider stream fails.)
  • Shared capability result emission changes intended behavior with a stated reason (fd3914e: Consolidate command execution and output while preserving public CLI behavior.)
  • Inference runtime lazy loading keeps the original intent (c425798: Keep help and command discovery independent of provider execution runtimes.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

  • Exact introduced change: The pinned merge-base-to-head diff passes the existing invocation signal to fetch and pipeline, checks interruption before publication handoffs, and suppresses output after cancellation. (src/cli/capability-cli/video.ts:130, e5e1fee04823)
  • Current main still has the defect: Current main supplies no invocation signal to the video download or streaming pipeline, and its capability wrapper emits the completed result without checking interruption. (src/cli/capability-cli/video.ts:124, 74f111a74dbd)
  • Existing lifecycle ownership: The executable interruption gate already closes invocation work with an AbortError, and the signal owner records exit codes 130 and 143 after cleanup; the PR reuses that contract. (src/cli/runtime-cleanup-scope.ts:90, e5e1fee04823)
  • Exact-head shipped CLI proof: The full-build proof by obviyus exercises the public CLI and bundled DeepInfra provider in secretless Node 24 Docker against a slow valid MP4 fixture. SIGINT and SIGTERM close candidate transfers, remove staging, and preserve signal exit status; completed controls replace existing output with matching complete bytes. fix(cli): stop capability video downloads on interrupt #187563 (comment). (e5e1fee04823)
  • Prior atomic-output contract: Merged fix(cli): reject incomplete hosted video downloads #117893 established validation and atomic publication for failed provider streams; this PR preserves that owner and handles the distinct accepted-interruption path. (src/cli/capability-cli/video.ts, 83fa625fb63a)
  • CI state and failure attribution: GitHub reports the reviewed head mergeable, with CI still pending. The failed PR context check requests prescribed body headings despite the supplied problem statement and behavior evidence; it identifies no source defect. (e5e1fee04823)

Likely related people:

  • Peter Steinberger: Raw commit fd3914e adds src/cli/capability-cli/providers-command.ts:11 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: fd3914e0af3f; files: src/cli/capability-cli/providers-command.ts)
  • Tak Hoffman: Raw commit ac66939 adds docs/cli/infer.md:2 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: medium; commits: ac6693986bbf; files: docs/cli/infer.md)

PR surface

Source +25, Tests +96, Docs 0. Total +121 across 5 files. Added test files: 1.

View PR surface stats
Area Files Added Removed Net
Source 2 32 7 +25
Tests 2 111 15 +96
Docs 1 1 1 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 5 144 23 +121

Review metrics

Metric Value Why it matters
Production versus test LOC Production +32/-7; tests +111/-15 Production growth connects existing lifecycle owners; test growth extends the existing atomic-output case with cancellation before and during transfer without adding registered tests.

Labels

Label changes:

No label changes.

Label justifications:

  • P2: Accepted interruption leaves a video download running and can leave staging output, with limited impact on an advanced CLI workflow.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • proof: sufficient: Contributor real behavior proof is sufficient.

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.

History

Review history (1 earlier review cycle)
  • reviewed 2026-10-29T10:10:53.593Z sha ddc98d6 :: needs maintainer review before merge. :: none

Reviewed October 29, 2026, 7:16 AM ET / 11:16 UTC (Revision 2).

@obviyus

obviyus commented Oct 29, 2026

Copy link
Copy Markdown
Collaborator

Full-build interruption proof

Candidate: e5e1fee04823ab1deb8a9c98699d477baf96aea8 (tree d6c743fde645da94d692bc0b75a460b8485813bf). Frozen main: 409b16cc2904bdc4468471ea9ccd48eb1b744172.

Both complete source trees were independently installed and built with scripts/build-all.mts runtime inside a secretless node:24.22.1 Docker container. The final candidate was rebuilt in full after the last source edit; no module-swapping proof. Public openclaw.mjs infer video generate --output ... --json used the bundled DeepInfra provider against a loopback HTTP service fixture, with supported per-provider request.allowPrivateNetwork. No paid upstream service was involved.

Fixture: a real ffmpeg-generated MP4 with a valid padding box, 67,113,789 bytes; ffprobe validated the fixture and completed output. Slow responses sent 128 KiB per 100 ms. Signals were delivered only after an HTTP transfer and on-disk staging were in progress. No clock changes or observer force-kills.

Build Signal/repeat Exit Signal-to-close Result
main SIGINT 1 launcher SIGKILL 2268 ms downloaded another 1,703,936 bytes; 2,228,224-byte staging file remained
main SIGINT 2 launcher SIGKILL 2303 ms downloaded another 1,703,936 bytes; 2,228,224-byte staging file remained
main SIGTERM 1 launcher SIGKILL 2101 ms downloaded another 1,310,720 bytes; 1,703,936-byte staging file remained
main SIGTERM 2 launcher SIGKILL 2194 ms downloaded another 1,310,720 bytes; 1,703,936-byte staging file remained
candidate SIGINT 1 130 36 ms no target, no staging, no success envelope
candidate SIGINT 2 130 41 ms no target, no staging, no success envelope
candidate SIGTERM 1 143 45 ms no target, no staging, no success envelope
candidate SIGTERM 2 143 45 ms no target, no staging, no success envelope

Every interrupt logged the accepted command interruption; candidate HTTP transfers closed. Both no-signal controls exited 0, atomically replaced an existing target with the complete matching SHA-256/size video, and emitted the expected output envelope. This reproduction demonstrates continued transfer and leftover staging on main, not a partially published final target.

Focused checks: formatting passed for all four changed TypeScript files; node scripts/run-vitest.mjs src/cli/capability-cli.test.ts passed 103/103. Registered test growth is 0: the existing atomic-output case now covers stream failure plus before/during-transfer cancellation. Contributor commits retained; no public SDK export or helper added.

Scope: provider-generation lifetime, already-started buffered writes, already-published renames, and earlier assets in a multi-video result are not changed. The fix owns cancellation during provider-URL download and suppresses late command success after an accepted stop.

@obviyus

obviyus commented Oct 29, 2026

Copy link
Copy Markdown
Collaborator

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@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. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 29, 2026
@obviyus
obviyus merged commit c54e9a1 into openclaw:main Oct 29, 2026
139 of 143 checks passed
@obviyus

obviyus commented Oct 29, 2026

Copy link
Copy Markdown
Collaborator

Landed in c54e9a1. Thanks @SunnyShu0925. Interrupted video downloads now stop cleanly.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 30, 2026
fix(cli): stop video downloads cleanly on Ctrl-C and SIGTERM

An interrupted video download kept downloading and left its staging file behind. The download now uses the existing invocation signal, as other accepted CLI reads do since openclaw#187504. It stops on the first signal, leaves no target or staging file, prints no success result and exits with 130 or 143.

Evidence: full builds on Node 24.22.1 with a real slow MP4 download through the bundled DeepInfra provider. On main the download continued and the staging file stayed after SIGINT and after SIGTERM (twice each); with this change the CLI exited 130 or 143 in 36 to 45 ms with no target, staging file or success output (twice each). Completed-download controls pass on both refs. Details: openclaw#187563 (comment).

Thanks @SunnyShu0925.

Co-authored-by: SunnyShu <0668000539@local>
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 docs Improvements or additions to documentation P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. size: S status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants