Valid JSON can carry a wrong answer very efficiently. The brackets line up, the fields arrive, the parser is happy. Somewhere downstream, a completely respectable number starts causing trouble.

LLM structured outputs are useful because they give software a predictable format to work with. The product still needs to decide whether the information inside that format deserves to be accepted. A tidy form is not a checked form.

The invoice that passes the wrong test

Consider a fictional invoice. Its subtotal is AED120, delivery is AED30, and the stated total is AED150. There are no other charges. An extraction model returns the correct subtotal and delivery, but puts 190 in the total field.

A schema requiring those three fields to be numbers can accept that result. Even a rule saying the total must be positive will accept it. The candidate is structurally valid, yet it contradicts the source and fails a simple calculation: 120 plus 30 is 150.

This is an illustrative failure, not a reported model test. Its value is that nobody needs an advanced reasoning benchmark to spot the problem. We need to stop asking one check to answer three different questions.

Check the response is complete and not a refusal, check it matches the schema, then check the source evidence and business rules. Handle refusals or incomplete outputs separately, reject or repair invalid structure, and send unsupported or incorrect values for review. Accept only a record that passes all checks. Fictional example: AED120 plus AED30 is AED150; candidate AED190 needs review. Record acceptance does not authorise a payment.
Three checks before accepting a record. The invoice is fictional. Open the full-size diagram.

Give each check a specific job

The schema check asks whether the candidate has the expected structure and permitted values. The source check asks whether the extracted amount appears in the right place on the supplied invoice. The business-rule check asks whether the amounts reconcile under the rules for that invoice.

These checks can disagree. A candidate could reconcile perfectly after copying the wrong invoice. It could faithfully reproduce an invoice whose arithmetic is wrong. Preserve both findings rather than quietly repairing the source or pretending agreement has been established.

The calculation also belongs to the document type. Discounts, tax, credit notes and rounding can change how a real invoice reconciles. Define the units, permitted adjustments and tolerance before testing it. Otherwise the validator may confidently reject a correct document. Keep a reason for each failure so a person can challenge the check as well as the model.

Google’s structured-output guidance explicitly covers outputs that conform to a schema but are semantically incorrect. That is the useful boundary: formatting controls help software read an answer; application checks still have to examine its values.

For extracted fields, keep a reference to the relevant source passage or document location. Then check it. A model-generated reference can itself be wrong, and a page number alone does not establish that the cited text supports the amount. Store the original input alongside the candidate and validation outcome so a reviewer can see what happened.

Give missing information somewhere honest to go

A missing delivery charge must not quietly become zero. Zero says delivery costs nothing. A missing field says the value was not supplied in the object. A null value can represent an unavailable amount, if that is the meaning your application has explicitly defined.

OpenAI’s Structured Outputs documentation requires fields to be marked required and describes using a nullable type for optional values. That is an API-specific design rule. Requiring the field to exist does not require inventing its value.

Define what happens next when a necessary value is unavailable. Perhaps the document goes to review, or the product asks for a clearer copy. The important part is that an empty value cannot acquire the meaning of a confirmed amount simply because the next system expects a number.

A response is not always a completed record

Before validating extracted fields, inspect the response status. Anthropic documents refusal and token-limit cases where output may not match the requested schema. Treat those as explicit outcomes. A truncated object should not be repaired into a record and passed along as though extraction finished normally.

Check which schema constraints your chosen API and validation library actually enforce. A condition written into a field description is guidance; it does not automatically become an executable check.

Keep an unaccepted candidate separate from accepted data. If review is needed, show the source, disputed fields and failed checks together. That is where a useful AI-to-human handoff matters: the person needs enough context to resolve the problem, not just a red badge saying something went wrong.

Measure what happens after parsing

Build a small test set with wrong totals, missing charges, conflicting currencies and incomplete responses. Label these as proposed test cases until they have actually been run. Record schema acceptance, field accuracy and the handling of unresolved cases separately.

This follows the same principle behind making evaluations part of the product: name the behaviour a passing result actually supports. A perfect parsing rate tells you something useful. It still leaves the invoice on the desk, waiting to be checked.