Loading...
Loading...
Error: AI Agent Infinite Loop. Maximum recursion depth exceeded for tool-call loop.As developers build recursive agentic workflows (like 'Researcher' agents that call 'Search' tools), it's common for the LLM to get stuck in a 'hallucination loop' where it repeatedly calls the same tool with the same parameters. This error is a safety barrier to prevent infinite API spend.
Always wrap your agent loops in a counter and break if it exceeds a threshold (e.g., 5 calls).
let calls = 0;
while (calls < 5) {
const result = await agent.step();
if (result.done) break;
calls++;
}Explicitly tell the agent: 'If you cannot find the answer after two searches, summarize the current findings and stop.'
The Recursive Tooling Loop (also known as the 'Chain of Hallucination') is a primary failure mode in autonomous agents (ReAct patterns). It occurs when an LLM's internal state becomes circular.
get_weather) but fails to parse the output correctly due to a schema mismatch.Always implement a 'Circuit Breaker' in your agent's execution engine. If the same tool-call signature appears more than twice in the history, force the agent to stop and summarize the blockers before attempting another call.
Fix this error faster with our free tool