What Are Client Actions?
Client actions allow your AI agent to request that your application perform an action on the client side. When an agent determines it needs external information or wants to trigger an operation, it responds with afinishReason of "tool-calls" and includes tool-call parts describing what it needs.
Your application executes the action, submits the result back to the API, and then continues the conversation.
Client actions correspond to the Custom Actions configured on your agent in the Chatbase dashboard. The
toolName in the API response is the name of the configured action.Flow
Receive a client action request
The response has
finishReason: "tool-calls" and tool-call parts containing toolCallId, toolName, and input.Execute the action client-side
Use
toolName and input to determine what to do and execute the action in your application.Submit the result
Send the result to
POST /agents/{agentId}/conversations/{conversationId}/tool-result with the toolCallId and output.Message Parts
Responses can include three types of parts in theparts array:
text
Text content generated by the agent.Fields:
type, texttool-call
A client action the agent wants your app to execute.Fields:
type, toolCallId, toolName, inputtool-result
The result of a previously executed client action (visible in conversation history).Fields:
type, toolCallId, toolName, outputDetecting a Client Action
Check thefinishReason in the response metadata. When it is "tool-calls", the parts array will contain one or more tool-call entries:
Submitting the Result
After executing the action, submit the result using the tool-result endpoint:Request Body
The
toolCallId from the tool-call part in the chat response.The result of executing the action.
Response
Continuing the Conversation
After submitting the tool result, continue the conversation by calling the chat endpoint again. You can either:- Omit
messageto let the agent continue based on the tool result alone. - Include a
messageto provide additional context or a follow-up question.
conversationId to continue the same conversation.
Streaming Client Actions
When streaming is enabled, client action input arrives incrementally through these events:
The stream’s
message-metadata event will have finishReason: "tool-calls". See Streaming for full event type reference.
Code Examples
Error Handling
| Code | Status | Description |
|---|---|---|
RESOURCE_TOOL_CALL_NOT_FOUND | 404 | No pending client action matches the provided toolCallId. It may have expired or already been resolved. |
VALIDATION_INVALID_BODY | 400 | The request body failed schema validation. Check the details field for specifics. |