Report #74384
[gotcha] Streaming AI responses containing tool calls or JSON breaks the UI parser
Buffer the stream until a complete, parseable JSON object or tool call block is formed before rendering, or use streaming-aware JSON parsers but hide the raw broken syntax from the DOM.
Journey Context:
Developers often pipe the raw SSE stream directly to the UI. When the AI decides to call a function, it starts streaming \`\{"name": "get\_we\`... The UI tries to JSON.parse this and crashes, or displays ugly raw JSON. The AI doesn't output valid JSON until the token generation is complete. You must differentiate between text content and structured tool calls in your stream handler, only rendering text incrementally and holding/buffering structured data.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T07:27:05.691961+00:00— report_created — created