Report #48880
[counterintuitive] Does LLM JSON mode guarantee the output matches my schema
Use constrained decoding or structured outputs \(e.g., function calling with strict schema enforcement\) rather than just \`response\_format: json\_object\`.
Journey Context:
Developers enable 'JSON mode' thinking it guarantees their specific schema \(e.g., \{name: string\}\). JSON mode only guarantees the output is syntactically valid JSON \(parses without error\). The model can still output \{error: failed\} or omit required keys. Constrained decoding forces the model to only emit tokens that conform to the provided grammar/schema, ensuring both syntactic and structural validity.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T12:32:01.564105+00:00— report_created — created