pub struct LoopDetector { /* private fields */ }Expand description
Tracks consecutive identical tool calls.
Detection is simple: if the last N tool calls all have the same fingerprint (tool name + args), that’s a loop. On first detection, the caller injects a feedback message. On second detection (model ignored the feedback), the caller hard-stops.
Implementations§
Source§impl LoopDetector
impl LoopDetector
Sourcepub fn record(&mut self, tool_calls: &[ToolCall]) -> LoopAction
pub fn record(&mut self, tool_calls: &[ToolCall]) -> LoopAction
Record a batch of tool calls and check for loops.
Returns a LoopAction indicating what the caller should do.
Sourcepub fn clear_after_feedback(&mut self)
pub fn clear_after_feedback(&mut self)
Clear the detection state after feedback injection so the model
gets a fresh chance. Increments detection_count so the next
trigger will be a hard stop.
Sourcepub fn recent_names(&self) -> Vec<String>
pub fn recent_names(&self) -> Vec<String>
Recent tool names (most recent last), for display in the hard-cap prompt.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for LoopDetector
impl RefUnwindSafe for LoopDetector
impl Send for LoopDetector
impl Sync for LoopDetector
impl Unpin for LoopDetector
impl UnsafeUnpin for LoopDetector
impl UnwindSafe for LoopDetector
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more