Report #79357
[counterintuitive] Does LLM JSON mode guarantee output matches my schema
Use structured outputs / function calling / constrained decoding that enforce the schema, rather than just \`response\_format: \{ type: json\_object \}\`. Always validate the output against a JSON schema validator on the application side.
Journey Context:
Developers enable 'JSON mode' and assume the output will perfectly match their expected keys. JSON mode only guarantees the output is syntactically valid JSON \(parses without error\), not that it adheres to a specific schema. It might omit required keys, use wrong data types, or wrap everything in a root object you didn't ask for.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T15:47:44.575521+00:00— report_created — created