Overview
Client tools allow your AI persona to trigger events in your client application. When the LLM invokes a client tool, the Anam SDK emits an event that your application can listen for, enabling the persona to:- Navigate to specific pages or sections
- Open modals, dialogs, or overlays
- Update UI state based on conversation
- Trigger animations or visual effects
- Control media playback
- Submit forms or initiate actions
How Client Tools Work
1
User makes a request
User: “Show me the pricing page”
2
LLM decides to call tool
The LLM recognizes this requires a client-side action and generates a tool call:
3
SDK triggers handler
The Anam SDK triggers the registered handler for the tool, or emits a
TOOL_CALL_STARTED event.4
Your app handles the event
Your registered handler receives the tool call and executes the action:
5
LLM continues conversation
If
awaitResult is true, the return value from your handler is sent back to the LLM. The persona uses the result to continue naturally: “I’ve opened the pricing page for you!”If awaitResult is false, the tool call is fire-and-forget — the LLM continues without waiting for a result.The user experiences a seamless interaction between voice/chat and UI.
Creating Client Tools
Basic Client Tool Structure
A client tool requires four components:string
required
Must be
"client" for client-side toolsstring
required
Unique identifier for the tool (snake_case, 1-64 characters)
string
required
Describes when the LLM should use this tool (helps with decision-making)
object
JSON Schema defining the parameters the tool accepts
boolean
default:"false"
When
true, the return value from your onStart handler is sent back to the LLM as the tool result, allowing the persona to incorporate it into its response. When false (default), the tool call is fire-and-forget.number
How long the engine waits for the client to return a tool result before timing out. Only applies when
awaitResult is true. Range: 1–600 seconds. Default: 10 seconds.Example: Page Navigation
Example: Open Modal
Example: Update UI State
Handling Tool Events in Your Application
Using registerToolCallHandler (Recommended)
Register handlers for specific tools by name. This will automatically emit completed or failed events when the handler completes. For client tools with awaitResult set to true, the return value from onStart is sent back to the LLM as the tool result:
registerToolCallHandler returns a cancel function you can use for cleanup:
Using Event Listeners
You can also listen to tool call lifecycle events directly for logging, analytics, or handling tools generically:See the complete SDK Reference for all available events, type definitions, and methods.
Real-World Examples
E-commerce Shopping Assistant
Create a shopping assistant that can guide users through your product catalog:- User: “Show me wireless headphones under $100”
- AI: Calls
apply_filterwith category: “headphones”, maxPrice: 100 - User: “I like the Sony ones”
- AI: Calls
show_productwith productId: “sony-wh-1000xm4” - User: “Add them to my cart”
- AI: Calls
add_to_cart“Added to your cart! Ready to checkout?”
Customer Support Dashboard
Create a support agent that can navigate your dashboard:SaaS Application Navigator
Best Practices
Provide Clear Descriptions
The description helps the LLM decide when to use the tool:Use Enums for Constrained Values
When parameters have a limited set of valid values, use enums:Handle Errors Gracefully
Validate arguments in your handler. Errors thrown inonStart are automatically caught and routed to the onFail callback. If awaitResult is true, the error message is also sent back to the LLM so it can respond appropriately (e.g., “Sorry, I couldn’t find that product”):
Provide User Feedback
Give immediate feedback when tools execute:Test Tool Execution
Use the tool call events to debug tool execution in the browser console:Security Considerations
Validate All Parameters
Never trust client tool arguments without validation:Avoid Exposing Sensitive Data
Don’t include sensitive information in tool parameters:Rate Limit Tool Calls
Prevent abuse by tracking and limiting tool execution:Next Steps
Cookbook: Client-Side Tools
Build a multi-page app where the avatar navigates users with voice commands
Webhook Tools
Integrate external APIs with webhook tools
Knowledge Tools
Search documents with RAG-powered tools
SDK Reference
Complete SDK documentation for tool events

