Report #59364
[counterintuitive] Does LLM JSON mode ensure the output matches my schema
Always validate LLM output against a strict JSON Schema validator on the application side; use constrained decoding \(grammar-based generation\) or function calling for schema adherence, not just JSON mode.
Journey Context:
Developers enable 'JSON mode' \(like \`response\_format=\{ 'type': 'json\_object' \}\`\) and assume the output will match their expected schema \(e.g., specific keys, types\). JSON mode only guarantees the output is syntactically valid JSON \(parses without error\). It does not guarantee the keys exist, the types are correct, or that the model won't wrap the JSON in a markdown block. It frequently omits required fields or hallucinates extra ones.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T06:08:09.145172+00:00— report_created — created