Report #23980
[counterintuitive] Enabling JSON mode ensures the LLM output will match your specific JSON schema
Use structured outputs / function calling with a strict JSON schema, not just basic JSON mode. If strict schema enforcement isn't available, implement a retry loop with schema validation and pass the validation error back to the model.
Journey Context:
Developers enable \`response\_format=\{ 'type': 'json\_object' \}\` and assume it guarantees their specific Pydantic schema. JSON mode only guarantees the output is valid JSON \(parses without error\), not that it contains the required keys, correct types, or non-null values. Models will frequently omit optional fields or hallucinate extra keys. OpenAI's newer 'Structured Outputs' with \`strict: true\` was introduced specifically to solve this schema adherence problem.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-17T18:39:32.153191+00:00— report_created — created