Skip to content

fix(boundaries): keep Markdown separators inside wrapped content - #201

Merged
chiruu12 merged 1 commit into
devfrom
fix/192-strip-boundary-truncation
Oct 7, 2026
Merged

chiruu12 merged 1 commit into
devfrom
fix/192-strip-boundary-truncation

Conversation

@chiruu12

@chiruu12 chiruu12 commented Oct 7, 2026

Copy link
Copy Markdown
Collaborator

Fixes #192.

strip_boundary_markers split the wrapped block on "---\n" with maxsplit=2 and took parts[1]. The wrapper writes a delimiter on either side of the body, so that works until the body contains a --- line of its own, at which point the second split lands on the body's separator instead of the wrapper's closing one and everything after it is dropped. No error, no truncation marker, just a shorter string.

A --- line is ordinary Markdown and common in retrieved documents, which is exactly the content this wrapper exists to carry.

The body is whatever sits between the first delimiter and the last one, so the fix reads one delimiter in from each end with partition and rpartition and keeps every byte between them. The delimiter itself moved to a module constant that both the writer and the reader use, since the bug was the two halves disagreeing about which --- was structural.

Two cases beyond the report also truncated and now round-trip: a body that is exactly ---, and a body ending in ---.

body                                        before            after
# Notes\n\nBefore\n---\nAfter\n\nFinal...   '# Notes\n\nBefore'   round-trips
Section 1\n---\nSection 2\n---\nSection 3   'Section 1'           round-trips
---                                         ''                    round-trips
A\n---                                      'A'                   round-trips

A block with no delimiters at all is still replaced with the removal marker rather than returned, so a forged wrapper does not get its contents handed back.

Tests: six parametrised round-trips over the separator shapes, one that asserts the reported content survives rather than only that the string changed, and one for the no-delimiter block. The existing round-trip test passed throughout because its body has no internal separator, which is why this had no coverage.

ruff check, ruff format --check, mypy (128 files) clean. 248 tests across tests/unit/core/agent, tests/security and the public import surface. No doc drift, lock clean.

Copilot AI balanced review requested due to automatic review settings October 7, 2026 08:47

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@github-actions

github-actions Bot commented Oct 7, 2026

Copy link
Copy Markdown

coverage

SDK Coverage •
FileStmtsMissCoverMissing
src/unplug/core/agent
   boundaries.py921287%103–112, 172, 187
TOTAL751888688% 

Tests Skipped Failures Errors Time
1360 25 💤 0 ❌ 0 🔥 46.115s ⏱️

@greptile-apps

greptile-apps Bot commented Oct 7, 2026 •

Copy link
Copy Markdown

RetriggerConfidence Score: 5/5

[Medium risk] Fixes boundary marker parsing for Markdown content.

This PR appears safe to merge.

What we checked:

  • Markdown content gets cut off: The writer places a closing delimiter after the body. The reader now selects that last delimiter instead of the body's first separator.
  • Returned content skips safety checks: The output pipeline scans and redacts the full text before stripping markers. Preserved content still passes through those checks.

Summary

Fixes strip_boundary_markers so Markdown separators inside wrapped content no longer cut off the returned body.

  • Shares _DELIMITER between wrapping and stripping.
  • Reads the opening delimiter from the start and the closing delimiter from the end.
  • Adds focused tests for separator shapes and malformed blocks.

No actionable issues found. This review checked code paths; it did not run tests.

Reviews (1) · Last reviewed commit: "keep markdown separators inside wrapped ..." · Reviewed by Greptile

@chiruu12
chiruu12 merged commit 056c86f into dev Oct 7, 2026
7 checks passed
@chiruu12
chiruu12 deleted the fix/192-strip-boundary-truncation branch October 7, 2026 09:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

strip_boundary_markers truncates wrapped content containing Markdown separators

2 participants