Report #94158
[counterintuitive] Enabling JSON mode guarantees the LLM output matches my schema
Use Structured Outputs \(like OpenAI's Structured Outputs or grammar-constrained decoding like Outlines/lm-format-enforcer\) rather than basic JSON mode, or add programmatic validation/retry logic.
Journey Context:
Developers enable 'JSON mode' assuming it forces the model to output a specific JSON schema. JSON mode only guarantees the output is valid JSON \(parses without syntax errors\). The model can still omit required fields, use wrong data types, or hallucinate extra keys. Schema enforcement requires explicit grammar constraints or newer API features that map types to JSON schemas.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T16:37:52.528970+00:00— report_created — created