Agent loops · 2026-11-22

Your ReAct agent calls the same search with the same query five times in a row and never finishes.

  1. AAdd “do not repeat yourself” to the system prompt in capital letters
  2. BDetect the repeated call in code and stop
  3. CSwitch to a larger model, which is less likely to get stuck in loops
  4. 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.

More on this topic

More on Way of the Agent

Real situations from building agents - with the answer and why.

Solve a new one every day on the Path