OpenAI says Structured Outputs makes a reply match your JSON schema, and that the values inside can still be wrong. This test asks what that means when a document doesn't contain a value your schema requires.
What the documentation promises
OpenAI's guide separates two things. Structured Outputs makes the reply follow your schema, including required fields and types. JSON mode does not. Neither promises that a value is correct. In strict mode every field must be listed as required, additionalProperties must be false, and a field that may be absent is written as a union with null. OpenAI's Structured Outputs guide
The Codex command line has an --output-schema flag that takes a schema file for the final reply. Codex non-interactive mode To see whether the flag is strict, a deliberately wrong schema was sent with it. The API refused it with an HTTP 400: "Invalid schema for response_format 'codex_output_schema': 'schema.additionalProperties' is required to be supplied and to be false when strict is true." So the flag asks for strict enforcement.
The setup
- Model:
gpt-6.2-sol, reported by Codex on all 108 calls. Model page - Tool: codex-cli 0.172.0, one fresh call per invoice, read-only sandbox, reasoning effort left at the machine default.
- Run date: 2026-11-25, evening Central time. Both rounds were run by AI agents working for CTS, not by hand.
- One variable: arm E adds
--output-schema schema.json. Arm P sends the same prompt, which includes the same schema text, with no enforcement. - Data: synthetic invoices from fictional vendors. No client data.
The schema:
{
"type": "object",
"properties": {
"invoice_number": {"type": "string"},
"invoice_date": {"type": "string"},
"vendor": {"type": "string"},
"currency": {"type": ["string", "null"]},
"subtotal": {"type": ["number", "null"]},
"tax": {"type": ["number", "null"]},
"total": {"type": ["number", "null"]}
},
"required": ["invoice_number", "invoice_date", "vendor", "currency", "subtotal", "tax", "total"],
"additionalProperties": false
}
The prompt, identical in both arms (the schema text and the invoice are inserted where marked):
Extract the fields below from the invoice text at the end of this message.
Schema (JSON Schema):
{SCHEMA}
Rules:
- Extract only what is printed on the invoice.
- Use null for any field that is not printed. Never calculate or infer a value that is not printed.
- invoice_date is the date the invoice was issued, formatted yyyy-mm-dd.
- currency is an ISO 4217 code (for example USD).
- Numbers are plain JSON numbers without currency symbols or thousands separators.
- Output only the JSON object, nothing else.
Invoice text:
<<<
{INVOICE}
>>>
Round 1: 30 invoices, can the schema fix accuracy?
The 30 invoices mixed layouts and traps: 12 plain, 5 with an invoice date, a due date and a service date, 5 with no total printed, 4 with currency symbols or words, and 4 with a credit line where the printed total, not the balance, is the answer. The scoring rules were written before any run. An invoice counted as correct only if all seven fields matched the answer key.
| Measure | Schema enforced (E) | Prompt only (P) |
|---|---|---|
| Calls that returned a reply | 30 of 30 | 30 of 30 |
| Parsed as JSON as-is | 30 of 30 | 30 of 30 |
| Valid against the schema | 30 of 30 | 30 of 30 |
| All seven fields correct | 30 of 30 | 30 of 30 |
| Missing-total invoices that got a number | 0 of 5 | 0 of 5 |
Enforcement changed nothing about accuracy here. On this fixture the model was already clean.
Round 2: what happens when the schema asks for something that isn't there?
Round 1 gave no difference, so round 2 aimed at the schema itself. In the schema above, invoice_date is a required string. It is not allowed to be null. The prompt still says to use null for anything not printed. The two instructions disagree on purpose.
Twelve invoices: six with the date printed (three formats), three with no date anywhere, and three with only a due date. For the last six the answer key is null, because the prompt defines the date as the day the invoice was issued. Each invoice ran twice per arm, so each arm made 24 calls. The scoring rules were written before the runs.
A no-date invoice, abbreviated:
TALLGRASS OFFICE SUPPLY
INVOICE 12767
Due: 15 August 2026
...
Total USD 422.84
The invoice_date field in each reply:
| Reply | Schema enforced (E) | Prompt only (P) |
|---|---|---|
| Invoices with the date printed (12 calls) | the correct date, 12 of 12 | the correct date, 12 of 12 |
| No date printed anywhere (6 calls) | "" (empty string), 6 of 6 | null, 6 of 6 |
| Only a due date printed (6 calls) | "" (empty string), 6 of 6 | null, 6 of 6 |
| Replies valid against the schema | 24 of 24 | 12 of 24 |
| Other six fields correct | 24 of 24 | 24 of 24 |
| An invented date, or the due date copied in | 0 | 0 |
With the schema enforced, the model could not say null, so it returned an empty string. Every reply was valid. Without enforcement it said null every time, which is what the prompt asked for and what a person would call correct, and 12 of those 24 replies failed the schema check because null isn't allowed there.
What this does and does not show
- It shows the pattern on this fixture: valid and honest pulled apart when the schema and the document disagreed. It does not show how often another document set would do it.
- It does not show that strict mode is a bad idea. It shows that the schema decides what an honest "I don't know" looks like.
- It is 12 invoices, two repeats each, one model and one machine setup. A different model or a different schema can behave differently.
- Round 2 was added after round 1 showed no difference, as a follow-up aimed at the schema. It was not the first plan.
- The Codex command line loaded its normal user configuration for these runs, so this is a test of Codex with the model, not a bare API call.
What I would do with this
If a document can leave a field out, write that field as a union with null in the schema and say so in the prompt. Then test with documents that leave it out, and check what your database receives: an empty string and a missing date are different records. A report that counts valid replies hides the difference.
Run it yourself
The command for each invoice, with the prompt on standard input (drop --output-schema for arm P):
codex exec -m gpt-6.2-sol -s read-only --ephemeral --skip-git-repo-check --color never -o reply.txt --output-schema schema.json -
Score the reply against your own answer key before you look at it. For the date test, count three things: replies valid against the schema, replies with null, and replies with an empty string or invented date.
Have a workflow you want to test?
Start with one task, sample inputs, and a clear definition of a good result. See the CTS workflow pilot.



