Doing the reconciliation in a Code node instead of trusting the model's arithmetic is a sensible split, and putting the variance next to the flag makes the review queue easy to sort. There is one gap I would close before this touches real books. Extract from File only reads a PDF's text layer, so a scanned or photographed invoice comes through as empty or near-empty text. The model then has nothing to read and may return nulls. The || 0 fallbacks turn all three amounts into 0, and since 0 + 0 = 0 the invoice passes as VERIFIED. So the status is most confident in exactly the case where extraction failed. A small guard fixes it: check the extracted text length before the OpenAI call, and in the Code node mark anything with total_amount <= 0 or a missing invoice_number as NEEDS_REVIEW instead of VERIFIED. Also, json_object mode guarantees valid JSON but not that every key is present. A strict json_schema response format would enforce the field list.
Catching the 0 + 0 = 0 false positive on image-only PDFs is a critical safeguard. v1.1 is now live across the repo and kit with both fixes: a NEEDS_REVIEW guard in the Code node when extracted text is under 15 characters, total_amount <= 0, or invoice_number is empty, plus strict json_schema enforcement on the OpenAI extraction node.
Hayrullah Kar
Doing the reconciliation in a Code node instead of trusting the model's arithmetic is a sensible split, and putting the variance next to the flag makes the review queue easy to sort. There is one gap I would close before this touches real books. Extract from File only reads a PDF's text layer, so a scanned or photographed invoice comes through as empty or near-empty text. The model then has nothing to read and may return nulls. The || 0 fallbacks turn all three amounts into 0, and since 0 + 0 = 0 the invoice passes as VERIFIED. So the status is most confident in exactly the case where extraction failed. A small guard fixes it: check the extracted text length before the OpenAI call, and in the Code node mark anything with total_amount <= 0 or a missing invoice_number as NEEDS_REVIEW instead of VERIFIED. Also, json_object mode guarantees valid JSON but not that every key is present. A strict json_schema response format would enforce the field list.