Your agent is stuck in a loop - it keeps making the same tool call over and over.
- ARaise the max-iterations limit
- BAdd an explicit exit-condition check to the loop
- CAdd a longer delay between iterations so the model has time to reconsider its next call
- DSwitch to a bigger model
Answer: B
Add an explicit exit-condition check to the loop
Why
A loop needs a clear termination check. Without an exit condition the agent never decides it is done - a bigger model or a higher limit just loops longer.
- Agent loopsYour agent keeps taking near-identical steps - each tool call “succeeds”, but nothing moves toward the goal.
- Agent loopsYou cap the agent at 10 iterations to stop runaways.
- Agent loopsThe same step fails the same way on every pass of the loop.
- Agent loopsThe agent alternates between two fixes forever: each one undoes the other, and both look reasonable in isolation.
More on Way of the Agent
- Course programThe first three modules are free: start in the browser or the app, no card needed.
- Library: guides, skills and promptsReady prompt templates, grouped into collections.
- AI ChroniclesSourced stories from the history of AI.
- ConceptsPlain-language explainers of agent engineering.
- Learn AI agentsApps and courses for learning AI agents, compared honestly.
Real situations from building agents - with the answer and why.
Solve a new one every day on the Path