aidputils.agents.toolkit.handoff¶
- aidputils.agents.toolkit.handoff.create_handoff_tool(*, agent_name: str, name: str | None = None, description: str | None = None, add_handoff_messages: bool = True) langchain_core.tools.BaseTool[source]¶
Create a tool that can handoff control to the requested agent.
- Parameters:
agent_name – The name of the agent to handoff control to, i.e. the name of the agent node in the multi-agent graph. Agent names should be simple, clear and unique, preferably in snake_case, although you are only limited to the names accepted by LangGraph nodes as well as the tool names accepted by LLM providers (the tool name will look like this: transfer_to_<agent_name>).
name – Optional name of the tool to use for the handoff. If not provided, the tool name will be transfer_to_<agent_name>.
description – Optional description for the handoff tool. If not provided, the description will be Ask agent <agent_name> for help.
add_handoff_messages – Whether to add handoff messages to the message history. If False, the handoff messages will be omitted from the message history.
- aidputils.agents.toolkit.handoff.create_handoff_back_messages(agent_name: str, supervisor_name: str) tuple[langchain_core.messages.AIMessage, langchain_core.messages.ToolMessage][source]¶
Create a pair of (AIMessage, ToolMessage) to add to the message history when returning control to the supervisor.
- aidputils.agents.toolkit.handoff.create_forward_message_tool(supervisor_name: str = 'supervisor') langchain_core.tools.BaseTool[source]¶
Create a tool the supervisor can use to forward a worker message by name.
This helps avoid information loss any time the supervisor rewrites a worker query to the user and also can save some tokens.
- Parameters:
supervisor_name – The name of the supervisor node (used for namespacing the tool).
- Returns:
The ‘forward_message’ tool.
- Return type: