pub struct ToolCallLoopGuard { /* private fields */ }Expand description
Detects consecutive identical assistant tool calls across model turns.
Implementations§
Source§impl ToolCallLoopGuard
impl ToolCallLoopGuard
Sourcepub fn new(options: ToolCallLoopGuardOptions) -> Self
pub fn new(options: ToolCallLoopGuardOptions) -> Self
Construct from options. threshold is clamped to ≥ 1.
Sourcepub fn with_threshold(self, threshold: usize) -> Self
pub fn with_threshold(self, threshold: usize) -> Self
Override the threshold at runtime.
Sourcepub fn with_exempt_tool(self, tool: impl Into<String>) -> Self
pub fn with_exempt_tool(self, tool: impl Into<String>) -> Self
Mark a tool as exempt from detection.
Sourcepub fn record_turn(
&mut self,
turn: ToolCallLoopTurn<'_>,
) -> Option<RepeatedToolCallDetection>
pub fn record_turn( &mut self, turn: ToolCallLoopTurn<'_>, ) -> Option<RepeatedToolCallDetection>
Records one completed turn and returns the threshold hit, if any.
A “completed turn” is one assistant message that contained tool calls and for which the corresponding tool results have been emitted. Turns with multiple distinct tool calls reset detection.
Trait Implementations§
Source§impl Debug for ToolCallLoopGuard
impl Debug for ToolCallLoopGuard
Auto Trait Implementations§
impl Freeze for ToolCallLoopGuard
impl RefUnwindSafe for ToolCallLoopGuard
impl Send for ToolCallLoopGuard
impl Sync for ToolCallLoopGuard
impl Unpin for ToolCallLoopGuard
impl UnsafeUnpin for ToolCallLoopGuard
impl UnwindSafe for ToolCallLoopGuard
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