LangGraph's ToolNode handles errors by catching them, formatting them into structured error messages, and surfacing them as ToolMessage content when handle_tool_errors=True (default), allowing the LLM to see and recover from failures.
ToolNode provides built-in error handling through its handle_tool_errors parameter. When set to True (the default), ToolNode wraps tool execution in a try-catch block. If a tool call fails with an exception, ToolNode catches it and converts it into a ToolMessage where the content field contains a structured error description [citation:1]. This ToolMessage is then added to the graph's messages key, allowing the language model to read the error and decide on a recovery strategy. This mechanism prevents the graph from crashing and keeps the agent loop running, enabling the agent to retry the tool with corrected arguments or choose an alternative path.
For custom error handling, you can pass a callable to handle_tool_errors that receives the exception and returns a custom error message. This allows you to format errors consistently or redact sensitive information before they reach the LLM.
If you add a ToolNode to a LangGraph flow and the external API it calls returns an error, how would you expect the node to reflect that error in the message state?
What happens to downstream nodes when a ToolNode raises an exception during execution?
Describe the steps you would take to log a tool call failure inside a ToolNode.
You notice that when a tool call fails, the conversation stops instead of continuing. Walk me through how you would debug the ToolNode's error handling and adjust it to surface the error back to the user.
Explain the trade‑offs between letting a ToolNode raise an exception versus catching it and inserting an error message into the message state.
Suppose you need to retry a failing tool call within a ToolNode. How would you modify the error handling logic while preserving the message state semantics?
Design a robust error handling strategy for ToolNodes in a production LangGraph pipeline that must handle timeouts, rate limits, and unexpected payloads, ensuring errors are surfaced to the message state without breaking the graph.
How would you instrument monitoring and alerting around ToolNode failures, and what changes would you make to the message state schema to support richer error context?
If you had to support multiple concurrent tool calls within a single ToolNode, how would you aggregate and surface individual errors back into the message state efficiently?
At scale, how would you evolve the ToolNode error handling pattern to support versioned tool contracts and backward compatibility across teams, while keeping the message state stable for downstream consumers?
Discuss the architectural implications of moving error handling from the ToolNode into a centralized error middleware in LangGraph. What are the benefits and risks?
When migrating a legacy system that used custom error propagation to LangGraph's ToolNode model, what steps would you take to ensure seamless error surfacing and minimal disruption to existing message processing pipelines?