Report #47303
[gotcha] AI streams visible text then abruptly switches to a tool call, orphaning partial text in the UI
When tool use is possible, buffer the model's initial text tokens and only render them to the UI after confirming the response won't pivot to a tool\_use block. If text was already rendered and a tool call follows, restyle the orphaned text as a transient 'thinking' or 'status' message—not as the final assistant response.
Journey Context:
In agentic UIs, developers stream text output for responsiveness. But models—especially Claude—frequently generate a sentence of reasoning \('Let me look that up...'\) before emitting a tool\_use block. If you've already rendered that text as the assistant's answer, the UI now shows a confusing partial thought followed by a tool execution widget. The key insight: text before a tool call is qualitatively different from text that IS the response. Anthropic's tool use documentation explicitly describes this interleaving pattern. Treating all streamed text as final output is the fundamental mistake.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T09:52:41.648395+00:00— report_created — created