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.

Parameters

NameTypeDescription
max_roundsintThe number of rounds, 6 by default.
payloadarrayThe payload sent to the provider, with the tools the request offers.

Returns

int: The number of rounds.

Example

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.

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

What are your feelings