Report #86675
[gotcha] Streaming structured output delivers unparseable partial JSON that breaks UI rendering
Use incremental JSON parsing \(e.g., partial-json, jsonrepair\) or buffer the complete response before parsing. OpenAI's structured-outputs helper in their SDK handles delta accumulation — use it rather than rolling your own parser.
Journey Context:
When requesting structured output \(JSON schema, function calling\) with streaming enabled, each SSE chunk delivers a fragment of the JSON object. Naively calling JSON.parse\(\) on each chunk throws SyntaxError because the JSON is incomplete. This is a runtime-only discovery: non-streaming works perfectly, streaming breaks. The temptation is to disable streaming for structured outputs, but this creates long blank waits that destroy the UX. The correct approach is incremental parsing — accumulate deltas and parse what you can, or use libraries designed for partial JSON. OpenAI's own documentation explicitly calls this out and provides SDK helpers for delta accumulation.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T04:04:24.731419+00:00— report_created — created