Separate the format contract from the business contract
OpenAI’s Structured Outputs documentation explains schema-constrained responses and distinguishes safety refusals from an ordinary successful structured result. A schema can require a field, constrain its type or limit a category. Those structural rules do not verify that an extracted amount belongs to the correct line or reflects an accepted commercial term.
Define what the application will do with the proposed data before choosing the schema. A quotation comparison needs quantities, purchasing units and costs that agree with one another. Treat the model output as a proposal until the required evidence and validation have passed.
Define the unknown state before the happy path
A required field should not force the model to invent a value when the source omits it. Design an explicit unknown state and preserve its reason. A zero freight charge, an included charge and an unanswered freight question have different meanings. The schema should allow the workflow to retain that distinction, with validation appropriate to each state.

Structure is the first check.
- Schema
- Expected fields and types
- Evidence
- Supporting source location
- Meaning
- Units and relationships
- Review
- Accepted version recorded
| Evidence | Meaning |
|---|---|
| Schema | Expected fields and types |
| Evidence | Supporting source location |
| Meaning | Units and relationships |
| Review | Accepted version recorded |
Quotation fields remain proposed until evidence and relationship checks pass.
Keep evidence references separate from confidence labels. A source page, quoted phrase or recorded message gives a reviewer somewhere to check. A generated confidence value is not a substitute for that evidence. Also record the source version used for extraction so a later revision does not silently overwrite the context of an earlier decision.
Work through an incomplete quotation
Consider a quotation in which a supplier prices 12 filter cartridges at EGP 250 each and writes “delivery to be confirmed.” The known goods subtotal is EGP 3,000. The extraction should preserve the quantity, unit price, currency and delivery uncertainty. It should not present that goods subtotal as the complete delivered cost.
| Field | Value | Meaning |
|---|---|---|
| Goods subtotal | EGP 3,000 | 12 × EGP 250; before unresolved charges. |
| Freight amount | Unknown | The source does not provide a charge. |
| Delivery promise | Unconfirmed | A supplier clarification is needed. |
| Review status | Proposed | No buyer has accepted the extracted record. |
Calculate the goods subtotal from the validated values and ask the buyer to resolve freight and delivery beside the source. When the supplier responds, retain the new evidence as a versioned update rather than overwriting the earlier incomplete record.
Validate in layers
- Check that the response is present, complete and structurally supported by the application.
- Validate required fields, allowed values and data types.
- Check source identities and evidence locations.
- Apply arithmetic, unit, date and relationship checks in application code.
- Route unresolved or consequential fields to the responsible reviewer.
Keep a distinct path for a refusal, interrupted response and technical failure. None should become an empty successful record. A retry should preserve the same source identity and extraction version so repeated attempts do not create duplicate proposals. Limit automatic repair attempts and make unresolved failures available to their owner.
Render a reviewable result
Show the important extracted fields next to their evidence, with unknowns visible in the same working area. A buyer should be able to correct a quantity without reconstructing the whole quotation. Record the correction, the reviewed source and the accepted version. The interface’s saved confirmation should correspond to a record the application actually stored.
Keep untrusted text safe when displaying it. A supplier description belongs in a text field, not executable markup. The renderer and storage layer own escaping, permitted content and identity. Include review, correction and target-system reuse in acceptance criteria agreed with Trion.
Evaluate the cases that look nearly correct
Use test documents with pack sizes, mixed currencies, revised terms and missing totals. Include a case where a valid number appears beside the wrong line. Score semantic correctness separately from schema adherence, recording which incorrect or unresolved fields need review.