fix(rag): detect Markdown tables without body rows
EM
2d ago+139+139+012345678901234567890123456789-2-2-0123456789
PR Checklist
- The proposed commit message follows Conventional Commits.
Bugs / Features
- Related issue(s) linked. Reproduced directly on main.
- Tests for the changes have been added.
- Docs have been added or updated.
- A patch changeset for
@voltagent/raghas been added.
What is the current behavior?
A document that starts with a Markdown table containing only a header and delimiter row is detected as plain text. GFM permits tables with zero body rows.
What is the new behavior?
Allow the first pipe row to start at the beginning of the document and accept LF and CRLF. Keep the delimiter-row check so ordinary pipe-delimited text still stays plain text.
Notes for reviewers
- Both table fixtures fail on upstream main and pass with the patch. The plain-text control passes in both cases.
vitest run --typecheckpassed 50 RAG tests across 20 files.- Scoped TypeScript, changed-file Biome, changeset Prettier and whitespace checks passed.
- CommonJS, ESM and type declaration builds passed.
References
OpenAI Codex assisted with reproduction, implementation and local validation.
Summary by cubic
Fixes Markdown table detection in the RAG format detector so header-only tables at the start of a document are recognized as tables instead of text.
- Requires an adjacent delimiter row with a matching cell count; each delimiter cell needs at least one hyphen with optional alignment colons.
- Accepts LF and CRLF line endings, optional outer pipes, an initial byte order mark, up to three leading spaces, and escaped header pipes.
- Keeps pipe rows without an adjacent delimiter, including inside prose, as text.
- Releases as a patch for
@voltagent/rag.
Summary by CodeRabbit
- Bug Fixes
- Markdown tables at the beginning of a document are now detected with LF or CRLF line endings, including when preceded by a BOM or up to three spaces. A pipe-delimited header must be followed by a separator row with a matching cell count and at least two hyphens per cell. Separators may include alignment colons and omit a trailing pipe. Rows without a valid separator are not mistaken for tables.