Repository navigation
Conversation
EmbeddedBlockChunker forced breaks had two defects. A drain crossing minChars fell through to the whitespace scan for every preference except newline, cutting mid-sentence on whatever whitespace happened to be buffered; the newline-only defer guard is now applied for every preference, since more buffered text can only add candidate boundaries. A forced cut landing exactly at the end of the source probed an open fence's span.end, which the exclusive fence lookup treats as outside the fence, so the chunk was emitted with an unbalanced marker. The cut now probes the last included character, while a span whose final line is a genuine closing marker is still recognized as balanced and emitted without a synthetic close/reopen pair. Co-Authored-By: Claude <[email protected]>
|
🦞👀 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 real behavior proof before merge. Reviewed September 10, 2026, 12:58 AM ET / 04:58 UTC. ClawSweeper reviewWhat this changesThe PR makes streamed reply chunks wait for suitable text boundaries and correctly close and reopen unfinished code fences at forced cuts. Merge readiness⛔ Blocked before merge - 2 items remain This PR remains useful: current main and v2026.9.3 retain both reported defects. No introduced correctness defect was found, but the supplied validation does not satisfy the real-behavior proof gate. Priority: P2 Review scores
Verification
How this fits togetherOpenClaw’s block chunker receives streamed assistant text and divides it into bounded Markdown messages. Its output flows through reply delivery to channel users. flowchart TD
A[Assistant text stream] --> B[Pending reply buffer]
C[Chunk size and break preferences] --> D[Choose text boundary]
B --> D
D --> E[Preserve code fences]
E --> F[Block reply delivery]
F --> G[Channel messages]
Before merge
Agent review detailsSecurityNone. PR surfaceSource +11, Tests +86. Total +97 across 2 files. View PR surface stats
Review metricsNone. 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 boundary selection in the shared chunker, preserving message budgets, source content, and balanced fences through actual streamed delivery. Do we have a high-confidence way to reproduce the issue? Yes, source inspection supports the reported small-delta reproduction with minChars 800 and maxChars 1200 for prose and unfinished fences; this review did not execute it. Is this the best way to solve the issue? Yes, the patch repairs the existing owner and improves on the suggested endpoint probe by preserving already-balanced fences. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against f4d1a1fdf84a. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
|
Closes #143641. Related: #143702. ## What Problem This Solves Fixes an issue where small streamed updates split a bullet line before its next natural boundary arrived or displayed code outside its fence. It also prevents the full final answer from repeating code already delivered with continuation fences. ## Why This Change Was Made The chunker waits for a natural boundary before falling back to whitespace at the limit. It retains the Markdown scanner's open-fence state for sentence and forced breaks, so an unfinished buffer endpoint gets balanced continuation wrappers while a completed closing fence stays intact. The chunker also carries the source represented by each block through private reply metadata. Coalescing retains that source, and final-reply accounting credits it only after successful delivery. Rejected or rewritten text keeps the existing fallback; this does not discard an unsent final answer merely because streaming started. ## User Impact Streamed prose stays in complete lines when a nearby boundary fits. Forced code continuations keep their fences and message limits, and successfully streamed code does not repeat in a final reply. ## Evidence The pinned baseline reproduced both defects through real Discord guild messages: the first prose message stopped after `Item 14:`, and the first code message contained an opening fence without a closer. Focused regressions also failed for those reasons. Independent acceptance caught a full-final replay in the first candidate. The corrected candidate delivered exactly three balanced code messages; removing only synthetic wrappers reconstructed the complete source once. The failed candidate and all raw observations were preserved. The correction passed 263 focused tests across the chunker, subscription, final-payload handling, rejection, supersession, coalescing, media and audio paths. Formatting, syntax checks and the native commit hook passed. Type-aware checks and the full suite run in CI. Real Discord prose and principal fenced-code cases pass update sizes 1, 3, 5, 10, 20 and 64. Every principal code source reconstructs exactly once after removing only synthetic wrappers. Additional whitespace probes expose existing Discord normalization of CRLF and trailing spaces, also reproduced on the pinned baseline; this repair does not claim general byte preservation for those inputs. Independent scoped acceptance is complete. Closed-at-limit and punctuation controls pass, including a real closed-fence message sent before provider completion. Draft edits, final handoff and draft deletion pass. Public cancellation closes the old provider connection, rejects its late write and delivers the replacement once. An existing misleading timeout notice after cancellation was reproduced on the pinned baseline; this does not establish a race involving an already-admitted stale callback on an open connection. The final revision also passes all 24 final-tag streaming tests. It fixes a declaration-only type error using the existing payload type and updates one exact expected reply boundary; runtime behavior is unchanged from the live-tested revision. Hosted CI and the exact-head landing review remain required. Thanks @rgregg for the report. Co-authored-by: Ayaan Zaidi <[email protected]>
…law#143722) Closes openclaw#143641. Related: openclaw#143702. ## What Problem This Solves Fixes an issue where small streamed updates split a bullet line before its next natural boundary arrived or displayed code outside its fence. It also prevents the full final answer from repeating code already delivered with continuation fences. ## Why This Change Was Made The chunker waits for a natural boundary before falling back to whitespace at the limit. It retains the Markdown scanner's open-fence state for sentence and forced breaks, so an unfinished buffer endpoint gets balanced continuation wrappers while a completed closing fence stays intact. The chunker also carries the source represented by each block through private reply metadata. Coalescing retains that source, and final-reply accounting credits it only after successful delivery. Rejected or rewritten text keeps the existing fallback; this does not discard an unsent final answer merely because streaming started. ## User Impact Streamed prose stays in complete lines when a nearby boundary fits. Forced code continuations keep their fences and message limits, and successfully streamed code does not repeat in a final reply. ## Evidence The pinned baseline reproduced both defects through real Discord guild messages: the first prose message stopped after `Item 14:`, and the first code message contained an opening fence without a closer. Focused regressions also failed for those reasons. Independent acceptance caught a full-final replay in the first candidate. The corrected candidate delivered exactly three balanced code messages; removing only synthetic wrappers reconstructed the complete source once. The failed candidate and all raw observations were preserved. The correction passed 263 focused tests across the chunker, subscription, final-payload handling, rejection, supersession, coalescing, media and audio paths. Formatting, syntax checks and the native commit hook passed. Type-aware checks and the full suite run in CI. Real Discord prose and principal fenced-code cases pass update sizes 1, 3, 5, 10, 20 and 64. Every principal code source reconstructs exactly once after removing only synthetic wrappers. Additional whitespace probes expose existing Discord normalization of CRLF and trailing spaces, also reproduced on the pinned baseline; this repair does not claim general byte preservation for those inputs. Independent scoped acceptance is complete. Closed-at-limit and punctuation controls pass, including a real closed-fence message sent before provider completion. Draft edits, final handoff and draft deletion pass. Public cancellation closes the old provider connection, rejects its late write and delivers the replacement once. An existing misleading timeout notice after cancellation was reproduced on the pinned baseline; this does not establish a race involving an already-admitted stale callback on an open connection. The final revision also passes all 24 final-tag streaming tests. It fixes a declaration-only type error using the existing payload type and updates one exact expected reply boundary; runtime behavior is unchanged from the live-tested revision. Hosted CI and the exact-head landing review remain required. Thanks @rgregg for the report. Co-authored-by: Ayaan Zaidi <[email protected]>
Fixes #143641.
What Problem This Solves
EmbeddedBlockChunkercorrupted streamed block replies in two independent ways, both reproduced onmain(15a781e3df2's parent92888bf9fdc):minCharsholds only a few characters past it, so paragraph/newline/sentence boundary searches at index ≥minCharscannot succeed yet. The defer guard that waits for real boundaries was scoped tobreakPreference: "newline"only; every other preference fell through to the whitespace scan and cut at whatever whitespace was already buffered. The cut was delta-dependent, which made the bug look intermittent.span.start < index < span.end) reported a cut atspan.endas outside the fence.isSafeFenceBreakreturned true, the close/reopen path was skipped, and the chunk was emitted with an odd number of ``` markers.Solution
#pickBreakIndex, two changes:maxCharsclamp still run once the buffer reachesmaxChars. Force drains are unaffected (they reach this helper only whenremainingLength > maxChars).findFenceCloseLineStart) is still recognized as balanced, so a fence that ends exactly at the cut is emitted as-is without a synthetic close/reopen pair.Why not the issue's suggested diff verbatim
The issue proposes probing
maxChars - 1whenevermaxChars === buffer.length. That variant also treats a balanced fence whose closing marker is the buffer's final bytes as still-streaming and wraps it in a synthetic close/reopen pair, so the balanced fence is emitted twice-closed and the content after it is pulled into the reopened code block. The added testcuts cleanly after a balanced fence that ends exactly at the source boundaryis red under that variant and green under this patch.Evidence
All runs against this head (
15a781e3df2), pre-fix runs against the same source before the two#pickBreakIndexhunks:waits for maxChars before a forced paragraph break so the cut lands on a line boundary (delta 1/3/10)— failed with the first chunk ending mid-line (bullets.charAt(firstChunk.length)was" ", not"\n").closes and reopens a still-streaming fence cut exactly at the buffer boundary (delta 1/50)— failed with chunks carrying an odd ``` count.cuts cleanly after a balanced fence that ends exactly at the source boundary— passes onmain(43-test baseline), stays green with this patch, fails with themaxChars - 1probe alone.embedded-agent-block-chunker.test.ts49/49 (43 pre-existing unchanged),packages/markdown-core27 files / 382 tests, chunking-adjacentembedded-agent-subscribe.code-span-awareness+block-reply-rejectionssuites.tsgo -p tsconfig.core.json --noEmitexit 0;oxlint --type-awareandoxfmt --checkclean on both changed files.Impact
Streamed embedded-agent replies (block reply chunking is user-configurable per channel via
blockReplyChunking, defaultbreakPreference: "paragraph") no longer split mid-sentence and no longer publish broken markdown when a forced chunk boundary lands on a streaming code fence. Non-streaming and force-flush output is unchanged apart from the two repaired cut positions.