Report #78448
[gotcha] Model starts streaming text then pivots to a tool call, leaving orphaned partial text in the UI
When using function/tool calling with streaming, buffer the initial text content until you confirm whether the response is a pure text completion or includes a tool call. If a tool call arrives after partial text, either: discard the partial text and show a tool execution indicator, or render the partial text as 'thinking' that transitions to tool execution. Never show partial text as a final response then remove it.
Journey Context:
The model begins streaming what looks like a normal text response — 'Let me look up...' — then mid-stream emits a tool\_call. The text was never the answer; it was the model's reasoning about calling a tool. But the streaming UI already rendered it. Now you must either remove it \(feels broken — content disappeared\) or leave it \(confusing — why is there text and a tool result?\). The gotcha: the API can return both content and tool\_calls in the same response, and with streaming, content tokens arrive before the tool\_call directive is known. The naive approach — render everything as it streams — creates the orphaned text problem. The fix requires understanding that streaming with tool use needs a fundamentally different rendering strategy than streaming pure text: you must hold back rendering until you know the response type.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T14:16:03.978804+00:00— report_created — created