Skip to main content

ToolResilience

Trait ToolResilience 

Source
pub trait ToolResilience: Send + Sync {
    // Required methods
    fn effective_timeout(
        &self,
        category: ToolTimeoutCategory,
    ) -> Option<Duration>;
    fn record_failure(&self, category: ToolTimeoutCategory) -> bool;
    fn reset_failure(&self, category: ToolTimeoutCategory);
    fn record_latency(&self, category: ToolTimeoutCategory, duration: Duration);
    fn should_circuit_break(
        &self,
        category: ToolTimeoutCategory,
    ) -> Option<Duration>;
    fn decay_adaptive_timeout(&self, category: ToolTimeoutCategory);
}
Expand description

Execution resilience: circuit breakers, adaptive timeouts, failure tracking.

Protects the system from cascading failures by tracking tool execution health and applying backpressure when tools become unreliable.

Required Methods§

Source

fn effective_timeout(&self, category: ToolTimeoutCategory) -> Option<Duration>

Get the effective timeout for a tool category, considering adaptive tuning.

Source

fn record_failure(&self, category: ToolTimeoutCategory) -> bool

Record a tool execution failure and check if circuit breaking should activate. Returns true if the circuit breaker tripped.

Source

fn reset_failure(&self, category: ToolTimeoutCategory)

Reset failure tracking for a tool category (e.g., after a success streak).

Source

fn record_latency(&self, category: ToolTimeoutCategory, duration: Duration)

Record a tool execution latency for adaptive timeout tuning.

Source

fn should_circuit_break( &self, category: ToolTimeoutCategory, ) -> Option<Duration>

Check if the circuit breaker is tripped for a category. Returns the recommended backoff duration if so.

Source

fn decay_adaptive_timeout(&self, category: ToolTimeoutCategory)

Decay adaptive timeouts after a success streak (relax backpressure).

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§