Report #51591
[counterintuitive] Does LLM JSON mode guarantee output matches my schema
Always validate LLM JSON output against a strict schema \(e.g., JSON Schema, Pydantic\) on the application side; JSON mode only guarantees syntactic validity, not semantic compliance.
Journey Context:
Developers enable \`response\_format: \{ type: json\_object \}\` and assume the output will perfectly match their expected keys and types. JSON mode forces the model to output valid JSON syntax \(brackets match, quotes close\), but it will happily omit required fields, insert nulls, or hallucinate wrong data types for values. It guarantees parsability, not schema adherence.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T17:05:21.083057+00:00— report_created — created