pub struct DoomLoopDetector { /* private fields */ }Expand description
Detects doom loops in agent tool call sequences.
Implementations§
Source§impl DoomLoopDetector
impl DoomLoopDetector
Sourcepub fn new(config: DoomLoopConfig) -> Self
pub fn new(config: DoomLoopConfig) -> Self
Creates a new detector with the given configuration.
Sourcepub fn record_and_check(
&mut self,
name: &str,
arguments: &Value,
) -> Option<DoomLoopType>
pub fn record_and_check( &mut self, name: &str, arguments: &Value, ) -> Option<DoomLoopType>
Records a tool call into the detection history and checks for doom loops against the current and past tool calls.
Two detection strategies are applied in order:
- Consecutive duplicates — the same tool with the same canonical
arguments called N times in a row (configured by
DoomLoopConfig::consecutive_threshold). - Cyclic patterns — a repeating sequence of tool calls of length
between
min_cycle_lengthandmax_cycle_lengththat repeats at leastcycle_repetitionstimes.
Returns Some(DoomLoopType) if a doom loop is detected, None otherwise.
Sourcepub fn history_len(&self) -> usize
pub fn history_len(&self) -> usize
Returns the current history length.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for DoomLoopDetector
impl RefUnwindSafe for DoomLoopDetector
impl Send for DoomLoopDetector
impl Sync for DoomLoopDetector
impl Unpin for DoomLoopDetector
impl UnsafeUnpin for DoomLoopDetector
impl UnwindSafe for DoomLoopDetector
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more