What Are Client-Side Tools?
Client-side tools let your agent invoke functions that run locally on the Android device. Register a handler, and the SDK takes care of the rest — when the agent calls the tool, your handler runs and the result is fed back into the conversation automatically.Client-side tools correspond to Custom Actions configured on your agent in the Chatbase Dashboard. The
toolName in the SDK matches the name of the configured action.tool
interface ChatbaseClient — Package: com.chatbase.sdk
String
required
The tool name. Must match a Custom Action configured on your agent.
suspend (Map<String, Any?>) -> Any
required
A suspend function that receives the parsed input and returns a result.
get_weather during a conversation. The SDK executes your handler and feeds the result back automatically. This loop can repeat up to 10 times per sendMessage call — if the agent requests more, sendMessage throws a ChatbaseException (“Tool loop exceeded maximum iterations”).
removeTool
String
required
The tool name to remove.
Tracking Execution
Use theonToolCall and onToolResult callbacks to observe tool execution:
ToolCallInfo
data class ToolCallInfo — Package: com.chatbase.sdk
Passed to the onToolCall callback before handler execution.
Map<String, Any?> for easy access.
ToolResultInfo
data class ToolResultInfo — Package: com.chatbase.sdk
Passed to the onToolResult callback after handler execution.
Interactive Tools
Since handlers aresuspend functions, they can block on user interaction. For example, showing a color picker and waiting for the user’s choice:
Related
Streaming
Streaming callbacks and Kotlin Flow
Error Handling
Handle errors during tool execution
