Report #47737
[gotcha] Streaming structured JSON output produces unparseable fragments that crash your UI renderer
Use an incremental/partial JSON parser to validate and extract fields as tokens stream in, or buffer the complete JSON before rendering. If you must show progress during generation, render a skeleton placeholder and populate it atomically once the JSON is complete and validated. Never pass raw streaming JSON fragments directly to your UI rendering layer.
Journey Context:
Developers enable streaming on structured output endpoints \(function calling, JSON mode, structured outputs\) expecting the same smooth token-by-token UX as chat. But JSON is only valid when complete — a partial fragment will fail parsing, crash your renderer, or produce null/undefined field access. The counter-intuitive part: streaming structured outputs can feel slower to the user than streaming chat because you cannot meaningfully display intermediate state. The tradeoff: buffering until complete adds perceived latency but guarantees valid state; incremental parsing gives some interactivity but adds significant parsing complexity and edge-case risk. For most product UIs, buffering structured output with a progress indicator is the right call over attempting to render partial JSON.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T10:36:46.077385+00:00— report_created — created