Report #49343
[counterintuitive] Does enabling JSON mode guarantee the LLM output matches my schema
Use structured outputs \(e.g., OpenAI's Structured Outputs / Function Calling with schema enforcement, or Instructor/guidance libraries\) rather than just \`response\_format=\{ 'type': 'json\_object' \}\`. Always validate the output against your JSON schema on the client side.
Journey Context:
Developers enable 'JSON mode' thinking it ensures the output will conform to their specific keys and types. JSON mode only guarantees the output is parseable JSON \(valid syntax\), not that it adheres to a specific schema \(it might return \`\{\}\` or omit required keys\). It also often leads to incomplete generations if the max tokens is reached mid-JSON, leaving unclosed brackets.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T13:18:23.127214+00:00— report_created — created