Repository navigation
fix(tts): hold a trailing lone bracket across stream chunks - #144161
Conversation
A chunk that ends on a single "[" never arms the [[ pending buffer, so the next chunk either leaks hidden [[tts:text]] speech or swallows the rest of the reply. Buffer that trailing "[" until the next push or flush.
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. Reviewed September 14, 2026, 10:25 PM ET / September 15, 2026, 02:25 UTC (Revision 8). ClawSweeper reviewWhat this changesPreserves split speech directives and trailing literal brackets across normal and external-agent reply streams, with prepared-payload recovery and registered delivery tests. Merge readiness✅ Ready for maintainer review This PR remains necessary: current main and v2026.9.4 still mishandle split brackets. The previous terminal-drain finding is resolved, the linked runtime evidence supports the repair, and no new blocking defect was found. Priority: P2 Review scores
Verification
How this fits togetherOpenClaw separates speech-only directives from visible assistant replies before sending streamed messages. Normal dispatch and external-agent dispatch use the shared cleaner and delivery receipts to coordinate text, audio, recovery, and transcript completion. flowchart TD
A[Assistant text chunks] --> B[Speech directive cleaner]
B --> C[Visible reply fragments]
B --> D[Buffered delimiter]
D --> E[Stream completion]
E --> C
C --> F[Ordered delivery receipts]
F --> G[Channel delivery or recovery]
F --> H[Transcript completion]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource +221, Tests +588. Total +809 across 13 files. View PR surface stats
Review metrics
Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Technical reviewBest possible solution: Keep one shared directive parser and source receipt, with each existing delivery lifecycle draining and recovering only its undelivered prepared fragments. Do we have a high-confidence way to reproduce the issue? Yes: current source deterministically mishandles chunks split between the two opening brackets of either delimiter. This review inspected source and supplied runtime captures; it did not execute target code. Is this the best way to solve the issue? Yes: buffering the delimiter and draining through existing delivery owners repairs the documented behavior without new configuration, public APIs, or competing recovery state. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 38c4aa42e4ce. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (7 earlier review cycles)
|
…g prefixes (#148301) Depends on #148318. ## What Problem This Solves A streamed prefix could mark the complete reply sent. If its deferred tail then failed, the final reply was already gone. ## Why This Change Was Made One source receipt owns completion, ordered sends, and final recovery; this state has one writer. Completed sources, including fenced code, are not replayed. Pending sends retain custody. ## User Impact Missing tails recover once, in order. Completed finals are cleared. Safe text and media still send immediately. Final-only media still sends when text is ambiguous, without changing its unknown state. ## Evidence `node scripts/run-vitest.mjs src/auto-reply/reply/dispatch-from-config.source-completion.test.ts`: before, `See `; after, `See [` once. Fifteen producer cases and 410 sibling tests passed, including ambiguous text with unsent media. With a real Gateway and Discord adapter against a local mock server, main lost a buffered literal tail; this head retained it for one queue recovery after the final send was refused, without replaying the prefix or its image bytes. Live Discord closing proof was composed with #144161's parser commit `8b02f015`; that dependency is excluded here. ## Compatibility No configuration, protocol, storage, or SDK export changes. Parser and terminal drains remain separate work. ## Consumers Normal dispatch, ACP delivery, and direct/final reply accounting share the receipt. ## Invalidation Receipts live for one source and remain reachable through its final settlement. ## Tests Existing split-text fixtures now provide actual delivery settlements. Their assertions are unchanged. ## Contention A concurrent suffix stays behind a failed prefix; safe block admission does not await transport settlement. Co-authored-by: Ayaan Zaidi <[email protected]>
|
landpr-approve-admin-merge |
|
Thanks @Bartok9! Proof: Discord streaming checks preserve split speech tags and the literal
|
…g prefixes (openclaw#148301) Depends on openclaw#148318. ## What Problem This Solves A streamed prefix could mark the complete reply sent. If its deferred tail then failed, the final reply was already gone. ## Why This Change Was Made One source receipt owns completion, ordered sends, and final recovery; this state has one writer. Completed sources, including fenced code, are not replayed. Pending sends retain custody. ## User Impact Missing tails recover once, in order. Completed finals are cleared. Safe text and media still send immediately. Final-only media still sends when text is ambiguous, without changing its unknown state. ## Evidence `node scripts/run-vitest.mjs src/auto-reply/reply/dispatch-from-config.source-completion.test.ts`: before, `See `; after, `See [` once. Fifteen producer cases and 410 sibling tests passed, including ambiguous text with unsent media. With a real Gateway and Discord adapter against a local mock server, main lost a buffered literal tail; this head retained it for one queue recovery after the final send was refused, without replaying the prefix or its image bytes. Live Discord closing proof was composed with openclaw#144161's parser commit `8b02f015`; that dependency is excluded here. ## Compatibility No configuration, protocol, storage, or SDK export changes. Parser and terminal drains remain separate work. ## Consumers Normal dispatch, ACP delivery, and direct/final reply accounting share the receipt. ## Invalidation Receipts live for one source and remain reachable through its final settlement. ## Tests Existing split-text fixtures now provide actual delivery settlements. Their assertions are unchanged. ## Contention A concurrent suffix stays behind a failed prefix; safe block admission does not await transport settlement. Co-authored-by: Ayaan Zaidi <[email protected]>
…#144161) This repair includes registered tests for both delivery lifecycles and moves existing helpers to keep the coordinator within its size limit. ## What Problem This Solves `createTtsDirectiveTextStreamCleaner` only parks a partial tag after it has seen both characters of `[[`. When a stream chunk ends on a single `[`, that bracket is emitted (or dropped) and the opener is never recognized. Fixes openclaw#144151. Split openers leak speech-only text; split closers swallow the visible suffix. ## Fix Retain split delimiters and drain literal carry once at completion. Normal dispatch and ACP each use their existing lifecycle adapter over the same source receipt. That receipt owns source completion and ordering. ACP recovery reuses the prepared payload and send operation instead of rebuilding a string. It preserves reply metadata, avoids repeated prefixes, transforms, media and speech, and respects cancellation and queue custody. The stateful stream tests now run in their existing auto-reply project. ## Growth record Ayaan, 2026-09-15: "accept the growth, land openclaw#144161". Production is **+221 net lines against the merge base**, accepted by the owner for the ACP terminal drain, the prepared-payload recovery that replaced the string fallback, and the helper move into the existing payload module that keeps the coordinator under the 700-line rule. This adds no state owner. ## Evidence [Gateway/Discord captures and correction evidence](https://gist.github.com/obviyus/f14fbf2109f3bb30d68e2af5e54b2d61): split tags and literal tails reach the recipient correctly; audio stays separate from visible speech-only text. Registered recovery tests verify exact bytes, one transform/media delivery, metadata, cancellation and released custody. Real packaged Discord faults verify retained queue custody on both builds. The 384 owner/sibling tests passed on head and fresh merge. After correcting test routing, all 12 stream cases pass under auto-reply, 136 routing tests pass, and the hosted unit-fast selector passes 9,235 tests with two skips. Local preflight passed. Record correction: tested merge `eaf170ab` included main `d4d14aca` through an intermediate merge; the earlier reported `bdb6b9f7` was only an ancestor. Later merge `904f4d9e` has exact parents main `31ed4888` and candidate `7614c08e`. Earlier captures retain their actual identities. The ledger records removal of the newline between same-source fragments, leaving `"Intro visible"` with two spaces; independent sources keep their separator. Duplicate helper-only bracket rows were removed while registered normal/ACP regressions and contributor history remain. ## Consumers Normal channel dispatch, ACP direct/routed delivery, terminal-only surfaces and retained followups retain their owners. Source receipts serialize continuations; actual delivery controls recovery and transcript coverage. Deferred captions retain complete-text fallback. ## Compatibility No new configuration, schema or public API. Co-authored-by: Ayaan Zaidi <[email protected]>
This repair includes registered tests for both delivery lifecycles and moves existing helpers to keep the coordinator within its size limit.
What Problem This Solves
createTtsDirectiveTextStreamCleaneronly parks a partial tag after it has seen both characters of[[. When a stream chunk ends on a single[, that bracket is emitted (or dropped) and the opener is never recognized.Fixes #144151. Split openers leak speech-only text; split closers swallow the visible suffix.
Fix
Retain split delimiters and drain literal carry once at completion. Normal dispatch and ACP each use their existing lifecycle adapter over the same source receipt. That receipt owns source completion and ordering.
ACP recovery reuses the prepared payload and send operation instead of rebuilding a string. It preserves reply metadata, avoids repeated prefixes, transforms, media and speech, and respects cancellation and queue custody. The stateful stream tests now run in their existing auto-reply project.
Growth record
Ayaan, 2026-09-15: "accept the growth, land #144161".
Production is +221 net lines against the merge base, accepted by the owner for the ACP terminal drain, the prepared-payload recovery that replaced the string fallback, and the helper move into the existing payload module that keeps the coordinator under the 700-line rule. This adds no state owner.
Evidence
Gateway/Discord captures and correction evidence: split tags and literal tails reach the recipient correctly; audio stays separate from visible speech-only text. Registered recovery tests verify exact bytes, one transform/media delivery, metadata, cancellation and released custody. Real packaged Discord faults verify retained queue custody on both builds.
The 384 owner/sibling tests passed on head and fresh merge. After correcting test routing, all 12 stream cases pass under auto-reply, 136 routing tests pass, and the hosted unit-fast selector passes 9,235 tests with two skips. Local preflight passed.
Record correction: tested merge
eaf170abincluded main2e7aa1b7through an intermediate merge; the earlier reportedf1cdcd51was only an ancestor. Later merge904f4d9ehas exact parents main78520903and candidate7614c08e. Earlier captures retain their actual identities.The ledger records removal of the newline between same-source fragments, leaving
"Intro visible"with two spaces; independent sources keep their separator. Duplicate helper-only bracket rows were removed while registered normal/ACP regressions and contributor history remain.Consumers
Normal channel dispatch, ACP direct/routed delivery, terminal-only surfaces and retained followups retain their owners. Source receipts serialize continuations; actual delivery controls recovery and transcript coverage. Deferred captions retain complete-text fallback.
Compatibility
No new configuration, schema or public API.