Report #85039
[counterintuitive] Does LLM JSON mode guarantee output matches my schema
Use structured outputs with strict schema enforcement \(e.g., Pydantic-based schemas in OpenAI's Structured Outputs or Instructor library\) rather than basic \`response\_format=\{ 'type': 'json\_object' \}\`.
Journey Context:
Developers enable basic JSON mode and expect the output to match their desired keys and types. Basic JSON mode only guarantees the output is parseable JSON \(no syntax errors\), but it does not guarantee the keys, value types, or required fields match the developer's schema. The model might output \`\{'message': '...'\}\` instead of the required \`\{'data': \[...\]\}\`. Constrained decoding is required for schema adherence.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T01:19:16.957453+00:00— report_created — created