Skip to content

fix: preserve paragraph boundaries across streamed replies - #119549

Closed
qingminglong wants to merge 9 commits into
openclaw:mainfrom
qingminglong:issue-pr/42106-stream-boundary
Closed

qingminglong wants to merge 9 commits into
openclaw:mainfrom
qingminglong:issue-pr/42106-stream-boundary

Conversation

@qingminglong

@qingminglong qingminglong commented Aug 5, 2026 •

Copy link
Copy Markdown
Contributor

Closes #42106

What Problem This Solves

Fixes an issue where users receiving block-streamed replies could see paragraph boundaries disappear when a reply crossed multiple streamed deliveries.

Why This Change Was Made

Paragraph separators are preserved on the delivery that ends a paragraph, while coalescing avoids adding a second separator when that boundary is already present. Equal-cap separator tails remain sendable, and BTW delivery admits recognized paragraph separators without forwarding ordinary whitespace-only payloads.

User Impact

Streamed Markdown keeps its paragraph structure when the client reconstructs successive reply deliveries without exceeding the configured outbound chunk limit, including BTW side-question deliveries.

Evidence

  • Current head: a56e0cd477deb1afea0c56dd8151708c3b5ad1d5.
  • Final equal-cap production runtime proof: EmbeddedBlockChunker plus createBlockReplyPipeline with maxChars=10 processed abcdefghij\n\n into bounded chunks ["abcdefghij", "\\n\\n"] and delivered the same two payloads.
  • Inspectable output: {"chunks":["abcdefghij","\\n\\n"],"delivered":["abcdefghij","\\n\\n"],"lengths":[10,4]}.
  • BTW production runtime regression proof: runBtwSideQuestion with maxChars=10 delivered ["abcdefghij", "\\n\\n", "Next", "paragraph."], preserving the separator between forced blocks while respecting the cap.
  • Supporting checks: reply-utils.test.ts 109/109, block-reply-pipeline.test.ts 25/25, the focused BTW separator test 1/1, chunker/subscriber boundary tests 27/27; targeted oxfmt --check, oxlint, and git diff --check passed.
  • Proof boundary: local production chunker/coalescer/pipeline and BTW delivery paths using synthetic assistant stream text; no external channel was contacted.

@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: S labels Aug 5, 2026
@clawsweeper clawsweeper Bot added 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. P1 High-priority user-facing bug, regression, or broken workflow. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. labels Aug 5, 2026
@clawsweeper

clawsweeper Bot commented Aug 5, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed August 13, 2026, 3:39 PM ET / 19:39 UTC.

ClawSweeper review

What this changes

The PR updates streamed-reply chunking, rendering, coalescing, and BTW delivery so paragraph separators survive bounded reply deliveries without duplicate blank lines.

Merge readiness

⛔ Blocked until real behavior proof from a real setup is added - 5 items remain

Keep open: the supplied branch evidence addresses the prior separator-tail findings, but its proof is synthetic/local rather than a real client or mock-gateway boundary run, and the checkout could not be inspected because every read command failed in the sandbox.

Priority: P1
Reviewed head: 4b76a421fdda37676a19e485afe4eee857118f2d

Review scores

