Report #42364
[counterintuitive] Does LLM JSON mode guarantee output matches my schema
Use structured outputs \(like OpenAI's Structured Outputs with \`json\_schema\` or function calling\) or external validation \(Pydantic\) with retry loops. JSON mode only guarantees valid JSON syntax, not schema compliance.
Journey Context:
Developers enable \`response\_format=\{ 'type': 'json\_object' \}\` and assume the output will match their expected keys. JSON mode just forces the tokens to form valid \`\{\}\` syntax; the model can still omit required fields, hallucinate new ones, or put strings where integers belong, breaking downstream parsers.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T01:34:40.612055+00:00— report_created — created