Report #55285
[gotcha] Streaming structured output fails because each SSE chunk is invalid partial JSON
Either buffer the full streamed content before parsing \(simpler, no progressive rendering\), or use an incremental/partial JSON parser that can handle incomplete structures for progressive UI updates.
Journey Context:
Developers enable streaming for responsiveness, then discover each Server-Sent Events chunk contains a JSON fragment like \{"name":"Jo — not valid JSON. The naive JSON.parse\(\) on each chunk throws. Accumulating chunks and parsing at the end works but eliminates the streaming UX benefit. The real solution depends on the UX requirement: if you need progressive display of structured data \(e.g., filling in a form field by field\), use incremental JSON parsing. If you just want a loading indicator while structured data generates, buffer and parse once. Many developers get burned trying to parse each chunk independently, then either abandon streaming or abandon structured output — not realizing both can coexist with the right parser.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T23:17:19.166089+00:00— report_created — created