You build a shiny new agent. It works great in the demo. Then you deploy it, and the next morning you wake up to find it called the same search function 47 times in a row before finally giving up. Sound familiar?
I hit this exact problem last week on a client project. The agent was supposed to research a topic, summarize findings, and write a report. Instead, it kept fetching the same URL, getting the same content, "reflecting" on whether it had enough information, deciding no, and fetching it again. Beautiful infinite loop. Expensive infinite loop.
This is one of those problems that doesn't show up in tutorials. Every "build an agent in 50 lines" post conveniently skips it. So let's actually dig into why it happens and how to fix it.
Why Agents Loop
There are three main reasons your agent gets stuck repeating itself.











