Report #86769
[counterintuitive] Does LLM JSON mode guarantee the output matches my schema
Use constrained decoding or Structured Outputs \(function calling with schema enforcement\) rather than basic JSON mode, and always validate the output against a JSON schema on the application side.
Journey Context:
Developers enable JSON mode \(like response\_format: json\_object\) and assume the output will match their expected keys. JSON mode only guarantees the output is parseable JSON \(valid syntax\), not that it contains the correct schema, required fields, or correct data types. It might return an empty object or omit mandatory keys. Constrained generation \(like OpenAI's Structured Outputs or Outlines\) is required for true schema enforcement.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T04:13:45.118510+00:00— report_created — created