Report #46577
[gotcha] Streaming structured output \(JSON, function call arguments\) produces syntactically invalid fragments that break progressive UI rendering
Use incremental JSON parsers \(e.g., partial-json, json-stream\) or buffer the complete response before rendering structured content. For OpenAI function calls, accumulate the function.arguments delta across chunks and parse only when the tool\_calls chunk indicates completion.
Journey Context:
Developers enable streaming for responsiveness, then discover that JSON responses are syntactically invalid until the stream completes. Standard JSON.parse\(\) throws on fragments. This is especially painful for function calling where the entire argument object must be valid before execution. The tradeoff: buffering kills the responsiveness benefit of streaming, while incremental parsing adds complexity. For function calls, the right call is usually to buffer arguments until complete; for display-only structured content like tables, incremental parsing preserves the streaming UX while avoiding broken renders.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T08:39:13.996467+00:00— report_created — created