Skip to content

fix: an oversized first page no longer flushes an empty chunk - #477

Open
jerrl10 wants to merge 2 commits into
VectifyAI:mainfrom
jerrl10:fix/empty-first-chunk
Open

fix: an oversized first page no longer flushes an empty chunk#477
jerrl10 wants to merge 2 commits into
VectifyAI:mainfrom
jerrl10:fix/empty-first-chunk

Conversation

@jerrl10

@jerrl10 jerrl10 commented Sep 4, 2026

Copy link
Copy Markdown

Fixes #467.

What

page_list_to_group_text() closed its accumulator whenever the running token count plus the next page exceeded average_tokens_per_part. On the first page the accumulator is still empty and the count is zero, so the test reduced to token_lengths[0] > average_tokens_per_part and appended an empty string as chunk 0.

>>> page_list_to_group_text(["PAGE-A", "PAGE-B", "PAGE-C"], [60000, 500, 500], max_tokens=20000)
['', 'PAGE-A', 'PAGE-APAGE-B', 'PAGE-BPAGE-C']

Both callers pass that chunk to the model as a slice of the document — process_no_toc() seeds the entire table of contents from it, and process_toc_no_page_numbers() can raise ValueError and abort the run.

current_subset is still empty on the first page, so a page over
average_tokens_per_part flushed an empty chunk that both callers then
passed to the model as a slice of the document.
@jerrl10
jerrl10 force-pushed the fix/empty-first-chunk branch from 756addc to 780b2ed Compare September 4, 2026 16:07
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.

Oversized first page produces an empty chunk that reaches the model

1 participant