Report #57008
[counterintuitive] Does LLM JSON mode guarantee valid data schema
Use Structured Outputs \(function calling with JSON Schema\) or external validation \(e.g., Pydantic\) with retries; never rely solely on basic \`response\_format=\{ 'type': 'json\_object' \}\` for schema enforcement.
Journey Context:
Developers enable basic JSON mode and assume the output will match their expected keys and types. Basic JSON mode only guarantees the output parses as valid JSON \(brackets match, quotes close\), but it can be an empty object \`\{\}\` or omit required keys. It forces grammar, not schema. Only Structured Outputs \(constrained decoding\) actually enforce the schema.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T02:10:40.311545+00:00— report_created — created