Repository navigation
fix(ocr): read a reply that ends inside its JSON as cut - #1543
Merged
Merged
Conversation
A local model whose context window fills stops in the middle of its rows and still reports finish_reason "stop". The read treated only "length" as a cut, so the prefix counted as unparseable: the corrective retry asked the same question and stopped at the same place, and a document or lab read came back with no values and no reason. A reply whose opening object is still open at its last character is now a cut whatever the provider reports. The closed rows before the cut are kept, the read is marked incomplete, no retry runs, and a read with no complete row fails as an output limit. Refs #1403
This was referenced Nov 26, 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.
A local model whose context window fills stops in the middle of its rows and still reports
finish_reason: "stop". The lab and document reads treated only"length"as a cut, so the prefix counted as unparseable: the corrective retry stopped at the same place, and the read came back with no values and no reason.A reply whose opening object is still open at its last character is now read as cut, whatever the provider reports. The closed rows before the cut are kept, the read is marked incomplete, no retry runs, and a read without a complete row fails as
output_limit. A complete reply that is not the schema is still retried once.Tests: three cases in
src/lib/labs/__tests__/ocr-extract.test.ts(two fail on main).Refs #1403