Skip to main content
When using tool calls (tool_calls), the model may issue multiple consecutive tool calls based on the context. If you find that the model repeatedly calls the same tool, each call uses exactly the same function.name and function.arguments, and the tool result does not provide new useful information, you can treat it as a repeated tool call.

Check the Message Layout

When handling this issue, we recommend checking the message layout first:
  1. When the Kimi API returns finish_reason=tool_calls, make sure the returned choice.message has been added to the messages list as is.
  2. Make sure each tool_call has a corresponding message with role=tool.
  3. Make sure the tool_call_id in the role=tool message exactly matches the corresponding tool_call.id.
  4. If you use streaming output with stream=True, make sure the streamed tool_calls chunks have been assembled correctly, especially the function.arguments field.

Client-Side Repeated-Call Detection

If the message layout is correct but the model still repeatedly calls the same tool with the same arguments, you can add repeated-call detection on the client side and append a reminder to the system prompt in the next request. When the same tool and the same arguments are repeated 3 consecutive times, you can append:
When the repeated call reaches 5 consecutive times, you can append a stronger reminder that includes the tool name, repeat count, and arguments:
If the same tool and the same arguments are repeated 8 consecutive times, we recommend appending the stronger reminder again. Note: <system-reminder> is only an example prompt, not a special field of the Kimi API. You can merge it into the next role=system message, or write it into the system prompt based on your own message management logic. To avoid false positives, we recommend triggering this reminder only when the same tool, the same arguments, consecutive repetition, and no new progress from the tool result are all true.