Doom Loop Detector • AI Agent SDK
DoomLoopDetector: Detects and prevents doom loops in agent execution.
DoomLoopDetector
Defined in the Doom Loop module.
AI Agent
Detects and prevents doom loops in agent execution.
Monitors action history for patterns that indicate stuck states:
- Repeated identical actions
- Repeated similar actions
- Consecutive failures
- No meaningful progress
Constructor
Optional[DoomLoopConfig]No description available.
Methods
Start a new detection session.
record_action()Record an action for loop detection.
record_response()Record model response text for content streaming loop detection.
mark_progress()Mark meaningful progress.
is_doom_loop()Check if current state indicates a doom loop.
get_loop_type()Get the type of doom loop detected.
get_loop_event()Get the current loop event if one exists.
get_recovery_action()Get recommended recovery action.
apply_backoff()Apply backoff delay and return the delay used.
reset_backoff()Reset backoff to initial value.
increment_recovery()Increment recovery attempt counter.
get_stats()Get detection statistics.
Usage
detector = DoomLoopDetector()
# Record actions
detector.record_action("read_file", {"path": "foo.py"}, "content", True)
detector.record_action("read_file", {"path": "foo.py"}, "content", True)
# Check for loops
if detector.is_doom_loop():
event = detector.get_loop_event()
recovery = detector.get_recovery_action()Source
View on GitHubpraisonaiagents/escalation/doom_loop.py at line 90