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§
Sourcefn effective_timeout(&self, category: ToolTimeoutCategory) -> Option<Duration>
fn effective_timeout(&self, category: ToolTimeoutCategory) -> Option<Duration>
Get the effective timeout for a tool category, considering adaptive tuning.
Sourcefn record_failure(&self, category: ToolTimeoutCategory) -> bool
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.
Sourcefn reset_failure(&self, category: ToolTimeoutCategory)
fn reset_failure(&self, category: ToolTimeoutCategory)
Reset failure tracking for a tool category (e.g., after a success streak).
Sourcefn record_latency(&self, category: ToolTimeoutCategory, duration: Duration)
fn record_latency(&self, category: ToolTimeoutCategory, duration: Duration)
Record a tool execution latency for adaptive timeout tuning.
Sourcefn should_circuit_break(
&self,
category: ToolTimeoutCategory,
) -> Option<Duration>
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.
Sourcefn decay_adaptive_timeout(&self, category: ToolTimeoutCategory)
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".