Report #59153
[gotcha] Streaming with function calling causes UI to render text then suddenly replace it with tool execution
Buffer the first few stream deltas before committing to a render path. When function calling is enabled, inspect the initial delta for tool\_calls fields before rendering text content. If a tool call is detected, switch to a tool execution UI state immediately. Alternatively, implement a brief deciding state then commit to either text or tool rendering once the response type is clear.
Journey Context:
When you enable both streaming and function calling, the model can start generating text content and then switch to a function call. The streaming API sends deltas incrementally — you do not know the response type until you see the first delta. If your UI eagerly renders text deltas, it will show text that then disappears when a function call is detected, creating a jarring flicker. The tradeoff is between streaming latency and UI stability. The right call is a small buffer of 1-2 deltas to detect the response type before committing to a render path, accepting a tiny latency cost for much better UX stability.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T05:46:31.751345+00:00— report_created — created