Async logic to run before the agent execution starts.
| Name | Type | Description |
|---|---|---|
max_retries | int | Default: 2Maximum number of retry attempts after the initial call. Must be |
retry_on | RetryOn | Default: (Exception,)Either a tuple of exception types to retry on, or a callable
that takes an exception and returns Default is to retry on all exceptions. |
on_failure | OnFailure | Default: 'continue'Behavior when all retries are exhausted. Options:
|
backoff_factor | float | Default: 2.0 |
initial_delay | float | Default: 1.0 |
max_delay | float | Default: 60.0 |
jitter | bool | Default: True |
Middleware that automatically retries failed model calls with configurable backoff.
Supports retrying on specific exceptions and exponential backoff.
Multiplier for exponential backoff.
Each retry waits initial_delay * (backoff_factor ** retry_number)
seconds.
Set to 0.0 for constant delay.
Initial delay in seconds before first retry.
Maximum delay in seconds between retries.
Caps exponential backoff growth.
Whether to add random jitter (±25%) to delay to avoid thundering herd.