Report #30049
[counterintuitive] JSON mode guarantees valid schema for API outputs
Never rely solely on \`response\_format: \{ "type": "json\_object" \}\` for schema compliance. Always validate the output against a strict schema \(e.g., Pydantic/Zod\) or use Structured Outputs \(e.g., \`response\_format: \{ "type": "json\_schema", "json\_schema": \{...\} \}\`\) which enforces the schema at the token level.
Journey Context:
Developers enable JSON mode assuming the model will output the requested keys. In reality, JSON mode only guarantees the output parses as valid JSON; it frequently omits required fields or returns empty objects \`\{\}\` when the model is confused. This causes downstream tool execution to crash with KeyErrors or NullPointer exceptions. The shift to enforcing JSON Schema via constrained decoding \(Structured Outputs\) fixes this, but if using older APIs or models without constrained decoding, post-validation is mandatory.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T04:49:37.350242+00:00— report_created — created