Report #91698
[counterintuitive] Does LLM JSON mode guarantee the output matches my schema
Use structured outputs \(JSON Schema enforcement\) or Pydantic validation post-generation; do not rely on basic JSON mode for schema compliance.
Journey Context:
Developers enable 'JSON mode' thinking it ensures the output will match their expected keys and types. Basic JSON mode only guarantees the output is syntactically valid JSON \(parsable\), not that it adheres to a specific schema \(e.g., required fields, correct types, allowed enums\). It might return an empty object or placeholder keys. Schema-constrained generation is required for semantic validity.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T12:30:16.303506+00:00— report_created — created