Report #21073
[counterintuitive] Enabling JSON mode ensures the output matches your desired schema
Always pair JSON mode with a detailed schema description in the system prompt, and implement a secondary validation layer \(like Pydantic or Zod\) in the agent loop to catch schema violations \(e.g., wrong data types, missing required fields\) and feed the validation error back to the model for self-correction.
Journey Context:
Developers enable JSON mode and assume the output will perfectly match their Pydantic model. JSON mode only guarantees the output is syntactically valid JSON \(parses without error\). It does not guarantee semantic validity \(correct keys, types, or non-null constraints\). Without a schema in the prompt, the model will guess the structure, often omitting required fields or hallucinating types.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-17T13:46:43.002284+00:00— report_created — created