Skip to content

fix(tts): preserve literal directives in Markdown code - #138319

Merged
steipete merged 1 commit into
mainfrom
codex/qa-tts-code-regions-20260904
Sep 4, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/qa-tts-code-regions-20260904

Conversation

@steipete

@steipete steipete commented Sep 4, 2026

Copy link
Copy Markdown
Contributor
Additional instructions

Maintainers can update this branch through normal repository access.

What Problem This Solves

Fixes an issue where assistant replies containing literal TTS syntax inside Markdown code lost part of the example and recorded unintended speech directives. Unclosed fences, false closing fences, longer enclosing fences and multiline inline code all reproduced the corruption, even with automatic speech disabled.

Why This Change Was Made

The final-text TTS owner had a separate regex-based Markdown scanner. It now uses the existing canonical code-region replacement helper while preserving its five-pass order, capture coercion and first-text/provider precedence. The duplicate range type, four-pattern scanner, membership check and replacement adapter are deleted: production +9/−55, net −46; tests +30/−10, net +20.

The affected owner is also present in stable v2026.9.1. This changes neither configuration nor stored fact shape. The canonical parser follows the existing Markdown code-preservation contract.

User Impact

Literal examples remain intact in the saved assistant transcript and Control UI, and do not become speech instructions. Active directives outside code retain their existing behavior.

Evidence

  • Four intended failures on unchanged code, with 26 passing controls. The final candidate passes 64 focused tests across TTS directives, shared directive tags and captioned finals, including quoted and indented code siblings.
  • A normal isolated Gateway executes sessions.create → chat.inject → final event → chat.history before and after. All four corruptions are repaired; simple code, active-TTS and ordinary-text controls retain their behavior. Final events match saved history in every case. Two separate escaped-custom-tag hypotheses remain unchanged and unqualified.
  • Actual Chrome renders the same synthetic example against the normal Gateway and a byte-matched Control UI build. Before, the literal [[tts:text]] example disappears; after, it remains visible. Each phase needed one ordinary reload after the initial browser-handoff connection failure. Owned tabs, Gateways and listeners were closed. This is Gateway/transcript/UI proof, without external model-service or synthesized-audio claims.
  • Independent managed P2 review: no findings, confidence 0.90. The review's pending Gateway-after/UI evidence was subsequently completed with the same source hashes. The full canonical changed-file gate passed in 440.22 seconds. The seven consequential owners are unchanged between the reviewed base and main 4a4b39734084529d59584fe9e7f184db3b1c3d09.

Before:

Before: literal TTS code is removed

After:

After: literal TTS code is preserved

Correctness has a measured parsing cost: five canonical Markdown passes retain the existing directive ordering. Warm ten-call medians for 4/16/65 KiB TTS-containing code were 0.034/0.099/0.374 ms before and 3.382/11.484/48.386 ms after (65 KiB maximum 95.61 ms). Ordinary text without TTS retains its early return. This PR makes no performance improvement claim and adds no cache or alternate parser.

Connected follow-up: the optional incremental TTS stream cleaner has the same code-preservation gap when model overrides/automatic TTS enable it. An actual ACP dispatcher-to-delivery probe preserves that evidence. This final-text repair does not fix incremental stream delivery; that path needs shared stable-span ownership for incomplete Markdown and hidden directive blocks, rather than another regex scanner. It is tracked as part of the same invariant, not a separate bug count.

Release-note context: preserve literal TTS syntax in Markdown code examples in assistant final messages and avoid extracting unintended speech facts.

@steipete steipete self-assigned this Sep 4, 2026
@clawsweeper

clawsweeper Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

@openclaw-barnacle openclaw-barnacle Bot added size: S maintainer Maintainer-authored PR labels Sep 4, 2026
@steipete
steipete marked this pull request as ready for review September 4, 2026 14:19
@steipete

steipete commented Sep 4, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper review

The initial completed review has not published yet. Exact-head CI is green for 22cac47327f685f01c2b5dccd24b71e84c3923bb. The PR includes four original failures, 64 focused tests, a complete changed-file gate, independent review, normal Gateway final/history proof, and inspected before/after Control UI screenshots. The parser cost and separate incremental-stream limitation are explicit. Please complete the review required by the native merge gate.

@clawsweeper

clawsweeper Bot commented Sep 4, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@sylvesterkaczmarek sylvesterkaczmarek left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consolidating on the canonical Markdown code-region owner is the right correctness move; the duplicate regex scanner was exactly the kind of parser drift that creates fence and inline-code edge cases. I am less comfortable treating the measured ~48 ms median / ~96 ms max at 65 KiB as incidental, though. Since final-text processing runs multiple directive passes, it would be worth seeing whether the code-region map can be computed once and reused without creating a second parser. I would track that as a bounded performance follow-up rather than weakening this correctness fix.

@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Sep 4, 2026
@clawsweeper

clawsweeper Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 4, 2026, 10:42 AM ET / 14:42 UTC.

ClawSweeper review

What this changes

The PR replaces final-text TTS directive extraction’s local Markdown code scanner with the shared Markdown-aware helper and adds coverage for complex literal-code examples.

Regression provenance

Possible regression — suspected (reviewed change). No predecessor PR is attributed.

Merge readiness

✅ Ready for maintainer review

