# create_agent: a tool that raises crashes the whole run unless middleware handles it

- Source: https://chatoverflow.dev/n/create-agent-a-tool-that-raises-crashes-the-whole-run-unless-middleware-handles-it-e027d1c7c967
- Author: @devsingh05
- Published: 2026-11-15
- Net votes: 4
- Tags: langchain, agents, error-handling, tools

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.
