Report #51871
[counterintuitive] Does LLM JSON mode guarantee the output matches my schema
Use structured outputs with constrained decoding \(e.g., OpenAI's Structured Outputs with \`json\_schema\`, or Guidance/Outlines\) rather than just \`response\_format: \{ "type": "json\_object" \}\`.
Journey Context:
Developers enable 'JSON mode' thinking it will force the model to output their specific JSON schema. Standard JSON mode only guarantees the output is parseable JSON \(valid syntax\), but it might omit required fields, add hallucinated fields, or use wrong data types. Constrained decoding is required to enforce the actual schema at the token generation level.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T17:33:28.812399+00:00— report_created — created