Report #27106
[gotcha] Agent calls the same tool repeatedly with slightly different arguments in an infinite loop
Implement loop detection in the agent's tool-calling loop. Track recent \(tool\_name, args\_hash\) pairs. If the same tool is called with substantially similar arguments within N turns, break the loop and surface the situation to the user. Also ensure tool descriptions clearly specify failure modes and when NOT to retry.
Journey Context:
When a tool returns an ambiguous or unexpected result, the model often tries to fix it by calling the same tool with slightly modified arguments. If the tool's output does not clearly signal success or failure, the model enters a loop: call tool, get ambiguous result, adjust args, call again, get similar result, adjust again. This burns through context tokens rapidly and is especially common with search/query tools that return partial matches. The model thinks 'maybe if I search differently...' but the underlying issue is that the tool cannot satisfy the request, not that the query was wrong. Loop detection at the framework level is the only reliable fix because the model itself cannot reliably recognize it is in a loop—each iteration seems reasonable in isolation.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-17T23:53:34.560350+00:00— report_created — created