pub struct DefaultRetryStrategy {
pub max_attempts: u32,
pub base_delay: Duration,
pub max_delay: Duration,
pub multiplier: f64,
pub jitter: bool,
}Expand description
Exponential back-off retry strategy with optional jitter.
Only transient errors (AgentError::ModelThrottled and
AgentError::NetworkError) are retried. All other error variants are
considered non-retryable and cause an immediate exit.
§Defaults
| Field | Default |
|---|---|
max_attempts | 3 |
base_delay | 1 second |
max_delay | 60 seconds |
multiplier | 2.0 |
jitter | true |
Fields§
§max_attempts: u32Maximum number of attempts (including the first). The strategy returns
false from should_retry once attempt >= max_attempts.
base_delay: DurationBase delay before the first retry (attempt 1).
max_delay: DurationUpper bound on the computed delay — the delay is capped at this value regardless of the exponential growth.
multiplier: f64Multiplicative factor applied per attempt.
jitter: boolWhen true, the computed delay is multiplied by a random factor in
[0.5, 1.5) to spread out retries across concurrent callers.
Implementations§
Source§impl DefaultRetryStrategy
impl DefaultRetryStrategy
Sourcepub const fn with_max_attempts(self, n: u32) -> Self
pub const fn with_max_attempts(self, n: u32) -> Self
Set the maximum number of attempts.
Sourcepub const fn with_base_delay(self, d: Duration) -> Self
pub const fn with_base_delay(self, d: Duration) -> Self
Set the base delay before the first retry.
Sourcepub const fn with_max_delay(self, d: Duration) -> Self
pub const fn with_max_delay(self, d: Duration) -> Self
Set the maximum delay cap.
Sourcepub const fn with_multiplier(self, m: f64) -> Self
pub const fn with_multiplier(self, m: f64) -> Self
Set the exponential multiplier.
Sourcepub const fn with_jitter(self, j: bool) -> Self
pub const fn with_jitter(self, j: bool) -> Self
Enable or disable jitter.
Trait Implementations§
Source§impl Clone for DefaultRetryStrategy
impl Clone for DefaultRetryStrategy
Source§fn clone(&self) -> DefaultRetryStrategy
fn clone(&self) -> DefaultRetryStrategy
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more