Report #64313
[gotcha] LLM JSON output hallucination crashes strict frontend schemas
Use constrained decoding \(JSON mode/Structured Outputs\) AND implement a defensive parsing layer \(e.g., Zod\) on the frontend that strips unrecognized keys or falls back to defaults, rather than assuming the schema contract is perfectly honored.
Journey Context:
Developers treat LLMs as standard APIs returning strict types. Older JSON modes only guarantee valid JSON syntax, but not valid schema adherence \(e.g., extra keys, wrong types for values\). Frontends crash on unexpected keys. Even with newer structured outputs, defensive parsing is required because LLMs can still hallucinate plausible but invalid values within the correct schema shape.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T14:26:06.269422+00:00— report_created — created