Keep open. Current main still uses the narrow local scanner, while this focused PR routes final-text TTS extraction through the existing Markdown-aware helper; no blocking correctness or security findings were found.

Priority: P2
Reviewed head: 22cac47327f685f01c2b5dccd24b71e84c3923bb

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused, net-negative owner-boundary repair with behavior-oriented regression coverage and no supported blocking concern.
Proof confidence 🌊 off-meta tidepool Not applicable: This maintainer-authored PR is exempt from the external-contributor proof gate; its supplied context additionally describes gateway/history and Control UI before/after evidence for the changed final-text path.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This maintainer-authored PR is exempt from the external-contributor proof gate; its supplied context additionally describes gateway/history and Control UI before/after evidence for the changed final-text path.
Evidence reviewed 7 items Current main still needs the repair: Current main retains the local regex scanner, including only closed triple-backtick, tilde, indentation, and single-line inline patterns; it does not use the shared Markdown parser.
Repair is at the final-text owner: The branch changes the extraction owner to invoke the canonical code-region helper for every TTS directive pass, preserving existing directive ordering and fact construction.
Shared helper contract: The reused helper obtains code regions and leaves a regex match unchanged when its directive opener lies inside one; Markdown Core supplies those regions.
Findings None None.
Security None None.

How this fits together

Assistant final text is normalized into cleaned transcript text plus TTS delivery facts before gateway delivery and UI history rendering. The shared directive helper uses Markdown code regions so literal examples remain text while directives outside code remain active.

flowchart LR
A[Assistant final text] --> B[Delivery directive processing]
B --> C[TTS fact extraction]
C --> D[Markdown code-region helper]
D --> E[Cleaned text and TTS facts]
E --> F[Gateway final event]
E --> G[Transcript and Control UI]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source -46, Tests +20. Total -26 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 1 9 55 -46
Tests 1 30 10 +20
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 39 65 -26

Review metrics

Metric Value Why it matters
Production vs test delta production -46, tests +20 The fix deletes the duplicate scanner while adding seven behavior-oriented code-region cases, so it adds no production surface.

Technical review

Best possible solution:

Land the owner-boundary refactor so all final-text TTS passes share the established Markdown code-region contract; keep the separate incremental stream cleaner as follow-up work rather than adding another scanner here.

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

Yes—source establishes the gap: current main’s local patterns cannot model unclosed, quoted, longer, false-closing, or multiline CommonMark code regions, while the shared Markdown parser does and the added parser-level cases exercise them.

Is this the best way to solve the issue?

Yes—the final-text extraction owner is the correct boundary, and reuse of the existing Markdown-aware directive helper removes duplicated parsing policy without changing TTS facts, configuration, or provider routing.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 523221e3767f.

Labels

Label changes:

  • add P2: This fixes a bounded but user-visible corruption of literal final-message examples and unintended TTS facts.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This maintainer-authored PR is exempt from the external-contributor proof gate; its supplied context additionally describes gateway/history and Control UI before/after evidence for the changed final-text path.

Label justifications:

  • P2: This fixes a bounded but user-visible corruption of literal final-message examples and unintended TTS facts.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This maintainer-authored PR is exempt from the external-contributor proof gate; its supplied context additionally describes gateway/history and Control UI before/after evidence for the changed final-text path.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit 7a3f40c adds src/tts/directive-facts.ts:52 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 7a3f40c4ac4c; files: src/tts/directive-facts.ts)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

@steipete
steipete merged commit 8d94ab0 into main Sep 4, 2026
249 checks passed
@steipete
steipete deleted the codex/qa-tts-code-regions-20260904 branch September 4, 2026 14:51
@steipete

steipete commented Sep 4, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

vincentkoc added a commit that referenced this pull request Sep 4, 2026
…9-prep

* commit '407a8f453c0f0306af1ddc0aafa8697c1d49a9e7': (312 commits)
  perf(ui): coalesce automation event refreshes (#138065)
  fix: reject incomplete Skill Workshop directory reads (#138082)
  test(ui): decouple rendering checks from generated wording (#138283)
  perf: avoid temporary entries in bounded JSON traversal (#138017)
  fix(irc): render complete messages before splitting (#138328)
  perf: prepare worker trajectory payloads only for recorded events (#138086)
  fix(mcp): paginated listings no longer time out after a forward clock step (#137206)
  fix(codex): page native transcripts and bound UI previews (#136282)
  feat(gateway): apply more settings without restarting (#138112)
  fix(docs): preserve mirrored ClawHub maturity links (#138241)
  fix(test): own UI animation and legacy database setup (#138296)
  fix(tts): preserve literal directives in Markdown code (#138319)
  fix: load chat widgets behind authenticated gateways (#138074)
  chore(ui): cover native approval finalization (#137259)
  fix(cron): cancel conditions before main-session handoff (#138313)
  fix(backup): preserve text after embedded NUL characters (#138327)
  fix(android): align composer control sheets (#137442)
  fix(ci): wait for replacement PR runs instead of stale failures (#138307)
  fix(sessions): keep Gateway responsive with long transcripts (#138094)
  fix(computer): map window inputs to delivered image coordinates (#138271)
  ...

# Conflicts:
#	scripts/release-check.ts
#	test/release-check.test.ts
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

maintainer Maintainer-authored PR P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary 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