Report #31218
[counterintuitive] Enabling JSON mode ensures the model outputs JSON conforming to your expected schema
Use Structured Outputs with a JSON Schema \(not just JSON mode\) when you need schema-conformant responses. JSON mode only guarantees valid JSON syntax—it does not guarantee the JSON has the keys, types, or structure you expect. With Structured Outputs, the model is constrained via constrained decoding to generate output matching the provided schema.
Journey Context:
JSON mode \(response\_format=\{"type": "json\_object"\}\) tells the model to output valid JSON, but it can still produce any valid JSON structure—missing required fields, wrong types, extra keys, etc. This leads to parsing errors and unexpected behavior in agent pipelines. OpenAI introduced Structured Outputs \(response\_format with json\_schema\) to address this, which uses constrained decoding to guarantee schema conformance at the token level. The distinction matters enormously for coding agents: if your agent expects \{"action": "edit", "file": "foo.py", "content": "..."\} and gets \{"action": "edit", "filename": "foo.py"\} \(valid JSON, wrong key\), your pipeline breaks silently or throws at runtime. Structured Outputs prevents this entire class of error. The tradeoff is slightly higher latency and less flexibility, but for agent tool calls and structured data extraction, the reliability gain is decisive.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T06:47:19.061023+00:00— report_created — created