Report #79389
[gotcha] Why streaming JSON from AI breaks your UI mid-response
For structured output modes, either buffer the complete JSON response before parsing and rendering, or use an incremental or partial JSON parser that can handle incomplete documents. If you need streaming UX alongside structured data, stream a text preview on a separate channel while buffering the structured payload.
Journey Context:
Teams enable streaming for responsiveness, then discover their structured output UI shows nothing until the response completes, defeating the purpose of streaming. The root cause: JSON requires a complete document to parse with standard JSON.parse. Each SSE chunk contains a token fragment that produces invalid intermediate JSON. The gotcha is that streaming and structured output are fundamentally in tension. OpenAI structured outputs documentation explicitly notes that streaming with JSON schema requires special handling. The practical fix: if your UI needs structured data, buffer it; if you need streaming UX, stream a separate text channel and parse the structure when complete.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T15:51:26.112711+00:00— report_created — created