From acdc1f7f6b65a9799fb3f1172c775d2f8d329c2a Mon Sep 17 00:00:00 2001 From: "open-swe[bot]" Date: Fri, 22 Aug 2025 13:26:40 +0000 Subject: [PATCH] Apply patch [skip ci] --- docs/docs/how-tos/multi_agent.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/docs/how-tos/multi_agent.md b/docs/docs/how-tos/multi_agent.md index 8f33099e6..d2dede896 100644 --- a/docs/docs/how-tos/multi_agent.md +++ b/docs/docs/how-tos/multi_agent.md @@ -26,7 +26,7 @@ To implement handoffs, you can return `Command` objects from your agent nodes or ```python from typing import Annotated from langchain_core.tools import tool, InjectedToolCallId -from langgraph.prebuilt import create_react_agent, InjectedState +from langgraph.prebuilt import create_react_agent from langgraph.graph import StateGraph, START, MessagesState from langgraph.types import Command @@ -37,7 +37,7 @@ def create_handoff_tool(*, agent_name: str, description: str | None = None): @tool(name, description=description) def handoff_tool( # highlight-next-line - state: Annotated[MessagesState, InjectedState], # (1)! + state, # (1)! Reserved keyword - automatically injected # highlight-next-line tool_call_id: Annotated[str, InjectedToolCallId], ) -> Command: @@ -58,7 +58,7 @@ def create_handoff_tool(*, agent_name: str, description: str | None = None): return handoff_tool ``` -1. Access the [state](../concepts/low_level.md#state) of the agent that is calling the handoff tool using the @[InjectedState] annotation. +1. Access the [state](../concepts/low_level.md#state) of the agent using the reserved keyword `state`. No annotation needed - LangGraph automatically injects the state when it sees this parameter name. 2. The `Command` primitive allows specifying a state update and a node transition as a single operation, making it useful for implementing handoffs. 3. Name of the agent or node to hand off to. 4. Take the agent's messages and **add** them to the parent's **state** as part of the handoff. The next agent will see the parent state. @@ -1250,4 +1250,4 @@ LangGraph comes with prebuilt implementations of two of the most popular multi-a :::js - [supervisor](../agents/multi-agent.md#supervisor) — individual agents are coordinated by a central supervisor agent. The supervisor controls all communication flow and task delegation, making decisions about which agent to invoke based on the current context and task requirements. You can use [`langgraph-supervisor`](https://github.com/langchain-ai/langgraph-supervisor-js) library to create a supervisor multi-agent systems. - [swarm](../agents/multi-agent.md#supervisor) — agents dynamically hand off control to one another based on their specializations. The system remembers which agent was last active, ensuring that on subsequent interactions, the conversation resumes with that agent. You can use [`langgraph-swarm`](https://github.com/langchain-ai/langgraph-swarm-js) library to create a swarm multi-agent systems. -::: \ No newline at end of file +:::