DoomLoopDetector watches a long-running agent session for stuck states — repeated actions, repeated failures, no progress, resource exhaustion, or repeated output — and recommends a RecoveryAction so the agent can break out instead of burning its whole iteration budget.
DoomLoopType, and maps that to a RecoveryAction on the recovery ladder.
This is the escalation doom-loop subsystem (session-level, recommends a
RecoveryAction). It is separate from the always-on per-agent Loop Detection that inspects tool-call fingerprints. Use this page for DoomLoopDetector / DoomLoopConfig.Quick Start
1
Construct with defaults
2
Record actions and progress markers
3
Check for a loop and get the recovery action
How It Works
The detector keeps an ordered history ofrecord_action(...) calls plus a separate list of mark_progress(...) markers. After each recorded action it re-runs every check; is_doom_loop() returns True as soon as any check fires, and get_loop_type() reports which one.
Loop types
Recovery ladder
get_recovery_action() walks a ladder based on how many recovery attempts have already been made:
Configuration Options
Pass aDoomLoopConfig to tune thresholds:
similarity_threshold (0.85) is retained for backward compatibility only and is not consulted by any current detector — fuzzy result-similarity is handled by the result-aware Loop Detection subsystem.How progress markers work
mark_progress() records a (marker, timestamp) tuple. When checking NO_PROGRESS, the detector only counts markers within the current no-progress window — markers older than the window boundary (the timestamp of the action immediately preceding the window) are filtered out.
mark_progress(...) disabled NO_PROGRESS detection for the rest of the run, no matter how long the agent then spun on unproductive work. Now NO_PROGRESS fires correctly on long runs where an early success previously suppressed it forever.
Common Patterns
Drive recovery from the detected action
Inspect session statistics
Best Practices
Call mark_progress() on real progress only
Call mark_progress() on real progress only
Mark progress when the agent genuinely advances (file modified, test passed, sub-goal reached) — not on every log line. Markers gate
NO_PROGRESS detection, so noisy markers hide real stalls.Keep max_no_progress_steps small
Keep max_no_progress_steps small
A smaller
max_no_progress_steps catches stalls sooner. Start at 3–5 for autonomous runs and raise it only if you see false positives.Increment recovery between attempts
Increment recovery between attempts
Call
increment_recovery() after acting on a recommendation so the ladder advances (RETRY_DIFFERENT → ESCALATE_MODEL → REQUEST_HELP) and eventually aborts at max_recovery_attempts.Reset per session
Reset per session
Call
start_session() at the top of each run to clear action history, markers, and recovery counters.Related
Loop Detection
The always-on, per-agent result-aware tool-loop detector
Autonomy Loop
doom_loop_threshold and the doom_loop completion reason
