Skip to content

Commit 8a9a13f

Browse files
committed
fix: update langgraph integration to use ToolNode instead of deprecated ToolExecutor
- Replace ToolExecutor import with ToolNode in TYPE_CHECKING block - Update to_tool_executor function to return ToolNode instead of deprecated ToolExecutor - Add mypy override to ignore missing imports for langgraph modules - Fix linting issue with blank line whitespace in docstring
1 parent 8bb3c02 commit 8a9a13f

File tree

3 files changed

+12
-65
lines changed

3 files changed

+12
-65
lines changed

examples/langgraph_tool_node.py

Lines changed: 0 additions & 60 deletions
This file was deleted.

pyproject.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,3 +120,7 @@ warn_unreachable = true
120120
[[tool.mypy.overrides]]
121121
module = "bm25s"
122122
ignore_missing_imports = true
123+
124+
[[tool.mypy.overrides]]
125+
module = "langgraph.*"
126+
ignore_missing_imports = true

stackone_ai/integrations/langgraph.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,8 @@
2222

2323
if TYPE_CHECKING: # pragma: no cover - only for typing
2424
try:
25-
from langgraph.prebuilt import ToolExecutor, ToolNode
25+
from langgraph.prebuilt import ToolNode
2626
except Exception: # pragma: no cover
27-
ToolExecutor = Any
2827
ToolNode = Any
2928

3029

@@ -59,12 +58,16 @@ def to_tool_node(tools: Tools | Sequence[BaseTool], **kwargs: Any) -> Any:
5958

6059

6160
def to_tool_executor(tools: Tools | Sequence[BaseTool], **kwargs: Any) -> Any:
62-
"""Create a LangGraph `ToolExecutor` from StackOne tools or LangChain tools."""
61+
"""Create a LangGraph `ToolNode` from StackOne tools or LangChain tools.
62+
63+
Note: ToolExecutor has been deprecated in favor of ToolNode.
64+
This function now returns a ToolNode for compatibility.
65+
"""
6366
_ensure_langgraph()
64-
from langgraph.prebuilt import ToolExecutor # local import with helpful error
67+
from langgraph.prebuilt import ToolNode # local import with helpful error
6568

6669
langchain_tools = _to_langchain_tools(tools)
67-
return ToolExecutor(langchain_tools, **kwargs)
70+
return ToolNode(langchain_tools, **kwargs)
6871

6972

7073
def bind_model_with_tools(model: Any, tools: Tools | Sequence[BaseTool]) -> Any:

0 commit comments

Comments
 (0)