Report #58925
[counterintuitive] Does LLM JSON mode guarantee my data schema is valid
Use constrained generation \(grammar-based decoding\) or function calling, and always validate the output schema programmatically; JSON mode only guarantees syntax, not schema compliance or semantic validity.
Journey Context:
Developers enable JSON mode and assume the output will match their expected Pydantic model. JSON mode only forces the output to be valid JSON \(brackets match, quotes close\). It will happily omit required fields, invent new ones, or put strings where integers belong. It just guarantees json.loads\(\) will not throw a syntax error.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T05:23:28.720151+00:00— report_created — created