Overview
Tools inAIChatAgent can be divided into two categories:
- Server tools: Have an
executefunction on the server. The AI SDK runs them automatically and the LLM continues responding in the same turn. - Client tools: No
executefunction on the server. The tool call is sent to the client viaonToolCall, and the client provides the result. By default, this requires a new request to continue.
autoContinueAfterToolResult, client tools can behave like server tools — the LLM calls a tool, the client executes it, and the server automatically continues the conversation in the same turn.
Server Setup
Define a tool without anexecute function. The AI SDK will pause and send tool-input-available to the client:
Client Setup
UseonToolCall to handle client-side tool execution. Auto-continuation is enabled by default (autoContinueAfterToolResult: true), so the server automatically calls onChatMessage() again after receiving the tool result, letting the LLM continue in the same assistant message.
How It Works
1
User sends message
User: “What’s the weather near me?”Client sends message → Server calls LLM
2
LLM requests client tool
LLM decides to call getUserLocation (no server execute)Stream sends tool-input-available to client
3
Client executes tool
onToolCall fires → client gets geolocation → sends CF_AGENT_TOOL_RESULT4
Server receives result
Server receives result with
autoContinue: trueServer waits for the original stream to complete5
Automatic continuation
Server calls
onChatMessage() again (continuation)LLM sees the location result, calls getWeather (server execute)6
Final response
LLM responds: “It’s sunny and 72°F near you!”Continuation parts are merged into the same assistant message
The user sees a single seamless response, even though it involved a client-side tool call mid-stream.
Without Auto-Continuation
WhenautoContinueAfterToolResult is set to false, the client must explicitly send a follow-up message after providing the tool result:
Use this when you want explicit control over when the conversation continues, or when tool results need user review before proceeding.
Combining with needsApproval
You can use client-side tools and approval together. For example, a tool that needs both user approval and browser execution:Custom Denial Messages
If the user denies the tool, you can provide a custom error message usingaddToolOutput with state: "output-error":
Related Documentation
- Chat Agents — Full
AIChatAgentanduseAgentChatreference - Human in the Loop — Approval patterns including
needsApproval