Tool retry middleware for agents.
Base middleware class for an agent.
Subclass this and implement any of the defined methods to customize agent behavior between steps in the main agent loop.
State schema for the agent.
Middleware that automatically retries failed tool calls with configurable backoff.
Supports retrying on specific exceptions and exponential backoff.
Type for specifying failure handling behavior.
Can be either:
'error' or 'continue')
'error': Re-raise the exception, stopping agent execution.'continue': Inject a message with the error details, allowing the agent to continue.
For tool retries, a ToolMessage with the error details will be injected.
For model retries, an AIMessage with the error details will be returned.Type for specifying which exceptions to retry on.
Can be either:
isinstance checks)True if it should be retried