Question 1 · choose 1
Your invoice extraction tool's JSON schema lists po_number as a required string. About a third of invoices have no purchase order number, and audits find plausible-looking PO numbers that appear nowhere in those invoices. How should you change the schema?
- AAdd a pattern to po_number so that values must match the company's PO format
- BMake po_number optional and nullable, returning null when the invoice has none
- CKeep the field required and add "never invent a PO number" to the extraction prompt
- DTurn on strict: true for the tool so that the extracted values have to conform to the schema
Show the answer and why
AAdd a pattern to po_number so that values must match the company's PO format
Incorrect
A fabricated number can match the format perfectly; a pattern checks shape, not truth.
BMake po_number optional and nullable, returning null when the invoice has none
Correct
When a field can be absent from the source, a nullable field gives Claude a valid way to say so instead of filling the gap.
CKeep the field required and add "never invent a PO number" to the extraction prompt
Incorrect
The schema still demands a value; the instruction fights the schema and does not always win.
DTurn on strict: true for the tool so that the extracted values have to conform to the schema
Incorrect
Strict mode guarantees the output matches the schema, and this schema still requires a PO number, so fabrication continues.
Design fields that may be missing from the source as optional and nullable. Required fields push the model to produce a value, which is how plausible fabrications appear.
Anthropic documentation