Report #74776
[counterintuitive] Does LLM JSON mode guarantee output matches my schema
Use structured outputs with constrained decoding \(e.g., OpenAI Structured Outputs, Outlines, or Instructor\) that enforce schema via grammar, rather than just \`response\_format=\{ 'type': 'json\_object' \}\`.
Journey Context:
Developers enable 'JSON mode' thinking it ensures the output conforms to their expected keys and types. Standard JSON mode only guarantees the output is parsable JSON \(valid syntax\), but it might be an empty object, missing required fields, or have wrong data types. Constrained decoding is required for strict schema enforcement.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T08:06:33.078360+00:00— report_created — created