What are tool calls?
Tool calls occur when an AI model decides to invoke a specific function or tool to accomplish a task. Rather than only returning text, the model can request to execute tools you’ve defined, such as fetching weather data, searching a database, or performing calculations. A tool call consists of:- Tool name: The identifier of the tool being invoked
- Tool input: Parameters passed to the tool, often structured as JSON
- Tool output: The result returned after execution
- Trust and transparency: Users see what actions the AI is taking, building confidence in the agent
- Human-in-the-loop workflows: Expose tool calls resolved by humans where users can review and approve tool execution before it happens
- Generative UI: Build dynamic, contextual UI components based on the structured tool data
Publish tool calls
Publish tool call and model output messages to the channel. In the example below, theresponseId is included in the message extras to allow subscribers to correlate all messages belonging to the same response. The message name allows the client to distinguish between the different message types:
Subscribe to tool calls
Subscribe to tool call and model output messages on the channel. In the example below, theresponseId from the message extras is used to group tool calls and model output messages belonging to the same response. The message name allows the client to distinguish between the different message types:
Generative UI
Tool calls provide structured data that can form the basis of generative UI - dynamically creating UI components based on the tool being invoked, its parameters, and the results returned. Rather than just displaying raw tool call information, you can render rich, contextual components that provide a better user experience. For example, when a weather tool is invoked, instead of showing raw JSON like{ location: 'San Francisco', temp: 72, conditions: 'sunny' }, you can render a weather card component with icons, formatted temperature, and visual indicators:
Client-side tools
Some tools need to be executed directly on the client device rather than on the server, allowing agents to dynamically access information available on the end user’s device as needed. These include tools that access device capabilities such as GPS location, camera, SMS, local files, or other native functionality. Client-side tool calls follow a request-response pattern over Ably channels:- The agent publishes a tool call request to the channel.
- The client receives and executes the tool using device APIs.
- The client publishes the result back to the channel.
- The agent receives the result and continues processing.
toolCallId enables correlation between tool call requests and results:
The agent subscribes to tool results to continue processing. The toolCallId correlates the result back to the original request:
Progress updates
Some tool calls take significant time to complete, such as processing large files, performing complex calculations, or executing multi-step operations. For long-running tools, streaming progress updates to users provides visibility into execution status and improves the user experience by showing that work is actively happening. You can deliver progress updates using two approaches:- Messages: Best for discrete status updates and milestone events
- LiveObjects: Best for continuous numeric progress and shared state synchronization
Progress updates via messages
Publish progress messages to the channel as the tool executes, using thetoolCallId to correlate progress updates with the specific tool call:
Subscribe to progress updates on the client by listening for the tool_progress message type:
Message-based progress is useful for:
- Step-by-step status descriptions
- Milestone notifications
- Workflow stages with distinct phases
- Audit trails requiring discrete event records
Progress updates via LiveObjects
Use LiveObjects for state-based progress tracking. LiveObjects provides a shared data layer where progress state is automatically synchronized across all subscribed clients, making it ideal for continuous progress tracking. Use LiveCounter for numeric progress values like completion percentages or item counts. Use LiveMap to track complex progress state with multiple fields. First, import and initialize the LiveObjects plugin: Create a LiveMap to track tool progress: Subscribe to LiveObjects updates on the client to render realtime progress: LiveObjects-based progress is useful for:- Continuous progress bars with frequent updates
- Distributed tool execution across multiple workers
- Complex progress state with multiple fields
- Scenarios where multiple agents or processes contribute to the same progress counter
Choosing the right approach
Choose messages when:- Progress updates are infrequent (every few seconds or at specific milestones)
- You need a complete audit trail of all progress events
- Progress information is descriptive text rather than numeric
- Each update represents a distinct event or stage transition
- Progress updates are frequent (multiple times per second)
- You’re tracking numeric progress like percentages or counts
- Multiple processes or workers contribute to the same progress counter
- You want to minimize message overhead for high-frequency updates
