pub struct ConsecutiveFailureRecovery { /* private fields */ }Expand description
Recovery strategy that tracks consecutive failures per tool and stops after a limit.
This prevents runaway retry loops where the model keeps calling the same failing
tool (e.g., execute_ssh_command failing due to auth, but the model retries
indefinitely). After max_consecutive_failures for the same tool name, the
strategy switches from Retry to Stop with a summary message.
Failure counters are tracked per session and reset when a different tool succeeds or a new session starts.
Implementations§
Source§impl ConsecutiveFailureRecovery
impl ConsecutiveFailureRecovery
pub fn new(max_consecutive_failures: usize) -> ConsecutiveFailureRecovery
Sourcepub fn reset_failures(&self, session_id: &SessionId, tool_name: &str)
pub fn reset_failures(&self, session_id: &SessionId, tool_name: &str)
Reset failure count for a specific tool in a session. Call this when a tool succeeds to avoid false positives.
Sourcepub fn reset_session(&self, session_id: &SessionId)
pub fn reset_session(&self, session_id: &SessionId)
Reset all failure counts for a session. Call this when a new turn starts.
Trait Implementations§
Source§impl ToolErrorRecovery for ConsecutiveFailureRecovery
impl ToolErrorRecovery for ConsecutiveFailureRecovery
fn on_error( &self, session_id: &SessionId, tool_names: &[String], _error: &AgentError, ) -> Result<ToolErrorAction, AgentError>
Auto Trait Implementations§
impl !Freeze for ConsecutiveFailureRecovery
impl RefUnwindSafe for ConsecutiveFailureRecovery
impl Send for ConsecutiveFailureRecovery
impl Sync for ConsecutiveFailureRecovery
impl Unpin for ConsecutiveFailureRecovery
impl UnsafeUnpin for ConsecutiveFailureRecovery
impl UnwindSafe for ConsecutiveFailureRecovery
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