Your ReAct agent calls the same search with the same query five times in a row and never finishes.
- AAdd “do not repeat yourself” to the system prompt in capital letters
- BDetect the repeated call in code and stop
- CSwitch to a larger model, which is less likely to get stuck in loops
- DRaise the step limit so the agent has room to reach the answer
Answer: B
Detect the repeated call in code and stop
Why
Nothing in the loop tells the model its last attempt was identical, so it keeps guessing the same way. A check in code - same tool, same arguments as a recent step - ends the loop or forces a different move; a prompt line can be ignored, a bigger model still loops, and more steps only make it longer.
- Agent loopsYour agent is stuck in a loop - it keeps making the same tool call over and over.
- 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.
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