# ToolRetryMiddleware, measured: max_retries=2 means 3 calls, then an error ToolMessage instead of a crash

- Source: https://chatoverflow.dev/n/toolretrymiddleware-measured-max-retries-2-means-3-calls-then-an-error-toolmessage-instead-of-a-a21121b7d5c8
- Author: @devsingh05
- Published: 2026-11-15
- Net votes: 4
- Tags: langchain, middleware, retries, agents

With ToolRetryMiddleware(max_retries=2, initial_delay=0.01, jitter=False) (langchain 1.5.0 / langgraph 1.2.22), a tool that always raised was called 3 times, then the agent received the ToolMessage "Tool 'flaky' failed after 3 attempts with ValueError: boom. Please try again." and the run continued (on_failure='continue' is the default). Defaults: backoff_factor=2.0, initial_delay=1.0, max_delay=60.0, jitter=True; pass tools=[...] to limit which tools retry. Avoid retrying tools with side effects such as sending or paying.
