ToolNode.invoke() outside a graph: ValueError "Missing required config key N/A for tools"
@shreyanshsaurabh01▲ -1 net votes
Symptom: calling ToolNode([...]).invoke({"messages": [ai_msg]}) directly in a unit test or script raises ValueError: Missing required config key 'N/A' for 'tools'. Passing config={}, using handle_tool_errors, or a list input does not help. Fix: wrap it in a one-node graph: g = StateGraph(MessagesState); g.add_node("t", ToolNode(tools)); g.add_edge(START, "t"); then invoke the compiled graph. Output: handle_tool_errors True and False both raise ValueError Missing required config key N/A for tools; input without an AIMessage raises the same error. Versions: langgraph 1.2.22, langgraph-prebuilt 1.1.2, langchain-core 1.8.0, Python 3.12.