Repository navigation
fix(markdown): preserve task lists across chunk boundaries - #135200
Conversation
Compose canonical Markdown IR slices without losing list, block, annotation, or link metadata. Reuse one append owner for disjoint chunks and fallback edits, and retain semantic whitespace only when the rendered output is nonempty. Remove the duplicate partial metadata mergers.
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs maintainer review before merge. Reviewed September 1, 2026, 6:10 PM ET / 22:10 UTC. ClawSweeper reviewWhat this changesRecomposes Markdown chunk fragments from original source slices so list, block, link, and annotation metadata survive message-size boundaries, with Google Chat and Telegram coverage. Merge readinessKeep this maintainer-labeled PR open for normal maintainer review. Current main still uses the metadata-dropping chunk merger; this branch replaces it with canonical source slicing and includes head-pinned native Telegram proof. Priority: P2 Review scores
Verification
How this fits togetherThe shared Markdown chunker turns parsed agent output into size-bounded channel payloads. Channel formatters consume those chunks for Google Chat, Telegram, Slack, Signal, and WhatsApp delivery. flowchart LR
source[Agent Markdown] --> parser[Markdown parser]
parser --> chunker[Rendered-size chunker]
chunker --> formatter[Channel formatter]
formatter --> delivery[Google Chat and Telegram delivery]
delivery --> observer[Native Telegram QA observer]
Before merge
Agent review detailsSecurityNone. PR surfaceSource +20, Tests +492, Other +215. Total +727 across 13 files. View PR surface stats
Review metrics
Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Land the canonical metadata-preserving shared chunker path after normal maintainer review, retaining the focused formatter and native Telegram regressions. Do we have a high-confidence way to reproduce the issue? Yes—current main still contains the metadata-dropping merger, and the focused Google Chat boundary test encodes the failing 31,998-character input; this read-only review did not execute it. Is this the best way to solve the issue? Yes—the branch repairs recomposition at the shared Markdown IR owner by reusing canonical slicing instead of adding a Google Chat-specific workaround. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against d789919bd53c. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (6 earlier review cycles)
|
Use checked metadata assignments and an unshadowed source-range name. Retain the plugin formatter and HTTP regressions while removing the duplicate plugin import from the core outbound planner test graph.
|
Merged via squash.
|
…135200) * fix(markdown): preserve task lists across chunk boundaries Compose canonical Markdown IR slices without losing list, block, annotation, or link metadata. Reuse one append owner for disjoint chunks and fallback edits, and retain semantic whitespace only when the rendered output is nonempty. Remove the duplicate partial metadata mergers. * fix(markdown): keep composition proof in its owning test graph Use checked metadata assignments and an unshadowed source-range name. Retain the plugin formatter and HTTP regressions while removing the duplicate plugin import from the core outbound planner test graph. * test(markdown): preserve authored link boundaries during chunking * test(markdown): avoid codifying dropped whitespace * test(qa): verify native Telegram formatting boundaries
What Problem This Solves
Fixes an issue where task-list messages gain an extra bullet when a rendered chunk boundary falls immediately before the item. At Google Chat's default 32,000-byte limit, the second delivered message could become
\n\n* [x] doneinstead of\n\n[x] done.Why This Change Was Made
Whitespace coalescing rebuilt Markdown IR from only text, styles, and links, discarding list and block metadata that later renderers need. Contiguous chunks now reuse the canonical source slicer; disjoint chunks and fallback edits share one append operation that preserves semantic metadata and authored coordinates. The duplicate partial append and span-merging paths are removed.
Meaningful whitespace is retained only when its rendered output is nonempty. Existing suppression of plain separators and empty attributed output remains intact, including Signal's fallback behavior. Production: +111/−144 (net −33). Tests: +702/−118 (net +584). Private QA support: +77/−28 (net +49); scenario: +127. QA support is excluded from the published package.
User Impact
Chunked messages retain their task-list structure, code and annotation content, and authored link boundaries. The change adds no configuration, dependency, or channel-specific production rule.
Related: #128615 and #127655 discuss lossless raw whitespace after unsuccessful coalescing. This repair also covers semantic whitespace, but its demonstrated task-list defect occurs during successful coalescing. It deliberately retains the existing treatment of unformatted separators and does not claim to resolve that broader raw-whitespace contract. The earlier trailing-inline-code fix in #134451 is preserved.
Evidence
The task-list regression failed before the repair with the extra bullet and passed afterward. The real guarded HTTP fixture exercises SDK dispatch, the required outbound queue, planning, formatting, the Google Chat adapter, and two captured POST bodies. Both exact bodies and the 32,000-byte bound pass. All eight transport cases pass together, including cancellation, dispatcher/socket cleanup, malformed UTF-8, and token-safe errors.
The earlier owner-sweep snapshot passed 192 tests across 16 Markdown suites. After CI exposed lint and test-boundary problems, the repair replaced three unnecessary type assertions with checked assignments, renamed a shadowed local, and removed a redundant Google Chat test from core infrastructure; the plugin-owned formatter and HTTP proofs remain. The 20 chunker and 40 formatter cases pass again, as do scoped type-aware lint, the assertion ratchet, and the core type-boundary check. Independent Codex review is clean.
The fixtures use loopback HTTP and synthetic authentication; this is not a hosted Google API or model-provider run. The initial CI also timed out in the unchanged ACP source-CLI exit test. That timeout remains unexplained and is not waived or addressed by increasing its deadline; the corrected head must pass required CI before landing.
The ClawSweeper link-boundary rank-up was checked with three additional real-parser/renderer tests: one authored link spanning retained whitespace, one spanning whitespace trimmed by attributed rendering, and two distinct adjacent authored links sharing a URL. All three pass. The requested link-merging change is not applied: contiguous source ranges are already coalesced before canonical slicing, so a spanning source link remains continuous within each output chunk. Merging by URL would instead fuse separately authored links. The new tests retain this distinction and verify each rendered payload stays within its limit. Independent Codex review of this test-only addition is clean; production code is unchanged.
The latest ClawSweeper finding about raw-whitespace loss is addressed: the assertion requiring dropped unformatted spaces was removed. The complete final 22-case chunker file passes, including semantic whitespace, task lists, attributed-output suppression, and the three authored-link cases. Scoped formatting and independent Codex review pass; production is unchanged.
The Telegram QA observer now preserves native text and formatting entities together through messages and edits, validates UTF-16 ranges, and exposes isolated snapshots for the registered
telegram-semantic-formatting-boundariesscenario. The scenario checks literal whitespace, fenced-code chunk boundaries, checkbox labels, and native formatting entities through the normal Gateway send path. This QA addition changes no shipped production code.Local validation passed: 9 Python cases, 21 TypeScript cases, 7 catalog/profile-selection cases, scoped formatting, the normal plugin source and test type checks, scoped lint, and independent managed Codex review with no actionable P0–P2 findings. Native Telegram Test Server proof passed on
da56b8ca8263df6c445d879fbe7188515dbfba82in workflow 33561650273. The leased-group Gateway send scenario completed with 1 passed, 0 failed, and 0 skipped scenarios. It observed exact native text and TDLib entity vectors for inline-code whitespace plus an emoji and link (UTF-16 offsets 3 and 9), two fenced-code chunks (3976 and 11 characters, with Pre entities), and two checkbox chunks (1994 characters each, Bold offset 6/length 1988). This uses the default 4000-character Telegram chunk limit. No model invocation is claimed. The redacted native evidence artifact contains the synthetic text and entity observations. All PR-head checks completed: 238 successful, 49 skipped, and 1 neutral, with no failures. This supplies the native-delivery evidence and green-CI rank-up requested in the latest ClawSweeper review.The broader live-transport workflow also ran the default non-Telegram lanes and finished with failures; it is not an all-lanes-green result. Telegram and mock parity passed. The retained failures are Slack's disabled-channel log warning, Discord's missing reserved QA voice-channel ID, Matrix's CLI encryption-owner verification, and exhausted WhatsApp credential capacity. Inspection of the failing branches places each before the changed Markdown formatter runs; they remain separate follow-ups. The native Telegram evidence above refers specifically to the successful Telegram job and its exact-head artifact.