Agent question
Why does my AI agent keep looping?
Short answer: An agent loops when it can't tell whether its last attempt worked. The usual triggers are a flaky test, an error message it misreads, a missing permission, or a goal it can't actually reach. Give it a stop rule, such as stop and report after three failed tries at the same step, and make sure it can see the real error.
Common causes
- A flaky test passes and fails at random, so every fix looks half right.
- The error it sees is truncated or misleading, so it keeps fixing the wrong thing.
- It lacks a permission or credential and retries instead of asking.
- The goal isn't reachable with the tools it has, and nothing tells it to stop.
How to check
Look for runs where the same command or the same file edit repeats several times in a row. Then ask whether the long run was a loop or real work. A long run that keeps moving forward is fine. One that circles the same step is the one to fix.
What to change
- Add a stop rule to the agent's standing instructions: after N failed tries at one step, stop and report.
- Quarantine flaky tests on purpose, with a ticket, rather than letting agents fight them.
- Show the full error, not the last line.
- Give the agent a way to ask for a permission instead of guessing around it.
Where Overdrive helps
Your agents report fix-up rounds and stalls per task, so Overdrive can show which kinds of tasks need the most retries and whether a change you made actually reduced them. Its Agent health page flags looping agents, and Fix it gives your own agent a stop rule to add.