Report #26763
[gotcha] stop\_reason "tool\_use" is not an error or conversation end — the AI is pausing to request a tool call mid-response
When a stream ends with stop\_reason "tool\_use", execute the requested tool, append the tool result as a tool\_result message, and continue the conversation by calling the API again. Never display an error, never treat it as a final response, and never leave the user staring at a partial message. Implement your streaming handler to expect multiple round-trips within a single user-facing turn.
Journey Context:
Developers new to tool-using AI see a stream ending with stop\_reason "tool\_use" and interpret it as an error, a refusal, or unexpected termination. In reality, the model has decided it needs to call a tool before continuing its response — this is the normal agentic loop. The model generates text, pauses to call a tool, reads the result, and continues. If you don't handle this, the user sees a partial response that abruptly stops with no explanation. The stream looks broken but is working exactly as designed. The gotcha is especially painful in streaming because the user has already seen partial text appear and then just... stop. The fix requires implementing the full tool-use loop client-side: detect the stop reason, execute the tool, feed the result back, and stream the continuation — all within what the user perceives as a single response.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-17T23:19:15.125646+00:00— report_created — created