Repository navigation
fix(gateway): preserve paragraph boundaries in streamed replies - #140833
Conversation
…nt items The live chat buffer concatenated a retained item prefix directly onto the next item's text. Each assistant message of a tool-calling turn is its own keyed item and its text is trimmed, so the buffer glued the last line of one message onto the first line of the next. Lists and tables that started a middle message were rendered as paragraph continuation lines in the WebChat. Insert the missing newlines at the item boundary, without adding any when a paragraph break is already present. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01VsJbS7YcJnDVxErEuaM8xP
|
🦞👀 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 9, 2026, 10:24 PM ET / September 10, 2026, 02:24 UTC (Revision 3). ClawSweeper reviewWhat this changesPreserves paragraph separation between distinct assistant messages in Gateway chat, HTTP streams, and the embedded terminal interface, including updates and display truncation. Merge readiness✅ Ready for maintainer review The fix remains necessary on current main. The earlier split-newline finding is resolved, recorded runtime proof covers the unchanged production code, and no blocking defect remains. Priority: P2 Review scores
Verification
How this fits togetherThe Gateway combines assistant message snapshots and incremental text into replies for chat clients, HTTP consumers, and the terminal interface. Shared separator handling keeps those outputs consistent while live displays retain their existing size limit. flowchart TD
A[Assistant message events] --> B[Shared text merger]
B --> C[Track message boundaries]
C --> D[Uncapped HTTP streams]
C --> E[Live display size limit]
E --> F[Gateway chat clients]
E --> G[Embedded terminal]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource +36, Tests +174. Total +210 across 12 files. View PR surface stats
Review metrics
Technical reviewBest possible solution: Keep paragraph-boundary ownership in the shared merger while preserving provider text, append-only HTTP guarantees, and the existing live-display cap. Do we have a high-confidence way to reproduce the issue? Yes: current main directly joins two distinct keyed assistant messages, making a paragraph followed by a list run together. Source establishes the path; this review did not execute it. Is this the best way to solve the issue? Yes: repairing the existing shared merger avoids separate client fixes, and the revised separator bookkeeping addresses the earlier split-newline failure without weakening HTTP completion guarantees. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 8cc90fe5d745. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
History |
|
Thanks @leapdragon! Merged in 0a20262.
|
…claw#140833) Preserve paragraph boundaries between distinct assistant items in public Gateway chat, Chat Completions, OpenResponses, and the embedded terminal backend. Reconstruct item text without inserted padding so later snapshots cannot retract streamed newlines, and retire padding consistently at the display limit. Validation: real isolated Gateway and WebChat with an actual read tool; baseline and candidate public text; 12 append-only HTTP scenarios; 795 focused tests; verified failing controls for both corrected regressions; clean exact-head review. Browser layout and transcript order remain correct. Co-authored-by: Ayaan Zaidi <[email protected]>
What Problem This Solves
When a tool-calling turn produces distinct assistant messages, public Gateway chat events and OpenAI-compatible HTTP streams join their text without a paragraph boundary. A second message starting with a list or table becomes part of the preceding paragraph in the combined text.
Why This Change Was Made
The shared text merger now keeps inserted separator bytes separate from each item's text. Snapshots and deltas use the same boundary calculation, including an initially empty item. This fixes the reviewed split-newline case without retracting output already sent over HTTP. Display truncation also retires separator state so a later correction cannot recreate discarded padding.
User Impact
Distinct assistant items keep their paragraph boundaries in public chat text, the embedded terminal backend, Chat Completions, and OpenResponses. Existing blank lines do not gain extra padding. Same-item updates, provisional replacement, legacy unkeyed streams, media handling, and terminal fallback retain their contracts.
The tested current WebChat already displayed separate paragraph, tool, and list blocks. That layout and transcript order remain correct. Its public combined text was still affected, including the final event.
Evidence
18f452584417a122747415fefc3089e296dc22cf. Runtime/public proof:adb13ba9a810357878b3829d50808c954b3f887e. Current head053b12bae1a4d1be0fcbacc16e1de18a34c498f3adds only two test-file corrections; all production and fixture inputs are unchanged.First paragraph.- Second item\n- Third item. Candidate live and final text isFirst paragraph.\n\n- Second item\n- Third item.Complete private traffic, provider requests, inspected screenshots, command logs, and review history are retained. No claim is made that the baseline browser layout was broken or that its final event repaired the missing boundary.