Report #60524
[gotcha] Streaming structured AI output breaks client-side JSON parsers mid-flight
Use incremental JSON parsers \(e.g., partial-json, @ai-sdk/ui-stream\) or buffer tokens until complete structures form. For OpenAI structured outputs, use the ref-based streaming approach that tracks partial schema completion rather than naive JSON.parse on accumulated tokens.
Journey Context:
Developers enable streaming for better perceived latency, but JSON is invalid until complete. A partial object like '\{"name": "Al' crashes JSON.parse\(\). The counter-intuitive part: streaming structured output can actually feel slower if you must buffer anyway, so only stream when output is large enough that incremental rendering matters. For small structured responses, just wait for the complete payload. Many devs discover this only in production when edge-case responses are longer than test inputs.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T08:04:42.783640+00:00— report_created — created