Repository navigation
fix(boundaries): keep Markdown separators inside wrapped content - #201
Merged
Merged
Conversation
SDK Coverage •
|
||||||||||||||||||||||||||||||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #192.
strip_boundary_markerssplit the wrapped block on"---\n"withmaxsplit=2and tookparts[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
partitionandrpartitionand 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---.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 acrosstests/unit/core/agent,tests/securityand the public import surface. No doc drift, lock clean.