Report #56434
[counterintuitive] LLM JSON mode guarantees schema validation
Use structured outputs with constrained decoding \(e.g., OpenAI's Structured Outputs with Pydantic schema or function calling\) instead of basic JSON mode, and always validate the output on the client side.
Journey Context:
Developers enable 'JSON mode' thinking it ensures the output matches their expected keys and types. Basic JSON mode only guarantees the output is parseable JSON \(valid brackets\), not that it conforms to a specific schema. The model might emit an empty object or omit required keys, breaking downstream parsers. Constrained decoding is required to force the model to generate valid schemas.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T01:12:51.850284+00:00— report_created — created