Skip to content

Commit 7ac209b

Browse files
authored
Update custom handoff tool doc (#211)
Closes #199 Thank you for raising the issue! It does look like the example was missing it.
1 parent 9dacf15 commit 7ac209b

File tree

8 files changed

+227
-211
lines changed

8 files changed

+227
-211
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# Pyenv
22
.python-version
3+
.ipynb_checkpoints/
34

45
# Byte-compiled / optimized / DLL files
56
__pycache__/

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ lint_diff format_diff: PYTHON_FILES=$(shell git diff --relative=. --name-only --
2828
lint lint_diff:
2929
[ "$(PYTHON_FILES)" = "" ] || uv run ruff format $(PYTHON_FILES) --diff
3030
[ "$(PYTHON_FILES)" = "" ] || uv run ruff check $(PYTHON_FILES) --diff
31-
[ "$(PYTHON_FILES)" = "" ] || uv run mypy $(PYTHON_FILES)
31+
[ "$(PYTHON_FILES)" = "" ] || uvx ty check $(PYTHON_FILES)
3232

3333
format format_diff:
3434
[ "$(PYTHON_FILES)" = "" ] || uv run ruff check --fix $(PYTHON_FILES)

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,7 @@ from langchain_core.tools import tool, BaseTool, InjectedToolCallId
229229
from langchain_core.messages import ToolMessage
230230
from langgraph.types import Command
231231
from langgraph.prebuilt import InjectedState
232+
from langgraph_supervisor.handoff import METADATA_KEY_HANDOFF_DESTINATION
232233

233234
def create_custom_handoff_tool(*, agent_name: str, name: str | None, description: str | None) -> BaseTool:
234235

@@ -261,6 +262,7 @@ def create_custom_handoff_tool(*, agent_name: str, name: str | None, description
261262
},
262263
)
263264

265+
handoff_to_agent.metadata = {METADATA_KEY_HANDOFF_DESTINATION: agent_name}
264266
return handoff_to_agent
265267
```
266268

langgraph_supervisor/supervisor.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ def _supports_disable_parallel_tool_calls(model: LanguageModelLike) -> bool:
5757

5858

5959
def _make_call_agent(
60-
agent: Pregel,
60+
agent: Pregel[Any],
6161
output_mode: OutputMode,
6262
add_handoff_back_messages: bool,
6363
supervisor_name: str,
@@ -181,7 +181,7 @@ def _prepare_tool_node(
181181
if input_tool_node is not None:
182182
tool_node = ToolNode(
183183
all_tools,
184-
name=input_tool_node.name,
184+
name=str(input_tool_node.name),
185185
tags=list(input_tool_node.tags) if input_tool_node.tags else None,
186186
handle_tool_errors=input_tool_node.handle_tool_errors,
187187
messages_key=input_tool_node.messages_key,

pyproject.toml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,3 +60,10 @@ warn_return_any = true
6060
warn_unused_configs = true
6161
disallow_untyped_defs = true
6262
check_untyped_defs = true
63+
64+
[tool.ty.rules]
65+
no-matching-overload = "ignore"
66+
call-non-callable = "ignore"
67+
unresolved-import = "ignore"
68+
[tool.ty.src]
69+
exclude = ["tests"]

tests/test_supervisor.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Tests for the supervisor module."""
2+
# mypy: ignore-errors
23

34
from collections.abc import Callable, Sequence
45
from typing import Any, Optional, cast

tests/test_supervisor_functional_api.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Tests for the supervisor module using functional API."""
2+
# mypy: ignore-errors
23

34
from typing import Any, Dict, List
45

uv.lock

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

0 commit comments

Comments
 (0)