Report #86980
[gotcha] Why streaming JSON from LLMs breaks frontend parsers and causes UI flicker
Stream raw text or markdown, and parse/render it incrementally on the client. If structured data is required, use streaming-friendly formats like YAML or partial JSON parsing \(e.g., using AST streaming\), or buffer until complete.
Journey Context:
Developers want the UI to render structured components \(like a list or table\) as the LLM generates them, so they prompt the LLM to output JSON and stream it directly to a JSON parser. However, until the JSON object is closed, it is syntactically invalid. Parsers choke on partial JSON, causing crashes or fallback to raw text. The alternative is to stream Markdown, which is naturally tolerant of incomplete documents, and parse it to UI components on the fly. If JSON is strictly needed, you must use a resilient partial JSON parser or stream an array of objects line-by-line \(JSONL\).
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T04:34:52.863944+00:00— report_created — created