---
name: kimaai_chatbot_max_tool_rounds
type: filter
since: 1.5.4
tier: free
feature: none
area: tools-addons
summary: Changes how many rounds of tool calls one answer may take, 6 by default.
parameters:
  - name: max_rounds
    type: int
    description: The number of rounds, 6 by default.
  - name: payload
    type: array
    description: The payload sent to the provider, with the tools the request offers.
returns:
  type: int
  description: The number of rounds.
surfaces: [chatbot, admin_assistant, search]
---

# kimaai_chatbot_max_tool_rounds

## When it fires

Once for each answer in the chatbot, the admin assistant and the search answer: for a streamed answer before its first request, for one that does not stream when the model's first reply has arrived and the request offers tools. In a round the model calls one or more tools, KimaAI runs them and sends the results back. Each round is a request to the AI provider, which costs tokens, so a higher number lets chained tools finish at a higher price per answer.

An answer runs up to this many rounds after the model's first reply, streamed or not. When the model still calls tools after the last round, those calls do not run: the model gets a note that the budget is spent and answers with what it has, without tools, so the visitor always gets an answer. 0 runs no tool at all.

Before this release the streamed answers, the chatbot's default, did not ask the filter: they made at most 6 requests, and tools the model called in the last reply ran without their results reaching the model, so no answer followed.

## Example

```php
add_filter(
  'kimaai_chatbot_max_tool_rounds',
  function (int $max_rounds): int {
    return 10;
  }
);
```

Ten rounds, for a site whose own tools are called one after another: an order lookup, then its parcel, then the parcel's delivery date.

## Related

- `kimaai_chatbot_tool_call`: runs each tool of a round.
- `kimaai_chatbot_tools_registry`: the tools an answer offers.
