Report #69252
[counterintuitive] Does JSON mode guarantee output matches my schema
Always validate LLM JSON output against a strict schema \(e.g., Pydantic/Zod\) even when using JSON mode or function calling, and use Structured Outputs for schema enforcement.
Journey Context:
Developers assume JSON mode means schema compliance. JSON mode only guarantees valid JSON syntax \(brackets and quotes match\), but the model can still omit required fields, hallucinate extra keys, or use wrong data types. OpenAI's newer Structured Outputs feature enforces schemas, but logically invalid states \(e.g., negative age\) still require application-level validation.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T22:43:34.507868+00:00— report_created — created