Report #77093
[gotcha] Streaming structured output \(JSON, function calls\) delivers invalid partial JSON that crashes downstream parsers
Buffer all streamed chunks and parse only after receiving the final \[DONE\] event or finish\_reason='stop'. For real-time needs, use an incremental/streaming JSON parser like partial-json that tolerates incomplete JSON. Never pass raw SSE chunk deltas through JSON.parse\(\).
Journey Context:
Streaming works seamlessly for text — each chunk is a valid string fragment. Developers naturally extend the same streaming pattern to structured output, but each SSE chunk contains a JSON fragment that is syntactically invalid in isolation: missing closing braces, truncated string values, incomplete arrays. This silently breaks in production because testing often uses short outputs that fit in a single chunk, masking the fragmentation. The bug only surfaces with longer responses that span multiple chunks, making it particularly insidious.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T11:59:34.570035+00:00— report_created — created