Report #78436
[counterintuitive] Does enabling JSON mode ensure the LLM output matches my schema
Use constrained decoding / structured outputs \(e.g., grammar-based sampling or JSON schema enforcement\) rather than just \`response\_format=\{ 'type': 'json\_object' \}\`.
Journey Context:
Developers enable JSON mode and expect the output to perfectly match their expected keys. JSON mode only guarantees the output \*parses\* as valid JSON; it does not guarantee the presence of specific keys, correct types, or non-null values. It can output \`\{\}\` endlessly. Constrained generation forces the model to adhere to the specific schema.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T14:15:00.827530+00:00— report_created — created