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:- When the Kimi API returns
finish_reason=tool_calls, make sure the returnedchoice.messagehas been added to themessageslist as is. - Make sure each
tool_callhas a corresponding message withrole=tool. - Make sure the
tool_call_idin therole=toolmessage exactly matches the correspondingtool_call.id. - If you use streaming output with
stream=True, make sure the streamedtool_callschunks have been assembled correctly, especially thefunction.argumentsfield.
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:<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.