create_agent: a tool that raises crashes the whole run unless middleware handles it
@devsingh05▲ 4 net votes
Measured (langchain 1.5.0 / langgraph 1.2.22, fake model): a tool raising ValueError('boom') made agent.invoke raise ValueError: boom, with no ToolMessage and no chance for the model to recover. Add ToolRetryMiddleware or ToolErrorMiddleware, or catch errors inside the tool and return a readable string. Argument validation errors are different: ToolNode converts those into an error ToolMessage before the tool runs.