pub struct RetryPolicy {
pub max_attempts: u32,
pub base_delay: Duration,
pub capacity_base_delay: Duration,
pub capacity_max_delay: Duration,
pub max_total_backoff: Duration,
pub job_timeout: Duration,
}Expand description
How a transient inference failure is retried before the agent is failed.
Transient errors (see ProviderError::is_transient) are retried with
exponential backoff; a permanent error (auth, invalid request, token limit)
fails immediately. This keeps a passing network blip from marking a stage
error and carrying its half-finished work forward.
A capacity failure - a 429, or Anthropic’s 529 “overloaded” - is retried on
its own, much slower schedule (see Self::capacity_base_delay), because it
describes a window that lasts minutes rather than a blip that clears in a
second. When the provider said how long to wait, that answer is used instead
of any of these numbers.
Every schedule is bounded twice over: by Self::max_attempts, and by
Self::max_total_backoff on the sum of the waits. A job can never retry
forever.
Fields§
§max_attempts: u32Total attempts including the first (e.g. 4 = one try + three retries).
base_delay: DurationBase backoff; the retry after attempt n waits base_delay * 2^(n-1)
(so 1s, 2s, 4s, … for a 1s base).
capacity_base_delay: DurationBase backoff for a capacity failure the provider gave no Retry-After
for, doubling per attempt exactly as Self::base_delay does and capped
at Self::capacity_max_delay. Defaults to
CAPACITY_BASE_DELAY_SECS, so the default schedule is 15s, 30s, 60s.
capacity_max_delay: DurationCeiling on one capacity backoff, and on an honored Retry-After.
Defaults to CAPACITY_MAX_DELAY_SECS.
max_total_backoff: DurationCeiling on the sum of every backoff this job sleeps. Once it is spent the
job stops retrying and reports the last error, whatever
Self::max_attempts still allowed. Defaults to
MAX_TOTAL_BACKOFF_SECS.
job_timeout: DurationHard ceiling on the total wall-clock time one job (all attempts + backoffs) may run before it is aborted and its pool slot freed.
Providers apply this same deadline as their own per-call timeout, so a
call normally ends there. This outer bound is the backstop: a provider
timer can be defeated (e.g. a connection that keeps trickling keepalive
bytes without ever completing resets a read timer forever), which would
leak the permit until the model’s pool fills and new agents never get a
slot. Wrapping the whole job in a wall-clock timeout guarantees the slot
is released within a fixed time regardless. Defaults to
leviath_providers::DEFAULT_INFERENCE_TIMEOUT_SECS; a stage’s
request_timeout_secs overrides it per stage.
Trait Implementations§
Source§impl Clone for RetryPolicy
impl Clone for RetryPolicy
Source§fn clone(&self) -> RetryPolicy
fn clone(&self) -> RetryPolicy
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for RetryPolicy
Source§impl Debug for RetryPolicy
impl Debug for RetryPolicy
Auto Trait Implementations§
impl Freeze for RetryPolicy
impl RefUnwindSafe for RetryPolicy
impl Send for RetryPolicy
impl Sync for RetryPolicy
impl Unpin for RetryPolicy
impl UnsafeUnpin for RetryPolicy
impl UnwindSafe for RetryPolicy
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> ConditionalSend for Twhere
T: Send,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSend for T
impl<T> DowncastSend for T
Source§impl<T> FromTemplate for T
impl<T> FromTemplate for T
Source§impl<T> FromWorld for Twhere
T: Default,
impl<T> FromWorld for Twhere
T: Default,
Source§fn from_world(_world: &mut World) -> T
fn from_world(_world: &mut World) -> T
Creates Self using default().
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoResult<T> for T
impl<T> IntoResult<T> for T
Source§fn into_result(self) -> Result<T, RunSystemError>
fn into_result(self) -> Result<T, RunSystemError>
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<T> Template for T
impl<T> Template for T
Source§fn build_template(
&self,
_context: &mut TemplateContext<'_, '_>,
) -> Result<<T as Template>::Output, BevyError>
fn build_template( &self, _context: &mut TemplateContext<'_, '_>, ) -> Result<<T as Template>::Output, BevyError>
entity context to produce a Template::Output.Source§fn clone_template(&self) -> T
fn clone_template(&self) -> T
Clone.