Measure Result What it means
Overall readiness 🦪 silver shellfish (2/6) The patch has focused test evidence and appears to address prior findings, but real delivery-boundary proof is still a merge gate.
Proof confidence 🦪 silver shellfish (2/6) Needs real behavior proof before merge: The PR body reports synthetic local stream/pipeline and BTW traces rather than an after-fix real client or mock-gateway boundary run. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Patch quality 🦐 gold shrimp (3/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Needs proof Needs real behavior proof before merge: The PR body reports synthetic local stream/pipeline and BTW traces rather than an after-fix real client or mock-gateway boundary run. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Evidence reviewed 4 items PR-provided implementation scope: The supplied PR diff changes the block chunker, stream renderer, reply coalescer, BTW delivery, and focused tests to carry paragraph separators across forced deliveries.
PR-provided proof is local and synthetic: The PR body explicitly limits its evidence to synthetic assistant-stream text through local chunker/coalescer/pipeline and BTW paths, with no external channel contacted.
Repository inspection unavailable: Read-only command execution failed before any checkout or history inspection with bwrap: loopback: Failed RTM_NEWADDR: Operation not permitted; therefore current-main ownership, scoped policy, and the exact head diff could not be independently verified.
Findings None None.
Security None None.

How this fits together

Assistant stream text is split into bounded blocks, passed through rendering and reply coalescing, then delivered to channel handlers. The change preserves Markdown paragraph boundaries through those stages.

flowchart LR
  A[Assistant text stream] --> B[Block chunker]
  B --> C[Stream renderer]
  C --> D[Reply coalescer]
  D --> E[Reply pipeline]
  E --> F[Channel delivery]
Loading

Before merge

  • Add real behavior proof - Needs real behavior proof before merge: The PR body reports synthetic local stream/pipeline and BTW traces rather than an after-fix real client or mock-gateway boundary run. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
  • Resolve merge risk (P1) - The proposed change affects the shared path that turns streamed blocks into user-visible deliveries, but the supplied proof does not exercise a real transport client or the repository-approved mock-gateway boundary.
  • Resolve merge risk (P1) - The PR body names proof at a56e0cd, while the supplied current head is 4b76a42; exact-head proof should be refreshed.
  • Resolve merge risk (P1) - This bug fix adds a reported production net +124 lines versus test net +429 lines; the added separator handling should be kept as one canonical boundary rule rather than parallel trim and join policies.
  • Complete next step (P2) - The remaining merge blocker is contributor-supplied real delivery proof rather than a safely automatable code repair.
Agent review details

Security

None.

PR surface

Source +124, Tests +429. Total +553 across 9 files.

View PR surface stats
Area Files Added Removed Net
Source 4 157 33 +124
Tests 5 433 4 +429
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 9 590 37 +553

Review metrics

Metric Value Why it matters
Production vs test delta production +124 net; tests +429 net The implementation is a bug fix on a shared delivery path, so its substantial production growth needs boundary-level proof and a canonical ownership shape.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #42106
Summary: This PR explicitly presents itself as the candidate implementation for the canonical streamed paragraph-boundary bug report.

Members:

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

Merge-risk options

Maintainer options:

  1. Add boundary-level delivery proof (recommended)
    Run the exact head through a mock-gateway harness or real client at an effective chunk cap and show the reconstructed streamed reply and BTW callback preserve the separator.

Technical review

Best possible solution:

Before merge, attach a redacted exact-head mock-gateway or real-client trace showing bounded streamed output and BTW delivery preserve one paragraph boundary, then consolidate any duplicate separator policy into the chunker/coalescer owner boundary.

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

No high-confidence independent reproduction is available: the supplied context provides focused synthetic runtime traces, but sandbox failure prevented validating the exact source or running a current-head delivery path.

Is this the best way to solve the issue?

Unclear: the patch targets the correct chunk-to-delivery boundary and prior findings, but an exact-head gateway/client trace is needed to show this is the best end-to-end repair.

AGENTS.md: unclear because the file could not be read completely.

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

Labels

Label justifications:

  • P1: The PR repairs user-visible Markdown structure in shared streamed replies, including delivery paths that can affect active channel users.
  • merge-risk: 🚨 message-delivery: Changing chunk and coalescing semantics can drop, duplicate, or misplace text boundaries when streamed payloads are reconstructed.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🦐 gold shrimp.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: The PR body reports synthetic local stream/pipeline and BTW traces rather than an after-fix real client or mock-gateway boundary run. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.

Evidence

What I checked:

  • PR-provided implementation scope: The supplied PR diff changes the block chunker, stream renderer, reply coalescer, BTW delivery, and focused tests to carry paragraph separators across forced deliveries. (src/agents/embedded-agent-block-chunker.ts:63, 4b76a421fdda)
  • PR-provided proof is local and synthetic: The PR body explicitly limits its evidence to synthetic assistant-stream text through local chunker/coalescer/pipeline and BTW paths, with no external channel contacted. (4b76a421fdda)
  • Repository inspection unavailable: Read-only command execution failed before any checkout or history inspection with bwrap: loopback: Failed RTM_NEWADDR: Operation not permitted; therefore current-main ownership, scoped policy, and the exact head diff could not be independently verified.
  • Prior findings appear targeted: The supplied prior review listed separator-tail handling in effective-cap and BTW delivery; the current supplied diff includes focused chunker, pipeline, and BTW tests for those cases. (src/agents/btw.test.ts:837, 4b76a421fdda)

Likely related people:

  • qingminglong: The supplied context attributes all nine commits on the proposed branch to this person; current-main feature-history ownership could not be inspected because the read-only sandbox failed. (role: current PR implementation author; confidence: low; commits: fa26044e5c68, 4b76a421fdda; files: src/agents/embedded-agent-block-chunker.ts, src/auto-reply/reply/block-reply-coalescer.ts)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Attach a redacted exact-head mock-gateway or real-client transcript covering an effective-cap paragraph tail and BTW delivery.
  • Update the PR evidence to identify the current 4b76a42 head.

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.

History

Review history (10 earlier review cycles; latest 8 shown)
  • reviewed 2026-08-05T13:16:59.202Z sha 36ff5b35c50d8c57d5a4d74d22f02d7a2becdb9b :: needs real behavior proof before merge. :: [P1] Retain the overflow paragraph separator
  • reviewed 2026-08-05T14:07:09.053Z sha 061df137859aa0ed669ebaad520d24235f246fe9 :: needs real behavior proof before merge. :: [P1] Preserve fence state on leading separators | [P2] Retain indentation after preserved separators
  • reviewed 2026-08-05T16:24:27.376Z sha 15d7b60221d4bf8759f013402b9adf47bb0b8093 :: needs real behavior proof before merge. :: [P1] Retain separator-only streamed deltas | [P1] Preserve fence state through the leading-separator path | [P2] Do not consume partial whitespace-bearing separators
  • reviewed 2026-08-07T00:48:41.723Z sha c34050194333c7c3c0836a03d89ab4d4888cf387 :: needs real behavior proof before merge. :: [P1] Retain separator-only streamed deltas | [P1] Keep fence state through leading separators | [P2] Do not consume incomplete whitespace separators
  • reviewed 2026-08-07T03:37:34.625Z sha db0aafd6087abc436705fee1405ae0ff9e181a7d :: needs real behavior proof before merge. :: [P1] Preserve paragraph suffixes through subscriber delivery | [P1] Handle whitespace-bearing separators at incoming chunk starts | [P2] Retain incomplete separators across streamed deltas | [P1] Emit separator-only tails when forced
  • reviewed 2026-08-07T16:54:34.787Z sha b965d7f6389ea1390dc3a83af04967e922a8d557 :: needs real behavior proof before merge. :: [P1] Carry separator-only tails through delivery
  • reviewed 2026-08-08T17:43:56.359Z sha 831d384475305a93ca7d0d9cfd4787ff3aa6819a :: needs real behavior proof before merge. :: [P1] Preserve separator-only tails in BTW delivery
  • reviewed 2026-08-08T17:50:02.285Z sha 831d384475305a93ca7d0d9cfd4787ff3aa6819a :: needs real behavior proof before merge. :: [P1] Preserve separator tails after an effective-cap flush | [P1] Preserve separator-only tails in BTW delivery

@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Aug 5, 2026
@qingminglong
qingminglong force-pushed the issue-pr/42106-stream-boundary branch from 2cfbf9d to b5b5d5c Compare August 5, 2026 12:32
@qingminglong

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 5, 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 repository_dispatch).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. labels Aug 5, 2026
@qingminglong

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 5, 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 repository_dispatch).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. labels Aug 5, 2026
@qingminglong
qingminglong force-pushed the issue-pr/42106-stream-boundary branch from 061df13 to 15d7b60 Compare August 5, 2026 15:05
@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. labels Aug 5, 2026
@qingminglong
qingminglong force-pushed the issue-pr/42106-stream-boundary branch from 15d7b60 to c340501 Compare August 7, 2026 00:40
@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. labels Aug 7, 2026
@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Aug 7, 2026
@qingminglong
qingminglong force-pushed the issue-pr/42106-stream-boundary branch from db0aafd to f395ca2 Compare August 7, 2026 15:27
@qingminglong

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 7, 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 repository_dispatch).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@qingminglong
qingminglong force-pushed the issue-pr/42106-stream-boundary branch from b965d7f to 64b0dd2 Compare August 8, 2026 15:45
@qingminglong

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 8, 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 repository_dispatch).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. labels Aug 8, 2026
@qingminglong
qingminglong force-pushed the issue-pr/42106-stream-boundary branch from 831d384 to a56e0cd Compare August 13, 2026 11:35
@qingminglong

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 13, 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:

@qingminglong
qingminglong force-pushed the issue-pr/42106-stream-boundary branch from a56e0cd to d20b0e1 Compare August 13, 2026 13:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. size: L status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Block streaming can drop paragraph separators across streamed updates

1 participant