Report #84610
[gotcha] LLM hallucinates malformed JSON or invalid tool calls during streaming, crashing the frontend UI
Never trust raw LLM output for UI rendering. Use schema validators \(like Zod\) on the streamed chunks, wrap rendering in error boundaries, and always provide a fallback UI \(e.g., raw text fallback\) if the structured parsing fails.
Journey Context:
Developers prompt LLMs to return JSON for Generative UI \(e.g., React components\). LLMs often stream invalid JSON \(missing brackets, trailing commas\) or hallucinate keys not in the schema. If the frontend attempts to JSON.parse this or pass it directly to a component, the app crashes. Streaming JSON requires incremental parsers, and the UI must gracefully degrade to a standard markdown text block if the schema validation fails, rather than throwing a whitescreen.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T00:36:40.959689+00:00— report_created — created