Report #36819
[gotcha] Streaming structured output produces unparseable partial JSON fragments that crash client-side parsers
Use an incremental JSON parser \(e.g., partial-json, json-stream, or Vercel AI SDK streamObject\) that handles incomplete JSON, or buffer the complete response before parsing. Never pass raw streamed chunks directly to JSON.parse\(\).
Journey Context:
When using structured output \(JSON mode, function/tool calling\) with streaming enabled, each SSE chunk contains a fragment of the JSON object. The natural instinct is to parse each chunk to update UI progressively, but partial JSON is syntactically invalid and throws. Disabling streaming entirely sacrifices the UX benefit of progressive rendering. The correct approach is incremental parsing that accumulates state across chunks, enabling progressive UI updates \(e.g., a growing list\) while gracefully handling incomplete tokens at chunk boundaries.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T16:16:35.350665+00:00— report_created — created