Issue with “Using with a custom agent” example when using models that support multi-tool calling (e.g., gpt-4o-mini) #4135
Unanswered
WorksOnMyVM
asked this question in
Q&A
Replies: 2 comments
-
👋 I'm not sure there's a really stellar solution here. The agent might be assuming that "Always do your portion of calculation before the handoff." means to have that be the first entry in a multiple-tool call situation. A few things I can think of:
|
Beta Was this translation helpful? Give feedback.
0 replies
-
any updates on this? langgraph sends an exception, but what is the solution to handle this? |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hi everyone,
I’ve encountered a problem when running the “Using with a custom agent” example in LangGraph with a model that supports multi-tool calling, such as gpt-4o-mini.
For the full code and setup, you can check this Gist:
https://gist.github.com/Makaveli-x/51845482edb6a591fa965d9453aee6a5
Problem
The example breaks when the model calls both the add tool and the make_handoff_tool (e.g., transfer_to_multiplication_expert) in a single turn. Before the handoff to multiplication_expert, the ToolMessage returned from the add function is not added to the state, so when control is passed to multiplication_expert, the corresponding ToolMessage for the add call is missing.
This leads to the following error:
Root Cause
In the call_tools implementation, when the model makes multiple tool calls in a single turn (e.g., both add and a handoff tool), the function returns two Command objects:
The issue is that the Command responsible for transferring to multiplication_expert does not include the result of the add tool call. So when the receiving agent resumes, the model is missing the ToolMessage for the add tool call, resulting in the error above.
Have you run into a similar issue when using multi-tool-capable models with agent handoffs? If so, how did you solve it?
Would love to hear your thoughts or if there’s a recommended fix!
Beta Was this translation helpful? Give feedback.
All reactions