Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions langgraph_swarm/handoff.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
from dataclasses import is_dataclass
from typing import Annotated, Any

from langchain_core.messages import ToolMessage
from langchain_core.messages import ToolMessage, RemoveMessage
from langchain_core.tools import BaseTool, InjectedToolCallId, tool
from langgraph.graph.message import REMOVE_ALL_MESSAGES
from langgraph.graph.state import CompiledStateGraph
from langgraph.prebuilt import InjectedState, ToolNode
from langgraph.types import Command
Expand Down Expand Up @@ -84,7 +85,7 @@ def handoff_to_agent(
goto=agent_name,
graph=Command.PARENT,
update={
"messages": [*_get_field(state, "messages"), tool_message],
"messages": [RemoveMessage(REMOVE_ALL_MESSAGES), *_get_field(state, "messages"), tool_message],
"active_agent": agent_name,
},
)
Expand Down