Skip to main content

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 a finishReason 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

1

Send a chat message

Send a message to the chat endpoint as usual.
2

Receive a client action request

The response has finishReason: "tool-calls" and tool-call parts containing toolCallId, toolName, and input.
3

Execute the action client-side

Use toolName and input to determine what to do and execute the action in your application.
4

Submit the result

Send the result to POST /agents/{agentId}/conversations/{conversationId}/tool-result with the toolCallId and output.
5

Continue the conversation

Call the chat endpoint again with the conversationId. You can omit message to let the agent continue based on the tool result alone, or include a new message.

Message Parts

Responses can include three types of parts in the parts array:

text

Text content generated by the agent.Fields: type, text

tool-call

A client action the agent wants your app to execute.Fields: type, toolCallId, toolName, input

tool-result

The result of a previously executed client action (visible in conversation history).Fields: type, toolCallId, toolName, output

Detecting a Client Action

Check the finishReason 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

string
required
The toolCallId from the tool-call part in the chat response.
any
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 message to let the agent continue based on the tool result alone.
  • Include a message to provide additional context or a follow-up question.
You must include the conversationId to continue the same conversation.

Streaming Client Actions

When streaming is enabled, client action input arrives incrementally through these events:
1

tool-input-start

Signals the start of a client action. Includes toolCallId and toolName.
2

tool-input-delta

Incremental chunks of the action input stream in.
3

tool-input-available

The complete input is ready. You can read the full input object directly from this event without concatenating the preceding deltas.
The stream’s message-metadata event will have finishReason: "tool-calls". See Streaming for full event type reference.

Code Examples

Error Handling