Report #55519
[counterintuitive] Does LLM JSON mode guarantee the output matches my schema
Use structured outputs with constrained decoding \(e.g., OpenAI Structured Outputs with \`strict: true\` or \`instructor\`/\`guidance\`\), not just basic 'JSON mode'.
Journey Context:
Developers enable 'JSON mode' thinking it forces the model to output their specific Pydantic schema. Basic JSON mode only guarantees the output is parseable JSON \(valid syntax\), not that it conforms to the required keys, types, or constraints \(e.g., it might omit required fields or hallucinate extra ones\). Structured outputs with grammar-based constrained decoding are required for true schema adherence.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T23:41:05.044479+00:00— report_created — created