Skip to content

fix(ocr): read a reply that ends inside its JSON as cut - #1543

Merged
MBombeck merged 1 commit into
mainfrom
fix/ocr-reply-cut-without-length
Nov 25, 2026
Merged

MBombeck merged 1 commit into
mainfrom
fix/ocr-reply-cut-without-length

Conversation

@MBombeck

Copy link
Copy Markdown
Owner

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

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
@MBombeck
MBombeck merged commit 6ab088e into main Nov 25, 2026
40 checks passed
@MBombeck
MBombeck deleted the fix/ocr-reply-cut-without-length branch December 1, 2026 09:13
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.

1 participant