Skip to content

Error Occurred When LLM Returns AI Message with Two Tool Calls Moving to Separate Tool Nodes #1398

Closed Answered by vbarda
modestme asked this question in Q&A
Discussion options

You must be logged in to vote

@modestme the issue you're encountering is because you're trying to send all tool calls to both tool nodes, but they only know how to handle a single tool. as a result, each tool node returns one correct tool message (with result of add/multiply) and one tool message with error (as it doesn't support the other tool by definition). as a result of that, LLM gets confused as it tries to fix that error. here is how you can achieve the desired behavior:

add_node = ToolNode(tools=[add])
multiply_node = ToolNode(tools=[multiply])

def call_add(state):
    messages = state["messages"]
    tool_messages = add_node.invoke([messages[-1]])
    return {"messages": [message for message in tool_messages if

Replies: 1 comment 5 replies

Comment options

You must be logged in to vote
5 replies
@modestme
Comment options

@modestme
Comment options

@vbarda
Comment options

Answer selected by modestme
@modestme
Comment options

@modestme
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants