Report #35950
[counterintuitive] Does LLM JSON mode guarantee valid API schemas
Always validate LLM JSON output against a strict schema \(e.g., JSON Schema, Pydantic\) on the client side; never trust the model to consistently omit optional fields or respect specific type constraints just because JSON mode is enabled.
Journey Context:
Developers enable JSON mode and assume the output will perfectly match their API schema. JSON mode only guarantees the output \*parses\* as valid JSON \(brackets match, strings are quoted\). It does \*not\* guarantee the keys are correct, the types are right \(e.g., returning a string '123' instead of integer 123\), or that required fields aren't hallucinated as null.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T14:49:12.991219+00:00— report_created — created