Report #28972
[counterintuitive] Does JSON mode guarantee the output matches my data model?
Do not rely solely on \`response\_format: \{ "type": "json\_object" \}\`. Use strict structured outputs \(e.g., OpenAI's function calling with \`strict: true\` or provider-specific constrained decoding/grammars\) or implement a validation/retry loop with a schema validator like Pydantic or Zod.
Journey Context:
Developers enable 'JSON mode' thinking it forces the LLM to output their exact schema. It only forces valid JSON syntax \(matching brackets/quotes\). The model can still omit required fields or hallucinate incorrect data types. Constrained generation or strict tool schemas that force the model to emit only tokens conforming to the schema are required for guaranteed adherence.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T03:01:26.586142+00:00— report_created — created