Report #38613
[gotcha] Streaming structured/JSON output renders broken intermediate UI states
Buffer streamed tokens and only parse/render structured output once the stream completes. If you must show progress, display a generic 'generating…' indicator rather than attempting to parse partial JSON. Never pass incremental chunks through JSON.parse.
Journey Context:
Developers naturally extend their streaming-text pattern to structured outputs. But partial JSON is syntactically invalid — a missing closing brace or truncated array element crashes any JSON parser. OpenAI's structured-outputs API streams tokens identically to text completions, yet no intermediate chunk is ever valid JSON. The temptation is incremental JSON parsing \(partial parsers, regex extraction\), but this breaks on edge cases like escaped characters split across chunks or nested objects. The right call: accept that structured output and incremental rendering are fundamentally at odds. Stream the tokens for perceived speed, but parse and render the structure only on completion.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T19:17:20.251979+00:00— report_created — created