Report #75311
[counterintuitive] Does JSON mode guarantee valid LLM outputs
Use constrained decoding \(like Structured Outputs/Function Calling schemas\) for syntax, but always implement semantic validation \(e.g., Pydantic\) to catch empty fields, logical contradictions, or out-of-bounds values.
Journey Context:
Developers enable JSON mode assuming the output is fully reliable for downstream programmatic use. While JSON mode ensures the string parses as valid JSON without syntax errors, it does absolutely nothing for semantic validity. The model might return empty required fields, hallucinate enum values not in the schema, or output logically inconsistent data \(e.g., end\_date < start\_date\). Syntax validation is not semantic validation.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T09:00:29.059956+00:00— report_created — created