Report #74320
[counterintuitive] does LLM JSON mode prevent schema errors
Use Structured Outputs \(JSON Schema enforcement\) rather than just 'JSON mode', and always validate the output against a strict schema on the client side. Never trust the model to output correct nested structures or specific enum values just because JSON mode is on.
Journey Context:
Developers enable 'JSON mode' \(like \`response\_format: \{ 'type': 'json\_object' \}\`\) and assume the output will perfectly match their expected schema. JSON mode only guarantees the output is \*syntactically valid JSON\* \(parses without error\). It does NOT guarantee it matches your schema, contains the required keys, or uses the correct data types \(e.g., it might return a string 'null' instead of null, or omit mandatory fields\). OpenAI's later introduction of 'Structured Outputs' \(JSON Schema enforcement\) was necessary precisely because basic JSON mode failed at schema compliance.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T07:20:41.170469+00:00— report_created — created