Unit 07.00: Loops, and the two detectors that catch them
Loops are the most expensive agent failure and the easiest to detect.
A ceiling and a repeat counter
The ceiling bounds total steps. The repeat counter watches for the same tool with the same arguments.
The example below runs both over a five-step sequence.
1. lookup INV-1187
2. lookup INV-1187
3. lookup INV-1187 <- REPEAT DETECTOR: ('lookup', 'INV-1187') seen 3x
4. search contract
5. lookup INV-1187 <- REPEAT DETECTOR: ('lookup', 'INV-1187') seen 4x
repeat detector fired at step 3; the ceiling would not fire until 5
The repeat detector fires at step three; the ceiling would not fire until step five. On a tight loop that difference is two paid steps every time it happens.
The ceiling still earns its place for a different shape: an agent that keeps doing slightly different things without converging, never repeating an exact call. The repeat detector never fires on that one.
The mistake this prevents
The mistake is a ceiling alone because it is simpler to implement. A ceiling of eight lets a two-step loop run four times, which is eight paid calls to learn something detectable at the third.
Takeaway
Run both detectors. The repeat counter catches tight loops early; the ceiling catches drift that never repeats exactly.
