Quick Start
How It Works
Detectors
| Detector | What It Detects | Example |
|---|---|---|
generic_repeat | Same tool + identical args N times | read_file("config.py") called 10 times |
poll_no_progress | Same args AND same result (no progress) | check_status("job-1") returns identical “pending” 10 times |
ping_pong | Alternating A → B → A → B pattern | Two tools oscillating back and forth |
poll_no_progress uses heuristic tool name matching — tools with “status”, “poll”, “check”, “wait”, “ping”, or “health” in their name are classified as polling tools.Configuration Options
| Option | Type | Default | Description |
|---|---|---|---|
enabled | bool | False | Opt-in on LoopDetectionConfig; plugin sets True when imported |
history_size | int | 30 | Sliding window of recent tool calls |
warn_threshold | int | 10 | Identical calls before warning |
critical_threshold | int | 20 | Identical calls before blocking (auto-corrected to > warn) |
detectors | dict | all three True | Enable or disable individual detectors |
Common Patterns
Disable a Specific Detector
Aggressive Detection
Related to Loop Guard
Loop Detection is opt-in (import the plugin) and catches identical-argument / no-progress patterns. Loop Guard (docs) is always-on and counts per-turn tool calls with idempotent-vs-mutating thresholds. Use both for autonomous agents — Loop Guard as the safety net, Loop Detection for deeper pattern matching.Best Practices
Import the plugin for autonomous agents
Import the plugin for autonomous agents
Long-running agents with many tool calls benefit most from loop detection — add the import at process startup.
Adjust thresholds for polling tools
Adjust thresholds for polling tools
If your agent legitimately polls a status endpoint, increase thresholds or disable
poll_no_progress.Zero overhead when not imported
Zero overhead when not imported
The detector uses stdlib only (
hashlib, json). Without importing the plugin, no hook is registered.Do not confuse with autonomy doom loops
Do not confuse with autonomy doom loops
Autonomy mode has separate doom loop detection for repeated actions during self-directed runs.
Related
Loop Guard
Always-on per-turn tool-call guardrails
Autonomy Loop
Self-directed execution and doom loop thresholds

