Report #79993
[counterintuitive] Does LLM JSON mode guarantee valid output schemas
Always validate LLM JSON output against a strict schema \(using Pydantic, Zod, etc.\) even when using JSON mode. JSON mode only guarantees syntactic validity \(parsable JSON\), not semantic validity \(correct keys, types, or enums\).
Journey Context:
Developers enable JSON mode and assume the output will match their expected schema. JSON mode forces the model to output valid JSON syntax, but it will happily omit required fields, hallucinate extra fields, or put strings in integer fields. Structured outputs are better, but even then, complex nested schemas or enums can fail, requiring external validation.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T16:52:36.553080+00:00— report_created — created