| Name | Type | Description |
|---|---|---|
max_retries | int | Default: 2Maximum number of retry attempts after the initial call. Must be |
tools | list[BaseTool | str] | None | Default: NoneOptional list of tools or tool names to apply retry logic to. Can be a list of If |
retry_on | RetryOn | Default: (Exception,) |
on_failure | OnFailure | Default: 'continue' |
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 tool calls with configurable backoff.
Supports retrying on specific exceptions and exponential backoff.
Either a tuple of exception types to retry on, or a callable
that takes an exception and returns True if it should be retried.
Default is to retry on all exceptions.
Behavior when all retries are exhausted.
Options:
'continue': Return a ToolMessage with error details,
allowing the LLM to handle the failure and potentially recover.'error': Re-raise the exception, stopping agent execution.ToolMessage content, allowing custom error
formatting.Deprecated values (for backwards compatibility):
'return_message': Use 'continue' instead.'raise': Use 'error' instead.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.