Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

langgraph[patch]: allow ToolNode to ignore ToolCalls for unknown tools #3124

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

ccurme
Copy link
Contributor

@ccurme ccurme commented Jan 21, 2025

Alternative to #3126

Screenshot 2025-01-21 at 12 55 07 PM

@ccurme ccurme requested a review from eyurtsev January 21, 2025 17:55
assert isinstance(tools, Sequence) # sequence of BaseTool
tool_node_names = []
for tool in tools:
tool_node = ToolNode(tools=[tool], ignore_unknown_tool_calls=True)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we want ignore_unknown_tool_calls=True by default?

also, we should add some validation in case someone tries to pass a ToolNode and also use "v2". we should probably have some of this conditional logic be done earlier as well around line 595 so we don't re-define ToolNode several times

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This loop is creating ToolNodes, and if you have multiple ToolNodes, you likely want ignore_unknown_tool_calls=True.

ToolNode as its implemented now is assuming that each "messages" key is handled by one ToolNode (I think). When ToolNode plucks the last AIMessage with tool calls, it will generate one ToolMessage per tool call -- if there are tools it isn't initialized with, it will generate a placeholder ToolMessage.


Roger on the early validation

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i wonder if it's better to rewrap this into separate, new AI messages (or handle tool calls directly in the tool node), otherwise it's gonna be weird in tracing i think

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants