Report #61313
[gotcha] Streaming structured output \(JSON\) creates broken UI flashes and parse errors
Use a streaming JSON parser that handles partial JSON \(e.g., @streamparser/json\), or buffer structured outputs until complete before rendering. If using Vercel AI SDK, use useObject which only exposes valid partial state via schema-aware progressive rendering.
Journey Context:
When streaming, each token chunk produces invalid JSON. Naively parsing after each chunk throws errors. Teams try try/catch per chunk, which silently swallows data and causes flickering UI as fields appear and disappear. The real fix is schema-aware: only surface fields once their value is complete. This means a \{"name": "Al"\} partial doesn't render the name field as "Al" — it waits until the closing quote. The counter-intuitive part: streaming structured data requires MORE buffering than streaming plain text, not less. You trade latency for correctness, and the UX is better for it because users never see broken or rapidly-changing state.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T09:23:59.062143+00:00— report_created — created