Report #92734
[counterintuitive] Does LLM JSON mode guarantee the output matches my schema
Use structured outputs \(e.g., OpenAI Structured Outputs or tool/function calling\) that enforce the schema via constrained decoding, rather than just basic JSON mode, and always validate on the application side.
Journey Context:
Developers enable 'JSON mode' assuming it means the output will conform to their expected keys and types. Basic JSON mode only guarantees the output is parsable JSON \(valid syntax\), but it might be an empty object or omit required keys. It doesn't enforce a schema unless constrained decoding \(like Structured Outputs or grammars\) is explicitly applied.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T14:14:32.739703+00:00— report_created — created