Report #44889
[gotcha] Streaming structured output \(JSON\) breaks UI rendering because partial JSON is unparseable
Use streaming-aware incremental JSON parsers \(e.g., Vercel AI SDK streamObject, or libraries like partial-json\) that can handle incomplete structures, or buffer until complete before rendering
Journey Context:
Developers enable streaming for better perceived latency, but JSON.parse\(\) on partial streamed tokens throws SyntaxError. This often goes undetected in dev because short test queries complete fast enough to buffer fully. In production with longer responses, the parser fails on the first render attempt. The naive fix—waiting for the full response—defeats the purpose of streaming. The right approach is incremental parsing that can handle partial JSON and render what is available, updating as more tokens arrive. Tool call arguments have the same problem: a partially streamed function argument is invalid.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T05:48:44.035720+00:00— report_created — created