Skip to content

Commit 05f9b61

Browse files
authored
bump core and update tool definition (#4)
1 parent 564fd4c commit 05f9b61

File tree

2 files changed

+7
-11
lines changed

2 files changed

+7
-11
lines changed

langgraph_swarm/handoff.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import re
22

33
from langchain_core.messages import ToolMessage
4-
from langchain_core.tools import BaseTool, InjectedToolCallId, StructuredTool
4+
from langchain_core.tools import BaseTool, InjectedToolCallId, tool
55
from langgraph.graph.state import CompiledStateGraph
66
from langgraph.prebuilt import ToolNode
77
from langgraph.types import Command
@@ -32,6 +32,7 @@ def create_handoff_tool(*, agent_name: str, description: str | None = None) -> B
3232
if description is None:
3333
description = f"Ask agent '{agent_name}' for help"
3434

35+
@tool(name, description=description)
3536
def handoff_to_agent(
3637
tool_call_id: Annotated[str, InjectedToolCallId],
3738
):
@@ -46,13 +47,8 @@ def handoff_to_agent(
4647
update={"messages": [tool_message], "active_agent": agent_name},
4748
)
4849

49-
handoff_tool = StructuredTool.from_function(
50-
name=name,
51-
description=description,
52-
func=handoff_to_agent,
53-
metadata={METADATA_KEY_HANDOFF_DESTINATION: agent_name},
54-
)
55-
return handoff_tool
50+
handoff_to_agent.metadata = {METADATA_KEY_HANDOFF_DESTINATION: agent_name}
51+
return handoff_to_agent
5652

5753

5854
def get_handoff_destinations(agent: CompiledStateGraph, tool_node_name: str = "tools") -> list[str]:

uv.lock

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)