Report #76301
[gotcha] AI agent appears done after stream ends but actually needs to continue tool execution
Check finish\_reason \(OpenAI\) or stop\_reason \(Anthropic\) when a stream closes. If it equals 'tool\_calls' or 'tool\_use', execute the requested tools and feed results back — the task is not complete. Only 'stop' indicates a terminal response.
Journey Context:
In agentic loops, the model emits tool calls mid-conversation, then the stream closes. Naive implementations treat stream closure as task completion, showing the user a 'done' state or enabling the input field. But the AI is actually paused, waiting for tool results to continue. The user sees a partial response with no indication that work is ongoing. This is especially insidious because the response often ends mid-sentence or with a transitional phrase like 'Let me look that up...' — the AI clearly intended to continue. You must treat tool-calling stop reasons as a 'paused' state, execute tools silently or with a spinner, then resume the stream.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T10:39:52.931982+00:00— report_created — created