You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(rag): split paragraphs with Windows line endings - #1567
The commit message follows the Conventional Commit guidelines.
Bugs / Features
Related issue linked.
Regression tests added.
Docs added or updated.
Patch changeset added for @voltagent/rag.
What is the current behavior?
RecursiveChunker treats a blank line made of LF characters as a paragraph boundary. The same text with CRLF or CR produces one chunk for two short paragraphs.
What is the new behavior?
Recognize LF, CRLF, and CR when splitting paragraphs. CRLF counts as one line break. The original text supplies the chunk offsets, and single line breaks inside a paragraph stay intact.
On the upstream code, the new CRLF and CR cases failed and the LF case passed.
With the fix, 50 RAG tests passed across 19 files. A smoke test against the built public ESM entry verified paragraph contents and source ranges for all three line endings.
Biome, changeset formatting, focused strict TypeScript checks, and the CommonJS, ESM, and declaration builds passed.
The package-wide TypeScript check reports the same three diagnostics on the upstream revision and on this branch, in code-chunker.spec.ts and late-chunker.spec.ts.
Codex assisted with investigation, implementation, tests, and drafting. All checks above were run locally without a model or external service.
Summary by cubic
Fixes RecursiveChunker so blank lines with CRLF or CR endings split paragraphs the same way LF endings already did.
The previous split regex only matched LF pairs, so text using CRLF or CR merged separate short paragraphs into one chunk.
The new regex treats \r\n as a single line break, preserves source offsets, and leaves single line breaks inside a paragraph intact.
No actionable comments were generated in the recent review.
Walkthrough
The recursive chunker now preserves paragraph boundaries when text uses LF, CRLF, or CR line endings. Regression tests check paragraph content and chunk offsets against the original text.
splitIntoParagraphs recognizes blank-line separators using LF, CRLF, and CR. Tests check paragraph content and chunk offsets. The changeset declares a patch release for @voltagent/rag.
This fix makes paragraph splitting work for text with Windows (CRLF) or old Mac (CR) line endings while keeping chunk offsets relative to the original text. The change is small and tested, and no merge-blocking risk remains.
Pre-merge checks: 4
Check name
Status
Explanation
Title check
The title "fix(rag): split paragraphs with Windows line endings" matches the main change. The changeset and code update splitIntoParagraphs in packages/rag/src/utils/text.ts to treat LF, CRLF, and…
Description check
The description follows the repository template. It includes the PR checklist, the bug/feature checklist with linked issue, regression tests, and changeset, plus the current behavior, new behavior wit…
Linked Issues check
[#1566] requires a blank line made of LF, CRLF, or CR to separate paragraphs in RecursiveChunker, with chunk offsets that refer to the original text. At the reviewed head, splitIntoParagraphs in packa…
Out of Scope Changes check
The PR changes three files according to the summary: .changeset/rag-paragraph-line-endings.md (patch changeset for @voltagent/rag), packages/rag/src/tests/recursive-chunker.spec.ts (regression tes…
Full details: Title check
Explanation
The title "fix(rag): split paragraphs with Windows line endings" matches the main change. The changeset and code update splitIntoParagraphs in packages/rag/src/utils/text.ts to treat LF, CRLF, and lone CR as paragraph breaks. The title names the bug area (@voltagent/rag), the behavior, and the cause. It is concise and follows a conventional commit style.
Full details: Description check
Explanation
The description follows the repository template. It includes the PR checklist, the bug/feature checklist with linked issue, regression tests, and changeset, plus the current behavior, new behavior with 'Fixes #1566', and reviewer notes. The 'Docs added or updated' item is unchecked, which is acceptable for a non-critical item. The description states the problem and the fix clearly and gives verification details.
Full details: Linked Issues check
Explanation
[#1566] requires a blank line made of LF, CRLF, or CR to separate paragraphs in RecursiveChunker, with chunk offsets that refer to the original text. At the reviewed head, splitIntoParagraphs in packages/rag/src/utils/text.ts splits on /(?:\r?\n|\r(?!\n)){2,}/. This pattern treats CRLF as one line break, matches bare CR pairs, and matches mixed forms such as \r\n\r. A single CRLF or LF inside a paragraph does not match, so it stays intact. Offsets come from text.indexOf on the trimmed part, and text is sliced from the original input, so the original line endings are preserved. The PR summary reports a new parameterized test in recursive-chunker.spec.ts covering \n, \r\n, and \r, which checks paragraph contents and offsets. That test and the smoke test were not read directly. The wiring from RecursiveChunker to splitIntoParagraphs was not confirmed by a repository read, because the history lookup for packages/rag/src/chunker/recursive-chunker.ts returned no result. Nothing in the evidence contradicts the requirement. No non-coding requirement applies beyond the changeset, which the PR adds.
Full details: Out of Scope Changes check
Explanation
The PR changes three files according to the summary: .changeset/rag-paragraph-line-endings.md (patch changeset for @voltagent/rag), packages/rag/src/tests/recursive-chunker.spec.ts (regression test for the three line endings and offsets), and packages/rag/src/utils/text.ts (paragraph split regex). Each change connects directly to #1566. The changeset is the release note for the fix. The test supports the required behavior. The text.ts change is the fix itself. No unrelated change was identified. The whole-PR diff for text.ts could not be read, so the base content comparison relies on the head file and the summary.
Finishing Touches
Generate unit tests (beta)
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.
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
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.
PR Checklist
Bugs / Features
@voltagent/rag.What is the current behavior?
RecursiveChunkertreats a blank line made of LF characters as a paragraph boundary. The same text with CRLF or CR produces one chunk for two short paragraphs.What is the new behavior?
Recognize LF, CRLF, and CR when splitting paragraphs. CRLF counts as one line break. The original text supplies the chunk offsets, and single line breaks inside a paragraph stay intact.
Fixes #1566.
Notes for reviewers
code-chunker.spec.tsandlate-chunker.spec.ts.Codex assisted with investigation, implementation, tests, and drafting. All checks above were run locally without a model or external service.
Summary by cubic
Fixes
RecursiveChunkerso blank lines with CRLF or CR endings split paragraphs the same way LF endings already did.\r\nas a single line break, preserves source offsets, and leaves single line breaks inside a paragraph intact.@voltagent/rag. Fixes [BUG] RecursiveChunker merges paragraphs separated by Windows line endings #1566.Written for commit fc94678. Summary will update on new commits.
Summary by CodeRabbit