Skip to content

fix(tts): preserve free-text [[tts:...]] reply across final and caption delivery (#137281) - #137329

Merged
obviyus merged 8 commits into
openclaw:mainfrom
wangyan2026:fix/tts-free-text-reply-137281
Oct 13, 2026
Merged

obviyus merged 8 commits into
openclaw:mainfrom
wangyan2026:fix/tts-free-text-reply-137281

Conversation

@wangyan2026

@wangyan2026 wangyan2026 commented Sep 3, 2026 •

Copy link
Copy Markdown
Contributor

Closes #137281

What Problem This Solves

Fixes lost answers and missing voice-note caption text when automatic TTS receives a model reply wrapped in a free-text [[tts:...]] tag.

User Impact

Wrapped speech remains visible in the reply and Telegram voice-note caption instead of disappearing or becoming an empty-reply error. Real key=value directives, reserved tts:text markers, hidden speech blocks, and existing code-caption behavior remain unchanged. No configuration or stored-data migration is required.

Why This Change Was Made

Final parsing and streaming cleanup now use one free-text body classification. Recovery is guarded by the existing incremental Markdown scanner so code-literal bodies do not become newly visible prose. Hidden speech does not advance that scanner, and fence-state updates retain the full tag context that distinguishes code content from a closing fence. This is not the separate repair for existing code-caption stripping.

Redundant caption-wrapper tests were removed. Retained cases cover final parsing, multiline/leading-newline bodies, stream boundaries, code-literal parity, hidden speech, non-closing fence lines, and the ACP dispatcher.

Thanks to @wangyan2026 for the contributor fix and @eiriktorheim for the report. No overlap with Pash/Sarah changes was found in the affected files.

Evidence

Built, isolated Gateway; real Telegram Test Server userbot; automatic TTS in final mode. A scripted model supplied five requested replies, and a local speech endpoint supplied a one-second Opus fixture. These are native Telegram messageVoiceNote observations, not mocked channel delivery. Each next model fixture waits for the previous native reply. Speech requests used the expected input text; the key=value control selected the requested alloy voice.

Baseline: fda581a1f5587726b01b7f11ad00da53a7fd7cbd. Its two production TTS files are unchanged in the merged main. Candidate: 5cecfc4bfa3dc2a42a981add02a7dd2262fe17ae.

Recorder timeline excerpts (elapsed from each recorder's start):

Scripted reply Baseline voice caption Candidate voice caption
[[tts:Here is your answer]] Visible text. +6.167s: Visible text. +30.884s: Here is your answer Visible text.
[[tts:Here is your answer]] +15.891s: empty-response warning, Agent couldn't generate a response. Please try again. +34.152s: Here is your answer
[[tts:voice=alloy]] Directive control. +27.410s: Directive control. +38.711s: Directive control.

The fenced-code control containing [[tts:Here is your answer]] was identical on baseline (+38.439s) and candidate (+42.099s):

Code example:



Code control.

The existing stripping of the literal code example is intentionally unchanged, rather than converting its body into prose.

The speech-only Markdown control was also unchanged:

[[tts:text]]Press the ` key.[[/tts:text]] Visible. [[tts:text]]Audio only.[[/tts:text]]

Both baseline (+50.708s) and candidate (+51.661s) delivered only Visible.. Neither hidden body nor its tags appeared in the caption. Focused tests also cover a chunk boundary after the first hidden block and fence lines with trailing bracket markup. The longer final recording includes a later default heartbeat alert; it is outside the five native reply receipts above. A preliminary 60-second recording timed out during cold startup; the final run used a 180-second recording window.

Focused verification: 93 tests passed across the parser, streaming cleaner, caption helper and ACP dispatcher suites (61.00s wall time). Targeted Oxfmt/Oxlint, the isolated build, and git diff --check passed. Before the fix, eight focused parser/streaming cases failed because the wrapped body was removed.

A separate real-provider check through the built CLI used OpenAI gpt-5-mini with minimal reasoning. It returned Here is your answer Visible text. with a successful assistant attempt, no fallback, and a visible terminal reply. Credentials and all Gateway state were isolated; leases and secret files were released/removed after the runs.

Patch size against the merge base: production +52/-10 (net +42), tests +101/-1 (net +100). Production growth is the shared classification and code-context guard; no new parsing subsystem. The original +177 test-line surface is reduced to the distinct cases above.

Merge risk: two-way door; reverting restores the prior text behavior without migrating state. Blast radius is free-text TTS recovery in automatic replies and their streamed/deferred captions.

@clawsweeper

clawsweeper Bot commented Sep 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.

@clawsweeper clawsweeper Bot added P1 High-priority user-facing bug, regression, or broken workflow. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. proof: telegram-e2e This PR needs Telegram Test Server proof with the repository E2E skill. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Sep 3, 2026
@clawsweeper

clawsweeper Bot commented Sep 3, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

The PR preserves free-text TTS tag bodies in final replies and voice-note captions while retaining directive and hidden-speech handling.

Example: Automatic TTS receives [[tts:Here is your answer]].

  • Before: The answer disappears and delivery produces an empty-response warning.
  • After: The reply and Telegram voice-note caption contain Here is your answer.

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) A focused, valuable repair with supplied shipped-entry-point proof, distinct regressions, unchanged stored fact shape, and no remaining verified finding.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (logs): Supplied recorder-output excerpts exercise the changed TTS owners through a built isolated Gateway and native Telegram Test Server delivery on the reviewed head: wrapped-only and mixed replies recover their captions, with directive, code, and hidden-speech controls retaining baseline behavior; a built-CLI provider run corroborates visible reply recovery.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: A model's free-text TTS wrapper causes an otherwise valid answer to disappear from the reply and voice-note caption.
Reason: The report and deployment confirmation establish lost answers; the focused repair preserves existing directives, hidden speech, and code-caption behavior without changing settings or public APIs.

Merge readiness

✅ Ready for maintainer review

Keep this PR open: it repairs confirmed reply loss that remains on current main, has relevant live behavior evidence, and resolves the previous finding without introducing a verified defect.

Priority: P1
Reviewed head: 5cecfc4bfa3dc2a42a981add02a7dd2262fe17ae

Before merge

None.

Findings

None.

Agent review details

How this fits together

Assistant text enters the shared TTS parser and streaming cleaner; cleaned visible text and existing speech facts feed transcript storage, synthesis, and channel delivery.

flowchart LR
  A[Assistant text] --> B[TTS fact parser]
  A --> C[Streaming cleaner]
  B --> D[Transcript and speech facts]
  C --> E[Visible reply and caption]
  D --> F[Speech synthesis]
  E --> G[Channel delivery]
  F --> G
Loading

Technical review

Best possible solution:

Land the shared parser-and-caption repair through the existing PR after its required checks pass.

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

Current-main source deterministically removes [[tts:Here is your answer]] at both affected boundaries; the linked report adds official-release deployment confirmation, and this review executed no target code.

Is this the best way to solve the issue?

Repairing the existing shared owners covers both transcript preparation and deferred captions; changing prompt wording alone would leave the destructive parsing behavior reachable.

AGENTS.md: found and applied where relevant.

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

Provenance checked

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

  • Current main retains the defect: The current-main colon-tag parser skips tokens without an equals sign and unconditionally removes their text; its streaming cleaner also removes free-text colon tags. Both production files are unchanged between the pinned base and fetched main. (src/tts/directive-facts.ts:59, d75796172a24)
  • Shared repair at both affected boundaries: The introduced patch uses resolveTtsDirectiveBody in final extraction and streaming cleanup, preserving visible speech while leaving reserved text markers and equals-bearing directive bodies on their existing paths. (src/tts/directive-facts.ts:7, 5cecfc4bfa3d)
  • Previous finding addressed: Compared with the previous reviewed head, scanner updates now retain complete tag context when code ownership requires it. Added cases cover non-closing fence lines followed by ordinary markup or a TTS directive; hidden speech remains excluded from visible Markdown state. (src/tts/directives.ts:151, 5cecfc4bfa3d)
  • Supplied production-entry-point proof: The complete PR body records native Telegram Test Server voice-note receipts from an isolated built Gateway on the reviewed candidate: free-text-only and mixed replies retain their captions, while voice selection, fenced-code stripping, and hidden-speech controls retain baseline behavior. It also records a successful built-CLI provider run. (5cecfc4bfa3d)
  • Independent deployment confirmation: tts: a free-text [[tts:...]] reply is stripped to nothing and delivered as "No reply was generated" #137281 (comment) credits vobornik's confirmation on official OpenClaw 2026.9.2 and successful WhatsApp production recovery after backporting this PR's parser and cleaner changes; the original reporter also supplied a recovery-plugin workaround.
  • Feature history and original intent: The streaming cleaner was introduced to hide speech directives; the later structured-speech change retained that transitional adapter and made transcript-boundary facts authoritative. The patch preserves that ownership and serialization contract. (src/tts/directives.ts:102, cf834e2a21ea)

Likely related people:

  • Peter Steinberger: Raw commit cf834e2 adds src/tts/directives.ts:142 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: cf834e2a21ea; files: src/tts/directives.ts)
  • Bartok: Raw commit 12fa7d4 adds src/tts/directives.ts:149 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 12fa7d44cde3; files: src/tts/directives.ts)

PR surface

Source +42, Tests +100. Total +142 across 5 files. Added test files: 1.

View PR surface stats
Area Files Added Removed Net
Source 2 52 10 +42
Tests 3 101 1 +100
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 5 153 11 +142

Review metrics

Metric Value Why it matters
Production versus regression coverage Production +52/-10; tests +101/-1 Production growth supplies shared body classification and Markdown state tracking; retained tests cover final extraction, streaming boundaries, hidden speech, fence context, and ACP caption delivery.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #137281
Summary: The canonical report identifies free-text colon-tag reply loss, and this PR repairs both responsible boundaries.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Labels

Label changes:

  • add rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • remove rating: 🦐 gold shrimp: Current PR rating is rating: 🦞 diamond lobster, so this older rating label is no longer current.
  • remove status: ⏳ waiting on author: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • P1: Confirmed automatic voice-reply workflows can lose the entire assistant answer, and current main still contains the responsible paths.
  • 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.
  • proof: telegram-e2e: This PR needs Telegram Test Server proof with the repository E2E skill. The PR changes Telegram voice-note captions; the supplied native Test Server receipts exercise that behavior.

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 (11 earlier review cycles; latest 8 shown)
  • reviewed 2026-09-03T14:41:36.302Z sha e61143a664f2b3b75e19cbc9e2572f4b28ab627c :: needs real behavior proof before merge. :: [P1] Accept leading-newline free-text TTS bodies
  • reviewed 2026-09-04T01:08:54.829Z sha 09631ee70e39366ca266c86f1ac339ba8e74877e :: needs real behavior proof before merge. :: none
  • reviewed 2026-09-23T04:52:29.470Z sha 09631ee70e39366ca266c86f1ac339ba8e74877e :: needs real behavior proof before merge. :: none
  • reviewed 2026-10-07T22:43:36.977Z sha 09631ee70e39366ca266c86f1ac339ba8e74877e :: needs real behavior proof before merge. :: none
  • reviewed 2026-10-07T22:51:46.428Z sha 09631ee70e39366ca266c86f1ac339ba8e74877e :: needs real behavior proof before merge. :: none
  • reviewed 2026-10-08T09:46:13.214Z sha bcc0136 :: needs real behavior proof before merge. :: none
  • reviewed 2026-10-13T15:24:48.476Z sha 72b1bb1 :: needs changes before merge. :: [P2] Exclude speech-only bodies from visible Markdown scanner state
  • reviewed 2026-10-13T15:51:19.530Z sha 0304080 :: needs changes before merge. :: [P2] Keep trailing tag text in fence-state updates

Reviewed October 13, 2026, 12:12 PM ET / 16:12 UTC (Revision 12).

@wangyan2026
wangyan2026 force-pushed the fix/tts-free-text-reply-137281 branch 2 times, most recently from 9f33f3c to e61143a Compare September 3, 2026 14:32
@wangyan2026
wangyan2026 force-pushed the fix/tts-free-text-reply-137281 branch from e61143a to 09631ee Compare September 4, 2026 00:42
@obviyus obviyus self-assigned this Sep 6, 2026
@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. labels Sep 23, 2026
@openclaw-barnacle

Copy link
Copy Markdown

This assigned pull request has been automatically marked as stale after being open for 27 days.
Please add updates or it will be closed.

@openclaw-barnacle openclaw-barnacle Bot added the stale Marked as stale due to inactivity label Oct 1, 2026
…on delivery (openclaw#137281)

The inbound/automatic TTS hint can make a model wrap its spoken reply in a
single [[tts:<prose>]] tag. The parsed final path parsed no key=value tokens
and substituted empty text, and the deferred stream/caption cleaner treated
every colon tag as a directive and dropped the body — so the reply reached
the 'No reply was generated' fallback on immediate and deferred
(Telegram voice-note) delivery alike.

Add one shared predicate, bodyHasTtsDirectiveKeyValue: a colon body is speech
overrides only when some token is key=value. The final parser now keeps the
trimmed body as visible reply text when there is no directive value, and the
stream cleaner (cleanDeferredFinalText's engine) emits a bare colon tag with
no key=value as visible text, mirroring [[tts]]...[[/tts]] and
[[tts:text]]...[[/tts:text]]. Free-text colon grammar matches the parser:
any whitespace (including a line break) before/after the colon is accepted
and the body is trimmed, so a single-line, multi-line, or leading-newline
repro ([tts:\nhello]) stays visible on both owners. Real key=value
directives and hidden [[tts:text]] blocks keep their behavior.

A lone reserved [[tts:text]] marker (no [[/tts:text]] closer) is not treated
as free prose: it stays audio-only, is dropped without setting facts.text,
and surrounding prose stays visible, matching shipped main and the streaming
cleaner.

Regression: parsed, streamed, chunk-split, multiline, leading-newline-lone
marker parser and deferred-caption cases; captioned dispatch test fails on
main (visible caption emptied) and passes on head.
@wangyan2026
wangyan2026 force-pushed the fix/tts-free-text-reply-137281 branch from 09631ee to bcc0136 Compare October 8, 2026 09:40
@openclaw-barnacle openclaw-barnacle Bot removed the stale Marked as stale due to inactivity label Oct 9, 2026
@openclaw-barnacle

Copy link
Copy Markdown

This assigned pull request has been automatically marked as stale after being open for 27 days.
Please add updates or it will be closed.

@openclaw-barnacle openclaw-barnacle Bot added the stale Marked as stale due to inactivity label Oct 9, 2026
@obviyus

obviyus commented Oct 13, 2026

Copy link
Copy Markdown
Collaborator

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Oct 13, 2026
@obviyus

obviyus commented Oct 13, 2026

Copy link
Copy Markdown
Collaborator

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. labels Oct 13, 2026
@obviyus

obviyus commented Oct 13, 2026

Copy link
Copy Markdown
Collaborator

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Oct 13, 2026
@obviyus

obviyus commented Oct 13, 2026

Copy link
Copy Markdown
Collaborator

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added 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 rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Oct 13, 2026
@obviyus
obviyus merged commit 92b5443 into openclaw:main Oct 13, 2026
131 of 135 checks passed
@obviyus

obviyus commented Oct 13, 2026

Copy link
Copy Markdown
Collaborator

Landed in 92b5443. Thanks @wangyan2026! Verified on the Telegram Test Server: free-text [[tts:...]] replies now keep their text and voice-note caption, and real directives behave as before.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 14, 2026
…on delivery (openclaw#137281) (openclaw#137329)

fix(tts): keep free-text [[tts:...]] replies and voice captions

When the model wrote a free-text `[[tts:<spoken reply>]]` tag, final parsing and the deferred caption cleaner both discarded the body, producing an empty reply or a voice note with no caption. The parser and the stream cleaner now share one body classification, so free-text speech is kept as visible text and caption. Real key=value directives, hidden speech blocks, reserved markers and existing code-literal behavior are unchanged.

Proof: Telegram Test Server userbot with a built Gateway: on main the wrapped speech was lost from the voice caption; the candidate keeps combined and wrapped-only captions. The key=value, code-literal and hidden-speech controls match main.

Fixes openclaw#137281. Thanks @wangyan2026.

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

P1 High-priority user-facing bug, regression, or broken workflow. proof: sufficient ClawSweeper judged the real behavior proof convincing. proof: telegram-e2e This PR needs Telegram Test Server proof with the repository E2E skill. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. size: S stale Marked as stale due to inactivity 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.

tts: a free-text [[tts:...]] reply is stripped to nothing and delivered as "No reply was generated"

2 participants