2026-07-31T00:20:13.475Z
LangChain Multi-Agent Handoff: Audit State, Context, and Outcome
Audit LangChain handoffs across route, state, tool protocol, context, destination work, waiting, and verified outcomes.
For a LangChain multi agent handoff , a successful transfer tool call is only the first piece of evidence. Treat the handoff as healthy when the declared route is allowed, control state moves to the intended agent, the tool call cycle is closed, required context arrives, the destination starts useful work, and the requested outcome is independently verified. That answer matters because a graph can keep running after a damaged transfer. goto can name one node while active agent still names another. A transfer tool can return without a matching tool response. The new agent can start with incomplete context. It can also produce a polished final message while the external task remains unfinished. This guide turns those boundaries into a content free receipt and replays eight synthetic cases. The examples reflect the official LangChain and LangGraph documentation retrieved on July 30, 2026. At that check, PyPI reported LangChain 1.3.14 and LangGraph 1.2.10. Pin and recheck your own dependency versions because state and streaming contracts can change. Choose a handoff for stateful, direct conversation LangChain's handoffs documentation defines the pattern through state. A tool updates a variable such as current step or active agent ; subsequent model configuration or graph routing reads that variable. State persists across turns, so the currently active specialist can continue speaking directly with the user. This is a good fit when: a conversation moves through sequential stages; capabilities should unlock only after a precondition; the active specialist needs to remain in control on the next turn; the user should interact directly with that specialist. Do not begin with multiple agents just because the task is complicated. The official multi agent overview says a single agent with suitable tools and dynamic instructions can often do the work. It distinguishes handoffs from subagents, skills, routers, and custom workflows. A reasonable default is one agent plus middleware when the identity of the "agent" is mostly a change in prompt, tools, or stage. Choose separate agent subgraphs when the specialists need genuinely different state, tools, lifecycle logic, or ownership. That choice affects the evidence contract: Single agent with middleware: prove that the state variable changed and the next model call received the intended configuration. Multiple subgraphs: also prove that graph routing reached the destination and that the destination received the right context. Handoffs are stateful and multi hop. They are not the natural choice for parallel fan out, and they do not by themselves prove that a specialist finished the user's work. Audit six boundaries in order The documented multiple subgraph example returns a Command with goto , an active agent update, a ToolMessage , and graph=Command.PARENT . LangChain explicitly requires the ToolMessage to use the matching tool call id when a handoff tool updates message history. Without that response, the model's tool request response cycle is left malformed. Those fields define important checks, but they do not cover the whole operation: Boundary Minimum evidence Failed state Safe next move Route to agent is declared and goto === to agent ROUTE REJECTED Block the transfer; restore a declared route Control before state names the sender and after state names the receiver STALE CONTROL Reconcile persisted state before retrying Tool protocol one ToolMessage closes the exact tool call id OPEN TOOL PROTOCOL Repair history before another model call Context every required context key is present at the destination CONTEXT INCOMPLETE Rebuild the minimal transfer contract Destination the intended node records an admitted start DESTINATION NOT STARTED Inspect routing and node admission Outcome a task specific verifier records the expected result FALSE COMPLETE Reopen the task; do not trust the final message The context check should compare a schema, not a transcript. For example, a sales handoff might require request type , customer tier , and consent status . The receipt records those key names and perhaps content digests; it does not need the customer's message or tool arguments. This boundary is especially important for separate subgraphs. LangChain warns that their message flow requires explicit context engineering. Passing everything can bloat context or expose irrelevant data. Passing too little can make the receiver confidently solve a different task. Define required keys per route and fail closed when they are absent. The destination start receipt is separate from the control state update. A reducer can accept active agent: "sales agent" even if the sales node is never admitted, crashes immediately, or waits in a queue. State mutation is activity. A destination event establishes that the receiver actually began. Replay an eight case receipt The artifact for this article uses synthetic structural fields only: Its classifier applies a precedence rule. Earlier failures prevent a later green signal from hiding them: Run the complete local fixture with: The replay produced eight expected classifications from eight cases: This is not a failure rate claim about LangChain. It is a test of the decision rule. The useful observation is that aligned routing and state are still insufficient: changing only the tool message ID, context key set, destination start time, or outcome receipt changes the verdict. The fixture also prevents a tempting shortcut. If the final state says complete but the outcome receipt is absent, the classifier returns FALSE COMPLETE , even when every handoff specific field is valid. Transfer correctness and task correctness are different questions. Preserve legitimate waiting A destination agent may need a person to approve a purchase, disclose a secret through an authorized channel, or choose between irreversible options. That is not automatically a stuck handoff. Record a valid wait with: an accountable owner ; a bounded reason ; a future deadlineUtc ; a durable resumeTokenId ; the destination state and required context already persisted. When all five facts exist, route the run to WAITING ON APPROVAL . Notify the owner and leave the graph alone until the deadline or a decision. Repeated model calls do not resolve missing authority; they only spend budget and risk duplicate effects. If the wait has no owner or deadline, classify it as uncertain rather than healthy. If the resume token is missing, a human reply may not reconnect to the correct graph state. If the destination declares completion while still waiting, the outcome verifier takes precedence over the friendly final response. This distinction gives operators a practical intervention boundary: Waiting: preserve state and surface the decision to its owner. Stale control or open protocol: stop automatic continuation and reconcile evidence. False complete: reopen the task and run the outcome verifier. Healthy: do nothing. The default is observation, not recovery. A reroute may repeat a side effect, and a reconstructed message can change what the receiver sees. Require explicit authority before an intervention could alter external state. Put the receipt beside the graph Collect each boundary where its evidence becomes knowable: 1. At handoff creation: sender, intended receiver, route contract version, tool call ID, required context key names. 2. After state reduction: observed active agent , resulting graph scope, matching tool message ID. 3. At destination admission: node identity, start time, attempt identity, context contract result. 4. At a wait checkpoint: owner, reason, deadline, and opaque resume token ID. 5. At task verification: verifier name, result, freshness, and a non sensitive receipt ID. Do not assume a private state channel is private telemetry. The LangGraph Graph API documentation warns that private channels are not automatically redacted when streaming values. Restrict streamed keys explicitly, or emit a separate minimized health event. A safe handoff receipt should exclude prompts, message bodies, tool arguments, tool results, secrets, and absolute local paths. Version the route and context contracts. Without a version, an older sender can look healthy while transferring fields that a newer destination no longer understands. Keep one stable operation identity across retries so a second transfer does not become a second external action. Finally, choose an outcome verifier that matches the task. A support handoff might require a ticket state change; a purchasing handoff might require an order ID from the destination system; a coding handoff might require tests plus the expected artifact. An LLM's final message is not that receipt. Sidewisp is currently in private preview. The live early access site and article system are available, but production agent health collection, LangChain adapters, and automated recovery are not shipped in the current website repository. The receipt above is an operator pattern you can implement today. If one calm health view for these boundaries would help your team, the private preview waitlist is the appropriate next step.