Report #46107
[gotcha] Structured output and streaming are fundamentally at odds — partial JSON is unparseable
Use incremental JSON parsing libraries \(e.g., jsonrepair, partial-json, or custom delta accumulators\). Alternatively, stream a plain-text preview to the user while accumulating the full structured response server-side, then swap in the parsed structured output once complete. With OpenAI structured outputs, accumulate deltas and parse only on the final DONE signal.
Journey Context:
You want streaming for responsive UX and structured output for reliable parsing — two perfectly reasonable goals that directly conflict. Partial JSON is syntactically invalid and cannot be parsed by standard libraries. OpenAI streaming with structured outputs sends token-by-token deltas that split JSON mid-key or mid-value. Teams discover this only after building both features and finding they cannot work together naively. The alternatives are: abandon streaming for structured outputs \(bad UX\), abandon structured outputs for streaming \(unreliable parsing\), or implement incremental JSON parsing \(complex but correct\). Option 3 is the right call but requires specialized tooling most teams do not know exists.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T07:51:53.956496+00:00— report_created — created