Skip to content

fix(cli): preserve TTS output after accepted interruption - #191635

Merged
obviyus merged 2 commits into
openclaw:mainfrom
zhangguiping-xydt:fix/proof-round3-3
Nov 3, 2026
Merged

obviyus merged 2 commits into
openclaw:mainfrom
zhangguiping-xydt:fix/proof-round3-3

Conversation

@zhangguiping-xydt

@zhangguiping-xydt zhangguiping-xydt commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

openclaw infer tts convert --output speech.wav can create or overwrite the requested file after acknowledging SIGINT/SIGTERM. The CLI exits with the interrupt status and suppresses JSON, but still publishes the late audio copy.

User Impact

Interruption accepted before output copying begins now preserves an existing destination or leaves an absent destination absent. Normal conversion still writes the synthesized audio. Completed synthesis retains its existing media-store lifetime; already-started atomic output writes are unchanged.

Why This Change Was Made

The shared local/loopback-Gateway copy owner captures the existing invocation signal and checks it after reading source audio, immediately before entering the existing atomic writer. No provider-wide cancellation, new lifecycle machinery, public API/configuration, retention policy or writer change.

Original fix/report by @zhangguiping-xydt; their commit is retained. Same output-publication boundary as the image cancellation repair in #191176.

Evidence

Independently built main 7e005b019a532981e0102ace3cc6be0478fb2266 and unchanged contributor production in secretless Linux arm64 Node 24.22.1 Docker, with fresh isolated profiles/state and a local HTTP TTS fixture.

  • The real /v1/audio/speech response is held until the CLI acknowledges the signal, then releases a valid 2,044-byte PCM WAV.
  • Main twice: SIGINT overwrites an existing destination; SIGTERM creates an absent destination.
  • Candidate twice: SIGINT preserves the original hash; SIGTERM leaves the destination absent.
  • Exit codes remain 130/143 with empty stdout. All four normal controls exit 0 and write the same valid WAV bytes.
  • 104 focused capability tests pass. On main, only the two interrupted destination cases fail (102 others pass). The matrix also preserves atomic-copy-failure, format-correct output, canonical source bytes, modes and staging cleanup checks. Targeted Oxlint/Oxfmt pass.
  • Simplification reuses existing fixtures and one spy-cleanup owner, removes duplicate standalone setup and its allocation: production +5/-1 (net +4), tests +75/-79 (net −4), docs +1/-0 against merge base.

Detailed captured signal ordering, hashes and outcomes: independent proof comment.

Merge Danger

Two-way door: reverting restores the previous late-copy behavior; no persisted-state migration. Blast radius is local or loopback-Gateway TTS --output publication after accepted interruption. Synthesis retention and already-started atomic writes retain their existing behavior.

@clawsweeper

clawsweeper Bot commented Nov 3, 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 Nov 3, 2026
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug 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. labels Nov 3, 2026
@clawsweeper

clawsweeper Bot commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR prevents local and loopback-Gateway TTS output publication after the CLI has accepted interruption.

Example: Run openclaw infer tts convert --text "Hello" --output speech.wav, then send SIGINT before delayed synthesis finishes.

  • Before: The CLI acknowledges interruption and exits 130, but the returned audio overwrites speech.wav.
  • After: The CLI exits 130 and preserves the existing speech.wav bytes.

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) Focused repair with shipped-command before/after proof, retained regression boundaries, no migration requirement, and no introduced defect found.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (live_output): The independent proof comment exercises the built CLI through the real HTTP speech adapter in isolated Linux/Node profiles, releases valid WAV bytes only after SIGINT/SIGTERM acknowledgement, and records preserved or absent destinations, correct exit statuses, empty interrupted stdout, and successful normal controls; candidate production is unchanged at the reviewed head.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: An interrupted TTS command can overwrite or create the requested output despite acknowledging cancellation and exiting with an interrupt status.
Reason: A small check restores the existing cancellation contract at the output owner without changing providers, configuration, retention, or writes already underway.

Merge readiness

✅ Ready for maintainer review

