LangGraph raises TypeError on function node output

LangGraph raises TypeError on function node output

This morning my LangGraph flow crashed after a new tool node.

TypeError: cannot unpack non-iterable ToolInvocation object

Python 3.12, langgraph 0.3.8, langchain 0.2.1.

The node function returned a ToolInvocation instead of (ToolInvocation, kwargs); API changed in 0.3.7.

Fix:

def my_node(state):
    return ToolInvocation(tool="search", input=state["q"]), {}

After returning the tuple the graph executed.

If you prefer old style pin langgraph below 0.3.7:

pip install "langgraph<0.3.7"
comments powered by Disqus