From fcfb9dd3a71fcc8b666d929dce25dfd1709dd34b Mon Sep 17 00:00:00 2001 From: Sydney Runkle Date: Fri, 29 Aug 2025 17:02:03 -0400 Subject: [PATCH] asyncio escape hatch --- libs/prebuilt/langgraph/prebuilt/tool_node.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/libs/prebuilt/langgraph/prebuilt/tool_node.py b/libs/prebuilt/langgraph/prebuilt/tool_node.py index 252f88802..453f2c961 100644 --- a/libs/prebuilt/langgraph/prebuilt/tool_node.py +++ b/libs/prebuilt/langgraph/prebuilt/tool_node.py @@ -443,7 +443,12 @@ class ToolNode(RunnableCallable): return invalid_tool_message try: call_args = {**call, **{"type": "tool_call"}} - response = self.tools_by_name[call["name"]].invoke(call_args, config) + tool = self.tools_by_name[call["name"]] + + try: + response = tool.invoke(call_args, config) + except NotImplementedError as e: + response = asyncio.run(tool.ainvoke(call_args, config)) # GraphInterrupt is a special exception that will always be raised. # It can be triggered in the following scenarios,