Overview
Agents can get stuck in loops when they lack proper termination conditions, encounter edge cases in their reasoning, or when tools fail in ways the agent cannot handle.
Common Causes
Reasoning Loops
- Agent keeps reconsidering the same options
- Uncertainty leads to repeated analysis
- Conflicting sub-goals create oscillation
Tool Interaction Loops
- Tool returns same error repeatedly
- Agent retries without adjusting approach
- Missing error handling logic
State Management Issues
- Agent doesn't track what it has tried
- Memory limitations cause repeated attempts
- Lack of progress detection
Prevention Strategies
- Set iteration limits - Hard caps on action counts
- Track action history - Detect repetitive patterns
- Implement circuit breakers - Automatic intervention triggers
- Progress monitoring - Require measurable advancement