Skip to main content

ModelRetryStrategy

Trait ModelRetryStrategy 

Source
pub trait ModelRetryStrategy:
    Send
    + Sync
    + 'static {
    // Required methods
    fn name(&self) -> &str;
    fn compute_retry_decision<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        context: &'life1 ModelRetryContext<'life2>,
    ) -> Pin<Box<dyn Future<Output = Result<RetryDecision>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait;

    // Provided methods
    fn type_name(&self) -> &'static str { ... }
    fn on_first_model_attempt(&self) { ... }
}
Expand description

A policy for retrying failed model calls (ModelRetryStrategy).

An implementation answers whether to retry and how long to wait; the agent handles the rest: it skips the strategy when another hook already asked for a retry or the call succeeded, calls on_first_model_attempt when a fresh retry budget starts, waits for the returned delay (ending early on cancellation) and then retries.

Instances usually carry per-budget state, so one instance belongs to one agent.

Required Methods§

Source

fn name(&self) -> &str

A stable identifier for the strategy (name).

Source

fn compute_retry_decision<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, context: &'life1 ModelRetryContext<'life2>, ) -> Pin<Box<dyn Future<Output = Result<RetryDecision>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Decides whether to retry the failed model call and how long to wait first.

Called only for failed calls no other hook has already marked for retry.

§Errors

An error ends the invocation with it.

Provided Methods§

Source

fn type_name(&self) -> &'static str

The implementing type’s name, such as DefaultModelRetryStrategy, which messages use. Provided; implementors keep the default.

Source

fn on_first_model_attempt(&self)

Called when attempt_count is 1, at the start of a fresh retry budget: a new turn, or a model router switching candidates. Strategies with per-budget state clear it here; the default does nothing.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§