LangGraph Parallel Execution Issue: AIMessages Without Corresponding ToolMessage #3147
Replies: 2 comments 4 replies
-
Can you provide a code example that illustrates the issue? From reading the problem description and the error, it doesn't seem like the issue is related to parallel tool calling (but parallel tool calling can be disabled via I am not sure what your implementation looks like, but in general, if you are sending multiple inputs on the same thread, you might want to wait until the original thread is finished before sending inputs, otherwise as you pointed out you might get a malformed message history that model providers don't accept. this conceptual doc from LangGraph platform might be helpful https://langchain-ai.github.io/langgraph/concepts/double_texting/ |
Beta Was this translation helpful? Give feedback.
-
Initially, I thought I could reuse the _valid_chat_history(...) function within the However, during my experiments, I discovered that _valid_chat_history is executed before the Simplified Execution Flow (I may have missed some steps): Reference: acall_model I realized that I could achieve the desired behavior by overriding the create_react_agent and acall_model() functions, but I’m wondering if there is a way to reuse the existing implementation instead. Just an idea for Improvement Would it make sense to introduce a more flexible chat history validation mechanism, similar to |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi everyone,
I ran into an issue when trying to send two parallel questions to the agent using the same thread_id. The second question, which was sent a few seconds later, resulted in the following error:
ValueError: Found AIMessages with tool_calls that do not have a corresponding ToolMessage. Here are the first few of those tool calls.
Our team uses the prebuilt LangGraph
langgraph.prebuilt.create_react_agent
function to create a graph andlanggraph.checkpoint.postgres.aio.AsyncPostgresSaver
for checkpointing.This issue occurs because question
#2
picks up the chat history, which includes messages from question#1
that is still in progress.Is there a way to handle or prevent parallel calls within LangChain/LangGraph?
Any insights would be greatly appreciated!
Beta Was this translation helpful? Give feedback.
All reactions