diff --git a/libs/langgraph/src/prebuilt/tool_node.ts b/libs/langgraph/src/prebuilt/tool_node.ts index 5c8e2170..9e0bffdd 100644 --- a/libs/langgraph/src/prebuilt/tool_node.ts +++ b/libs/langgraph/src/prebuilt/tool_node.ts @@ -9,6 +9,7 @@ import { StructuredToolInterface } from "@langchain/core/tools"; import { RunnableCallable } from "../utils.js"; import { END } from "../graph/graph.js"; import { MessagesAnnotation } from "../graph/messages_annotation.js"; +import { isGraphInterrupt } from "../errors.js"; export type ToolNodeOptions = { name?: string; @@ -187,6 +188,12 @@ export class ToolNode extends RunnableCallable { if (!this.handleToolErrors) { throw e; } + if (isGraphInterrupt(e.name)) { + // `NodeInterrupt` errors are a breakpoint to bring a human into the loop. + // As such, they are not recoverable by the agent and shouldn't be fed + // back. Instead, re-throw these errors even when `handleToolErrors = true`. + throw e; + } return new ToolMessage({ content: `Error: ${e.message}\n Please fix your mistakes.`, name: call.name,