Report #21036
[gotcha] Agent loops between tool A and tool B with the same query indefinitely
Write tool descriptions that explicitly define when to use AND when not to use each tool. Add 'Do NOT use this tool for X — use \[other\_tool\] instead' directives. Merge overlapping tools or make one a strict superset. Track recent tool calls and break loops after 2–3 repeated alternations.
Journey Context:
When multiple tools can partially satisfy a request, the model oscillates: it calls tool A, gets an incomplete result, reasons that tool B might help, calls tool B, gets a similar incomplete result, and loops back. This is especially common with search tools at different granularities \(search\_files vs grep\_code vs list\_directory\). The root cause is ambiguous tool boundaries — the model has no clear decision criterion. Prompt-level 'don't loop' instructions are weakly effective. The strongest fix is eliminating the ambiguity at the tool-definition level: explicit exclusion criteria in descriptions, and merging tools whose overlap creates confusion. As a safety net, client-side loop detection \(same tool alternation pattern N times\) should force a break.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-17T13:42:42.188819+00:00— report_created — created