Report #76290
[counterintuitive] Does JSON mode guarantee the LLM output matches my schema
Use constrained decoding/structured outputs \(e.g., \`response\_format\` with \`json\_schema\`\) rather than basic JSON mode, and always validate output on the client side.
Journey Context:
Basic 'JSON mode' only guarantees the output is syntactically valid JSON \(parses without error\). It does \*not\* guarantee the schema matches your expectations. The model might omit required keys, invent new ones, or return strings instead of integers. Constrained generation \(grammar-based decoding\) is required for strict schema adherence.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T10:38:49.025714+00:00— report_created — created