ToolNode returns "Error: Tool 'undefined' not found" even when tool call name matches registered tool names #330

Closed
opened 2026-02-15 18:15:57 -05:00 by yindo · 0 comments
Owner

Originally created by @meetmerchant on GitHub (Aug 4, 2025).

Checked other resources

  • I added a very descriptive title to this issue.
  • I searched the LangGraph.js documentation with the integrated search.
  • I used the GitHub search to find a similar question and didn't find it.
  • I am sure that this is a bug in LangGraph.js rather than my code.
  • The bug is not resolved by updating to the latest stable version of LangGraph (or the specific integration package).

Error Message and Stack Trace (if applicable)

Error: Tool "undefined" not found. Please fix your mistakes.

Description

What I was trying to achieve
I’m building a graph-based agent workflow with LangGraph, where a user message is sent to an LLM, which then issues a tool/function call (using OpenAI function calling). The intended flow is:

I register several tools (e.g., "doActionA", "doActionB", "doActionC") using LangChain’s tool() helper, each with a unique name property.

When the LLM agent receives a prompt (e.g., "perform action A"), it is expected to respond with a tool/function call like { function: { name: "doActionA", arguments: ... } }.

The ToolNode is supposed to receive this tool call, find the matching tool by name, and invoke it.

What I tried
Ensured my tool array is always [actionATool, actionBTool, actionCTool], with each tool having a .name property like "doActionA", "doActionB", etc.

When calling the LLM (OpenAI/Azure), I pass the tools array, converting Zod schemas to JSON Schema using zod-to-json-schema.

Confirmed by logging:

The tool names in the tool array used by ToolNode at runtime.

The name of the tool call returned by the LLM in the assistant message (e.g., "doActionA").

Verified that only one version of all LangChain packages is installed (checked with npm ls).

Restarted my server and cleaned all caches to eliminate hot reload or module duplication issues.

What actually happens
The tool call is returned by the LLM correctly:
function: { name: "doActionA", arguments: ... }

The ToolNode receives this tool call, and my debug logs confirm the registered tools include "doActionA".

But instead of invoking the tool, ToolNode produces an error:

Error: Tool "undefined" not found. Please fix your mistakes.
And the resulting tool message has name: undefined.

Other details
There are no duplicate or mismatched module versions.

I confirmed all messages retain their tool_calls property when being passed to the graph and ToolNode.

I added debug logs inside ToolNode’s invoke() that confirmed the array of registered tool names, as well as the incoming tool call name, always match as expected at runtime.

As a workaround, I implemented a manual tool dispatcher that maps the tool call name to the tool instance and calls .invoke() directly—this worked as expected.

Summary
Despite every tool name and function call name matching perfectly, and with all versioning and data integrity validated, ToolNode fails to match the tool call and returns an error message referencing "undefined". This appears to be a lookup bug inside ToolNode.

Happy to share a minimal reproducible repo or further logs if needed!

Originally created by @meetmerchant on GitHub (Aug 4, 2025). ### Checked other resources - [x] I added a very descriptive title to this issue. - [x] I searched the LangGraph.js documentation with the integrated search. - [x] I used the GitHub search to find a similar question and didn't find it. - [x] I am sure that this is a bug in LangGraph.js rather than my code. - [x] The bug is not resolved by updating to the latest stable version of LangGraph (or the specific integration package). ### Error Message and Stack Trace (if applicable) Error: Tool "undefined" not found. Please fix your mistakes. ### Description What I was trying to achieve I’m building a graph-based agent workflow with LangGraph, where a user message is sent to an LLM, which then issues a tool/function call (using OpenAI function calling). The intended flow is: I register several tools (e.g., "doActionA", "doActionB", "doActionC") using LangChain’s tool() helper, each with a unique name property. When the LLM agent receives a prompt (e.g., "perform action A"), it is expected to respond with a tool/function call like { function: { name: "doActionA", arguments: ... } }. The ToolNode is supposed to receive this tool call, find the matching tool by name, and invoke it. What I tried Ensured my tool array is always [actionATool, actionBTool, actionCTool], with each tool having a .name property like "doActionA", "doActionB", etc. When calling the LLM (OpenAI/Azure), I pass the tools array, converting Zod schemas to JSON Schema using zod-to-json-schema. Confirmed by logging: The tool names in the tool array used by ToolNode at runtime. The name of the tool call returned by the LLM in the assistant message (e.g., "doActionA"). Verified that only one version of all LangChain packages is installed (checked with npm ls). Restarted my server and cleaned all caches to eliminate hot reload or module duplication issues. What actually happens The tool call is returned by the LLM correctly: function: { name: "doActionA", arguments: ... } The ToolNode receives this tool call, and my debug logs confirm the registered tools include "doActionA". But instead of invoking the tool, ToolNode produces an error: Error: Tool "undefined" not found. Please fix your mistakes. And the resulting tool message has name: undefined. Other details There are no duplicate or mismatched module versions. I confirmed all messages retain their tool_calls property when being passed to the graph and ToolNode. I added debug logs inside ToolNode’s invoke() that confirmed the array of registered tool names, as well as the incoming tool call name, always match as expected at runtime. As a workaround, I implemented a manual tool dispatcher that maps the tool call name to the tool instance and calls .invoke() directly—this worked as expected. Summary Despite every tool name and function call name matching perfectly, and with all versioning and data integrity validated, ToolNode fails to match the tool call and returns an error message referencing "undefined". This appears to be a lookup bug inside ToolNode. Happy to share a minimal reproducible repo or further logs if needed!
yindo closed this issue 2026-02-15 18:15:57 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langchain-ai/langgraphjs#330