Repository navigation
fix: preserve streamed reply boundaries without replaying code - #143722
Conversation
|
🦞👀 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 10, 2026, 1:54 AM ET / 05:54 UTC (Revision 3). ClawSweeper reviewWhat this changesThe PR preserves natural streamed reply boundaries, balances continued code fences, and tracks successfully delivered source text so the final answer does not replay that code. Merge readiness✅ Ready for maintainer review This remains a useful fix for defects still present on current main. The updated acceptance evidence resolves the previous review’s outstanding request, and no blocking introduced defect was found. Priority: P2 Review scores
Verification
How this fits togetherOpenClaw turns streamed assistant text into channel-sized reply blocks. The delivery pipeline combines those blocks and records successful sends to decide which final text and attachments still need delivery. flowchart LR
A[Assistant text updates] --> B[Markdown boundary chunker]
B --> C[Balanced blocks and source text]
C --> D[Reply normalization and coalescing]
D --> E[Channel delivery]
E --> F[Successful source accounting]
F --> G[Suppress delivered final text]
F --> H[Preserve unsent content]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource +91, Tests +268. Total +359 across 12 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 Markdown boundary handling in the shared chunker and suppress final text only when successful delivery accounts for its complete source. Do we have a high-confidence way to reproduce the issue? Yes: current-main source exposes both reported triggers when small updates cross the minimum length or an unfinished fence reaches the maximum length. This review inspected that path without executing it. Is this the best way to solve the issue? Yes: the patch uses the existing Markdown scanner and delivery-accounting owners, preserving fallback delivery when complete successful coverage cannot be established. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against fe6556b643e3. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
History |
|
Thanks @rgregg for the report. Proof: Real Discord guild requests through an isolated Gateway pass prose and fenced-code update sizes 1, 3, 5, 10, 20 and 64. The principal code source reconstructs exactly once after removing only synthetic fence wrappers. Independent acceptance also covers closed-fence/punctuation boundaries, draft edits and finalization, and matched cancellation/replacement behavior. Focused validation passed 263 tests plus 24 final-tag tests.
The final revision also fixes the payload's declaration type and keeps the exact literal final-tag test aligned with the intended boundary behavior. Its runtime matches the live-tested revision. Existing Discord whitespace losses and the misleading cancellation timeout notice were reproduced on the pinned baseline and remain separate limitations. The late-write cancellation probe used an already-closed connection; it does not establish an open-transport internal race result. Exact-head CI · Related contributor work: #143702, left unchanged. Exact-head CI and the required independent landing review passed. |
…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]>
Put back upstream b1c68b9 content that the continuation line had silently reverted in shared files. Every row has a keep/restore disposition recorded in the round journal. Feature hunks are preserved. Production: - announce deps: use callSubagentLifecycleGateway for the wake and cleanup deps (openclaw#146369 inherited Gateway binding). - reply-delivery: clear blockSourceText on superseded deferred replies (openclaw#143722). - stream-rendering: record a block reply as delivered only when it has text (openclaw#135751). - gateway runtime handles: carry hotReloadStatus through the managed reload. - sweep-kill and sweeper: honor retired cancellations (reconcileRetiredSubagentCancellation), and pass the run's Gateway context resolver into sweep session deletes. - registry read: per-child snapshot reads (openclaw#154727), so the Gateway event loop is not blocked. - session delivery queue: read the post-enqueue status inside the SQLite worker instead of on the main thread, restoring the openclaw#147887 invariant. Tests restored to upstream's coverage: - task-registry kernel test: back to upstream's kernel functions. - double-announce: real outbound adapter retry outcomes (openclaw#131419). - side-question: listener-failure hooks case (openclaw#144828). - session-delivery storage: main-thread-SQL idle assertion (openclaw#157458). - media-only: the re-resolved auth selection assertion. - resume persistence: activation uses the real recovery-runtime shape. The resume "steered requester turn" test was adapted for upstream's async task lookup (openclaw#157634). Its stub now settles like the real waker, and the test waits for settle before an exact count, with a no-pending-wake assertion added. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Fq5EX9ESA3CG9cuZxVoKAK
Closes #143641. Related: #143702. Thanks @rgregg for the report.
What Problem This Solves
Small streamed updates could split a bullet line too early or display code outside its fence. The final answer could then repeat code already delivered in continuation blocks.
Why This Change Was Made
The chunker waits for a natural boundary before splitting at whitespace and preserves open-fence state across forced breaks. Private reply metadata carries each block's original source through coalescing; final accounting credits it after successful delivery. Rejected or rewritten text retains final-answer recovery.
User Impact
Prose keeps complete lines when they fit. Code continuations stay fenced within message limits, and delivered code is not repeated in the final answer.
Consumers: streamed chunks, coalesced blocks, and final-reply accounting now preserve source coverage across continuation wrappers.
Evidence
Real guild messages reproduced premature prose splitting and an unclosed fence. Corrected messages reconstructed the full code exactly once for six update sizes. All 263 focused tests and 24 final-tag streaming tests passed. Draft edits, handoff, deletion, cancellation, and replacement checks passed. Existing platform normalization of line endings and trailing spaces remains; general byte preservation is not claimed. A misleading cancellation timeout notice also reproduced before the change.