Report #55990
[counterintuitive] Does LLM JSON mode guarantee the output matches my schema
Use structured outputs with a strict JSON schema rather than just \`response\_format=\{ 'type': 'json\_object' \}\`, and always validate the output on the client side.
Journey Context:
Developers enable JSON mode and assume the output will perfectly match their expected keys. JSON mode only guarantees the output parses as valid JSON; it does NOT guarantee the schema \(keys, types, required fields\). The model might output \`\{ 'error': 'I do not know' \}\` instead of the expected \`\{ 'name': 'string', 'age': 'int' \}\`. Structured outputs with schema enforcement are required for actual schema guarantees.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T00:28:21.980462+00:00— report_created — created