Skip to main content
Agents can get stuck in infinite loops, repeating the same actions without making progress. Loop detection catches these patterns and breaks out.

Types of Loops

Basic Usage

With Workflow

Loop Detector API

For more control, use the LoopDetector directly:

Handling Loop Errors

Loop Breaking Strategies

Detecting Subtle Loops

Sometimes loops aren’t exact repeats:

Best Practices

Agents running without human oversight will get stuck. It’s a matter of when, not if.
Too low = false positives. Too high = loops run too long. 3 repeated outputs is a good default.
If loops are common, your prompts might need work.
Repeated outputs alone isn’t enough. An agent might output different text but make no progress.