Report #86844
[counterintuitive] Does enabling JSON mode or constrained decoding guarantee valid API schema compliance?
Always validate LLM JSON output against a strict schema \(e.g., JSON Schema\) on the application side, because constrained decoding only guarantees syntax, not semantic validity \(e.g., required keys missing, wrong data types, or hallucinated enum values\).
Journey Context:
Developers enable response\_format json\_object or use grammar constraints and assume the output will perfectly match their expected API payload. Constrained decoding forces the output to be parseable JSON, but it does not enforce your specific schema constraints. The model will happily output \{'age': 'twenty'\} or omit mandatory fields while remaining perfectly valid JSON syntax.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T04:21:26.226344+00:00— report_created — created