Skip to content

The agent engineering platform.

docs(langchain): clarify `ToolRetryMiddleware` exception handling (#38884)

ccurmea4538dbf07b6
diff --git a/libs/langchain_v1/langchain/agents/middleware/tool_retry.py b/libs/langchain_v1/langchain/agents/middleware/tool_retry.py
index 87e2095617..aa7f713f9b 100644
--- a/libs/langchain_v1/langchain/agents/middleware/tool_retry.py
+++ b/libs/langchain_v1/langchain/agents/middleware/tool_retry.py
@@ -152,7 +152,8 @@ class ToolRetryMiddleware(AgentMiddleware[AgentState[ResponseT], ContextT, Respo
retry_on: 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.
+ Default is to retry on all exceptions. Exceptions that do not match
+ propagate immediately and are not handled by `on_failure`.
on_failure: Behavior when all retries are exhausted.
Options: