Agent Loop Detection
Detect when agents get stuck in circular patterns — repeated tool calls, oscillating states, or LLM loops. Configurable circuit breakers can automatically halt runaway agents.
Python SDK
from prysmai.detectors import LoopDetector
detector = LoopDetector(
max_repetitions=3, # Alert after 3 repetitions of a pattern
window_size=20, # Look back 20 events for patterns
min_pattern_length=2, # Minimum sequence length to consider a loop
max_pattern_length=5, # Maximum sequence length to check
circuit_breaker_threshold=5, # Halt after 5 repetitions
)
session.attach_detector(detector)
Detection Types
| Type | Description |
|---|---|
| repeated_tool | Same tool called repeatedly with identical arguments |
| circular_sequence | A sequence of tool calls repeating in a cycle |
| llm_loop | LLM producing near-identical outputs repeatedly |
| state_oscillation | Agent state toggling between two values |
Circuit Breaker
When circuit_breaker_threshold is reached, the detector raises a CircuitBreakerTriggered detection with severity halt, signaling the governance session to stop the agent.
Dashboard
Navigate to Dashboard → Loop Detection to view:
- Total loops detected, circuit breaker triggers, and pattern analysis
- Detection log with pattern visualization and repetition counts