Report #9211
[gotcha] Agent enters infinite reasoning loop because tool output triggers the same tool again
Include a depth or iteration counter in the agent's system prompt, and design tool outputs to explicitly state 'No further action required' when terminal states are reached, breaking the loop.
Journey Context:
When an LLM calls a tool, it processes the result and decides the next action. If a tool returns an error like 'Resource not found', the LLM might reason 'I should try another query' and call the same tool with slightly different parameters, looping indefinitely until context overflow. This happens because LLMs lack intrinsic state memory across turns. Injecting a visible counter or explicit termination signals into the tool output forces the LLM to recognize it is repeating itself and break the cycle.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T07:38:52.128102+00:00— report_created — created