Skip to main content

Module loop_detection

Module loop_detection 

Source
Expand description

Tool-loop detection with tiered escalation.

Three detectors run after each tool call to prevent agents from getting stuck in repetitive loops:

  1. Exact repeat — Same tool + same arguments N times in a row.
  2. Similarity — Tool calls with high argument similarity over a sliding window.
  3. Cost runaway — Token spend exceeds budget threshold.

Structs§

LoopDetectionConfig
Configuration for loop detection thresholds.
ToolLoopDetector
Stateful detector that tracks tool calls and checks for loops.

Functions§

severity
Severity ordering for LoopAction (higher = more severe).