Repository navigation
fix(chunker): preserve URLs in CharacterTextChunker (#2510) - #2515
Merged
endxxxx merged 3 commits intoNov 17, 2026
Merged
Conversation
Contributor
There was a problem hiding this comment.
Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.
Collaborator
🤖 Open Code ReviewTarget: PR #2515 ✅ OpenCodeReview: Review complete: 0 finding(s) across 1 selected item(s). Generated by cloud-assistant via Open Code Review. |
endxxxx
approved these changes
Nov 17, 2026
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.
Description
CharacterTextChunkerreplaces URLs with__URL_<n>__placeholders beforesplitting, but
RecursiveCharacterTextSplittercan cut right through aplaceholder (e.g.
__URL/_0__landing in different chunks). The URL canthen no longer be restored: it disappears from the output and placeholder
fragments leak into the chunks.
The fix takes the first approach suggested in the issue: when the input
contains URLs, delegate to
SimpleTextSplitterwith the samechunk_size/chunk_overlap. It already keeps placeholders indivisible(see #2228), so this reuses the tested protection instead of adding a
second boundary-alignment implementation. Inputs without URLs keep the
previous recursive-splitter path byte-for-byte.
Related Issue (Required): Fixes #2510
Type of change
How Has This Been Tested?
New
tests/chunkers/test_charactertext_chunker.py(5 tests):test_url_preserved_with_small_chunk_sizeis the exact reproduction fromthe issue — confirmed failing before the fix (2 of the URL tests fail on
unpatched code) and passing after. Also covers overlap, a URL longer than
chunk_size(kept whole, may oversize one chunk), multiple URLs, and ano-URL test pinning the recursive-splitter output unchanged.
ruff checkandruff format --checkpass on both changed files.Checklist