call_model
graph node receives a malformed list of messages. Specifically, it is malformed when there are AIMessages
with tool_calls
(LLM requesting to call a tool) that do not have a corresponding ToolMessage
(result of a tool invocation to return to the LLM).
There could be a few reasons you’re seeing this error:
graph.invoke({'messages': [AIMessage(..., tool_calls=[...])]})
tools
node (i.e. a list of ToolMessages)
and you invoked it with an input that is not None or a ToolMessage,
e.g. graph.invoke({'messages': [HumanMessage(...)]}, config)
.
This interrupt could have been triggered in one of the following ways:interrupt_before = ['tools']
in create_react_agent
"tools"
)graph.invoke({'messages': [ToolMessage(...)]})
.
NOTE: this will append the messages to the history and run the graph from the START node.
graph.get_state(config)
graph.update_state(config, {'messages': ...})
with the modified list of messages 4. resume the graph, e.g. call graph.invoke(None, config)