This PR fixes a current TTS output cancellation defect with a focused change, convincing built-CLI proof, and no actionable review findings; exact-head CI remains pending.

Priority: P2
Reviewed head: abce9850c7f48e622799b10e392c6745098316f1

Before merge

None.

Findings

None.

Agent review details

How this fits together

The TTS CLI obtains synthesized audio locally or through a loopback Gateway, reads its source file, and publishes an explicitly requested destination through the shared atomic media writer.

flowchart TD
  A[TTS CLI command] --> B[Local synthesis or loopback Gateway]
  B --> C[Read synthesized audio]
  D[Invocation interruption signal] --> E[Check before publication]
  C --> E
  E --> F[Shared atomic media writer]
  F --> G[Destination audio file]
Loading

Technical review

Best possible solution:

Land the existing signal check at the shared TTS publication boundary once required checks pass.

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

Current-main source exposes the unchecked publication path, and the independently posted built-CLI comparison reproduces the destination changes after acknowledged signals; this read-only review ran no reproduction.

Is this the best way to solve the issue?

The patch is the smallest complete repair: reuse the invocation signal in the existing shared TTS copy owner while retaining source custody, format correction, and atomic publication.

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • TTS media publication keeps the original intent (7fcc86e: Route returned audio through the shared writer so file extensions match actual bytes while preserving atomic publication.)
  • Consolidated publication tests keeps the original intent (fix(cli): preserve TTS output on copy failure #117962: Protect existing destination bytes on failed TTS copies; later format coverage protects WAV output naming, and cleanup history favors distinct behavioral cases over repeated setup.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit 7fcc86e adds src/cli/capability-cli/tts-runtime.ts:118 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 7fcc86ef7866; files: src/cli/capability-cli/tts-runtime.ts)

PR surface

Source +4, Tests -4, Docs +1. Total +1 across 3 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 1 5 1 +4
Tests 1 75 79 -4
Docs 1 1 0 +1
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 3 81 80 +1

Labels

Label changes:

No label changes.

Label justifications:

  • P2: Accepted interruption can still overwrite a requested TTS output file; the defect is concrete and limited to this CLI publication flow.
  • 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-11-03T03:48:49.023Z sha 5a52b18 :: needs maintainer review before merge. :: none

Reviewed November 2, 2026, 11:26 PM ET / November 3, 2026, 04:26 UTC (Revision 2).

@obviyus

obviyus commented Nov 3, 2026

Copy link
Copy Markdown
Collaborator

Independent built-CLI TTS interruption proof

Final head: abce9850c7f48e622799b10e392c6745098316f1. Baseline main: 7e005b019a532981e0102ace3cc6be0478fb2266. Candidate runtime uses unchanged contributor production 5a52b18703ae3ea2639a9b5f383ad1efca6e0000; the follow-on commit consolidates tests. Original fix/report by @zhangguiping-xydt; ownership checked (unassigned contributor PR, maintainer edits enabled, sole mapped contributor commit retained).

Real shipped command and accepted-signal barrier

Independently built runtime artifacts in secretless Linux arm64 Node v24.22.1 Docker, fresh task-owned home/profile/config/state/workspace and a unique local HTTP TTS fixture for each case. The bundled OpenAI speech provider receives a synthetic key and explicit local base URL; no real credential or paid service.

node openclaw.mjs --profile <isolated-profile> infer tts convert
  --provider openai --text "Synthetic speech fixture"
  --output <workspace>/speech.wav --json

The fixture fully receives the real POST /v1/audio/speech, holds its response, and the driver sends SIGINT or SIGTERM to the CLI foreground process group. It waits for the CLI's own acknowledgement before releasing HTTP 200 with a valid 2,044-byte PCM WAV. All eight interrupted cases record acknowledgement before response release, not a timing sleep or private lifecycle call.

Actual acknowledgement strings:

Command interrupted by SIGINT. Waiting for cleanup before exiting.
Command interrupted by SIGTERM. Waiting for cleanup before exiting.

Observed outcomes

Case Main repeat 1 Main repeat 2 Candidate repeat 1 Candidate repeat 2
SIGINT; existing 48-byte destination Overwritten with WAV Overwritten with WAV Original hash preserved Original hash preserved
SIGTERM; destination absent WAV created WAV created Remains absent Remains absent
No signal; normal control Valid WAV written Valid WAV written Same valid WAV written Same valid WAV written

Every SIGINT case exits naturally with 130, every SIGTERM case with 143, no terminating exit signal, and empty stdout. Every control exits 0 with success JSON. Each case reaches exactly one real speech request; no watchdog fires.

Original destination SHA256 (48 bytes):
80e9fc4f83b61abdefec00ce4077445cc499234d75609d9e1a3cb9285cff5095

Returned/control WAV SHA256 (2,044 bytes):
ae1699164eaaad3d2c3ed75c4d8a39dba39b860d33973f97264fcff4a969f595

The returned WAV has RIFF/WAVE framing, PCM format 1, mono 16 kHz / 16-bit audio, and a correctly sized 2,000-byte data chunk. All four uninterrupted outputs are byte-identical. Both candidate SIGINT outputs retain the original bytes; both SIGTERM outputs are still absent after the delayed response and CLI exit.

Focused regression and simplification

  • 104 capability consumer tests pass. The consolidated loopback-Gateway output matrix covers successful format-correct copying, injected partial-copy failure, interruption after the real source read with an existing destination, and interruption with an absent destination. Canonical source bytes remain unchanged; existing-file modes and staging cleanup remain checked.
  • Same updated suite on main: 102 pass / 2 intended failures—interrupted-existing overwrites the destination, interrupted-absent creates result.wav. These are filesystem-outcome failures, not only error-class assertions.
  • Targeted Oxlint: zero warnings/errors. Oxfmt passes on all changed source/tests/docs.
  • Reused existing output fixtures and one suite-level spy cleanup owner; removed duplicate standalone regression setup and its allocation without dropping either destination boundary. Whole-change delta against merge base: production +5/-1 (net +4), tests +75/-79 (net −4), docs +1/-0.
  • Production captures the existing invocation signal and checks it after source reading, before entering the existing atomic writer. No new cancellation owner, provider API, retention policy, writer or public configuration. Already-started writes remain outside this boundary; synthesis audio retains its existing media-store lifetime.

@obviyus

obviyus commented Nov 3, 2026

Copy link
Copy Markdown
Collaborator

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 3, 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-repro Preliminary submission classification; full source review pending. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Nov 3, 2026
@obviyus
obviyus merged commit b655b24 into openclaw:main Nov 3, 2026
122 of 124 checks passed
@obviyus

obviyus commented Nov 3, 2026

Copy link
Copy Markdown
Collaborator

Landed in b655b24. Thanks @zhangguiping-xydt. Interrupted TTS commands no longer write the output file.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 4, 2026
…91635)

fix(cli): don't write TTS output after the command is interrupted

After a TTS command acknowledged SIGINT or SIGTERM, late audio from the provider was still written to `--output`, overwriting an existing file or creating a new one. The command now checks the existing cancellation signal after reading the audio and before the atomic write, so an interrupted run leaves the destination unchanged. Exit codes stay 130 and 143, and normal runs write as before.

Evidence: built CLI in secretless Node 24.22.1 Docker with a TTS endpoint that responded only after the signal was acknowledged. Main overwrote an existing file after SIGINT and created a missing file after SIGTERM, twice; with this change the original hash, or the absence of a file, was kept twice. All normal controls wrote identical valid WAV bytes. Details: openclaw#191635 (comment).

Thanks @zhangguiping-xydt.

Co-authored-by: Ayaan Zaidi <[email protected]>
RomneyDa added a commit that referenced this pull request Nov 17, 2026
Backport #191635 from b655b24.
Keep the existing CLI fixtures and add bounded interruption regressions.

Co-authored-by: xingzhou <[email protected]>
Co-authored-by: Ayaan Zaidi <[email protected]>
Co-authored-by: RomneyDa <[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