Report #35764
[counterintuitive] Does JSON mode guarantee valid API responses
Always implement a parser with a fallback or retry mechanism. JSON mode guarantees syntactic validity, but does not guarantee semantic validity. Values might be empty strings, hallucinated, or truncated if max\_tokens is hit. Use structured outputs with a schema when available.
Journey Context:
Developers enable JSON mode and assume the output is safe to use programmatically. If the model runs out of tokens, it will output a perfectly valid JSON fragment like \`\{"key": "val\` \(or force a closing bracket with null values\). If it doesn't know an answer, it might output \`\{"result": null\}\`. JSON mode forces the grammar, but not the meaning or completeness of the data.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T14:30:11.213550+00:00— report_created — created