All courses

Recognising when the agent goes in circles

Spot the signs of a stuck agent: the same fix tried repeatedly, growing patches over patches, flipping between two approaches, or an apology without new evidence. Decide to stop, revert and reframe.

Builds on: Giving useful feedback on a wrong result, Interrupting and redirecting mid-task

Read it card by card Start the whole course

Busy, but getting nowhere?

You asked the agent to fix a failing test. Fifteen minutes later it has edited `src/dates.py` four times. The test still fails, and its latest reply begins: 'Apologies, you're right, this should now work.' It looks busy, so it must be close, right? How do you tell an agent that is making progress from one that is going in circles?

Why an agent loops

On each turn of its loop, the agent guesses a cause from what it has seen, edits, and runs. If the real cause sits somewhere it never looked, such as a data file, another module or a setting, every guess misses. Its earlier attempts stay in the conversation and pull it back toward the same ideas. More tries add no new information. An apology is just text, not evidence.

Four signs, and when to stop

1. **Same fix again**: it repeats an edit or command it already tried and gets the same error. 2. **Patches over patches**: each attempt adds a special case or workaround on top of the last one. 3. **Flip-flopping**: approach A, then B, then A again. 4. **Apology without evidence**: 'this should work now', with no new command run or file read. Progress means the error changes or new facts appear. If the error is unchanged after two attempts, stop.

Stop, undo, reframe

In the date case, the agent spent four attempts swapping `%d/%m/%Y` and `%m/%d/%Y` back and forth. It never opened `data/orders.csv`. Every run printed the same `ValueError: unconverted data remains: 10:30`. That is flip-flopping with an unchanged error, so it is stuck. 1. **Stop** it. 2. **Undo** its edits so `src/dates.py` is back as it was. Use your tool's undo/rewind or a checkpoint (a saved copy of your files from before the task). Every patch rests on a wrong guess. 3. **Reframe**: give it the evidence it never looked at, and ask for a diagnosis before any edit.

A reframe that breaks the loop

Name what failed, add the missing evidence, and ask for an explanation before any edit.
▸ You: Stop. Your last 4 attempts only
  swapped %d/%m/%Y and %m/%d/%Y. The
  error never changed:
    ValueError: unconverted data
    remains: 10:30
  A real input line from data/orders.csv:
    05/03/2024 10:30
  I've undone your edits to src/dates.py.
  Don't edit yet. Explain why parsing
  fails for this line, then propose
  one fix.

Busy is not progress

Watch for the same error after two attempts, fixes piling up, flipping back and forth, or an apology with no new evidence. When you see one, stop. Undo the attempts with your tool's undo or a checkpoint. Then restart with the missing evidence and ask for a diagnosis before any edit.

On Bytewise this lesson comes in small steps with a check at the end, and the app brings it back right before you would forget it.