🎉 75% of content is free forever — Unlock Premium from $10/mo →
CW
NEWSLIVESearch All Content
đŸ’ŧ Servicesâ„šī¸ Aboutâœ‰ī¸ ContactView Pricing Plansfrom $10

Multi-Agent Teams: Supervisors, Handoffs, and Shared State

đŸŸĸ Free Lesson

When one agent stops being enough

A single agent handles a handful of tools comfortably. Past roughly eight to ten, tool selection accuracy drops: the model starts choosing plausible-but-wrong tools, arguments get smeared across similar tools, and the prompt carrying all those descriptions crowds out the actual conversation. The usual first fix is to prune the tool list. The second fix, when pruning is not enough, is to split the agent.

Splitting means giving each agent a narrow role and a tool set that belongs to that role, then deciding who talks to the user. Two shapes dominate practice. In the supervisor pattern, one agent reads every user turn, delegates to specialists, and composes the final answer. In the handoff pattern, agents pass the conversation to each other directly, each one owning the thread for a stretch. Supervisors are easier to reason about and to audit; handoffs feel more fluid but make it harder to say who was responsible for a given decision.

Supervisor routing to specialistsSupervisorResearcherweb_search, read_docAnalystcalculator, sqlWritersummarize, draft

Roles before architecture

Before drawing any graph, write down the roles. A research agent that gathers sources, an analyst that computes, and a writer that drafts will compose into a clear team. Researcher #1, Researcher #2 and Researcher-generalist will not. Roles should differ along two axes at once: the tools they hold and the system prompt that tells them what good work looks like. Agents that share both are the same agent wearing different names, and the only thing you have added is latency.

RoleToolsFailure it prevents
Researcherweb_search, read_documentAnalyst wasting context on raw sources
Analystcalculator, query_ordersResearcher producing arithmetic mistakes
Writersummarize, draft_emailAnalyst writing sprawling, unfocused prose
Supervisornone, routing onlyAny specialist talking past the user's intent

The supervisor holding no tools is a deliberate constraint. A supervisor with tools will be tempted to solve the problem itself when delegation feels slow, which reintroduces exactly the tool-competition problem the split was meant to solve. Give it only the ability to choose the next agent and to write the final reply.


A supervisor graph you can write in one file

The pattern below builds on the state graph from the previous lesson. The state gains a plan key, a short list of steps the supervisor has committed to, and the supervisor node emits both a routing decision and an updated plan so you can see its reasoning after the fact.

python
from typing import Annotated, Literal
from typing_extensions import TypedDict
from langgraph.graph import StateGraph, START, END
from langchain_core.messages import HumanMessage, AIMessage


class TeamState(TypedDict):
    messages: Annotated[list, lambda a, b: a + b]
    plan: list
    active_agent: str
    steps_remaining: int


def supervisor(state: TeamState):
    last = state["messages"][-1].content
    if "summarize" in last or "draft" in last:
        next_agent = "writer"
    elif "calculate" in last or "total" in last:
        next_agent = "analyst"
    else:
        next_agent = "researcher"
    plan = state.get("plan", []) + [f"delegated to {next_agent}"]
    return {
        "plan": plan[-6:],
        "active_agent": next_agent,
        "steps_remaining": state["steps_remaining"] - 1,
        "messages": [AIMessage(f"Supervisor routing to {next_agent}.")],
    }


def route(state: TeamState) -> str:
    if state["steps_remaining"] <= 0:
        return "end"
    return state["active_agent"]


def researcher(state: TeamState):
    note = f"Researcher found sources for: {state['messages'][-1].content[:80]}"
    return {"messages": [AIMessage(note)]}


def analyst(state: TeamState):
    note = "Analyst computed figures from the retrieved numbers."
    return {"messages": [AIMessage(note)]}


def writer(state: TeamState):
    draft = "Draft answer composed from the research and analysis above."
    return {"messages": [AIMessage(draft)]}


builder = StateGraph(TeamState)
builder.add_node("supervisor", supervisor)
builder.add_node("researcher", researcher)
builder.add_node("analyst", analyst)
builder.add_node("writer", writer)
builder.add_edge(START, "supervisor")
builder.add_conditional_edges(
    "supervisor",
    route,
    {
        "researcher": "researcher",
        "analyst": "analyst",
        "writer": "writer",
        "end": END,
    },
)
for name in ("researcher", "analyst", "writer"):
    builder.add_edge(name, "supervisor")

team = builder.compile()

Every specialist returns to the supervisor, never to another specialist. That single rule is what keeps the topology auditable: control flow always passes through one node whose job is to decide, so a debugger or a log reader always knows where the next decision came from.


Passing work without losing it

Handoffs between agents fail in predictable ways. The receiving agent gets the final message only and misses the constraints stated five turns earlier. Or it receives the entire transcript including another agent's internal notes, which pollutes its context and raises cost. Or two agents write to the same key in state and the later write silently wins.

The fix is a small, explicit contract for what crosses a boundary. Send the user's original ask, the decisions already made, and the artifacts produced so far, trimmed to what the next role needs. Do not send intermediate tool dumps; if the next agent needs a fact from a search result, the current agent should extract that fact and pass it as a sentence.

python
def make_handoff(from_role: str, to_role: str, budget: int = 3):
    def handoff(state: TeamState) -> dict:
        prior = [m.content for m in state["messages"] if isinstance(m, AIMessage)]
        summary = " | ".join(prior[-budget:])
        packet = {
            "from": from_role,
            "to": to_role,
            "original_ask": state["messages"][0].content,
            "decisions_so_far": summary,
        }
        return {
            "messages": [AIMessage(f"Handoff to {to_role}: {packet}")],
            "active_agent": to_role,
        }
    return handoff

That function is intentionally boring. Its value is that the handoff payload has one definition, so when the writer starts hallucinating constraints that were never given, you have a single place to inspect and to tighten.


Observability across a team

Debugging a multi-agent system is harder than debugging a single agent, because a wrong answer may start in any of four places: the user's question was misread, the supervisor routed it badly, the specialist executed its tools incorrectly, or the final composition discarded what the specialist found. Without instrumentation you are guessing between those four, and the guess is usually wrong.

The minimum useful instrumentation is a structured log entry per node invocation containing the thread identifier, the node name, the routing decision, the length of the incoming and outgoing state, and a hash of the handoff payload. That last field is the one people leave out and later regret: when a writer agent contradicts a researcher's findings three hops earlier, the payload hash tells you whether the facts ever crossed the boundary intact.

Trace every run through a single identifier, from the user's message to the final composed answer, so a support question or a failed test can be replayed end to end. Treat the plan key in state as part of that trace rather than as a prompt artifact, because it is the only record of why the supervisor chose the specialist it chose. Teams that skip this step end up rewriting routing logic every time an answer goes wrong, since no one can prove which hop was responsible.

Coordination cost, and when not to split

Multi-agent systems carry three taxes. Latency multiplies, because each hop is at least one model call. Cost multiplies similarly, because each agent resends whatever context it was given. And failure modes compound, because a routing mistake sends the question to a competent agent that is simply the wrong specialist, producing an answer that sounds fine and addresses the wrong task.

SymptomLikely causeFirst fix
Correct specialist, wrong answerContext packet too thinSend original ask and prior decisions
Wrong specialist consistentlyRole descriptions overlapRewrite role boundaries before adding agents
Latency doubles for simple asksSupervisor delegating trivial turnsLet supervisor answer directly when no tool is needed
Agents contradict each otherShared mutable state keyGive each role its own state keys

The honest checklist for whether to split is short. Split when tool sets genuinely do not overlap. Split when the system prompt each role needs would fight the others. Do not split to simulate parallelism that you have not measured, and do not split because the diagram looks impressive. A single agent with five well-written tools and a clear prompt outperforms a three-agent team with muddy boundaries almost every time, and it is cheaper to run, cheaper to test and easier to explain to whoever has to maintain it after you.

💡Start with one agent and a journal

Before building the team, log every tool call the single agent makes for a week. Roles emerge from that log with real evidence behind them, rather than from a guess about what the architecture should look like.

Common Mistakes

Splitting into agents that share the same tools and nearly the same system prompt

Fix: Require every role to differ in both tools and stated purpose; merge any two that would not

Letting specialists call each other directly in arbitrary topologies

Fix: Route every handoff back through the supervisor so control flow stays auditable

Passing the raw transcript, including tool dumps, across a handoff

Fix: Send the original ask, the decisions made, and extracted facts only, with a fixed budget on length

Giving the supervisor tools of its own

Fix: Keep the supervisor's job as routing and composing; a tool-wielding supervisor will bypass the team under time pressure

Best Practices

  • Write role descriptions that name both what the agent does and what it must refuse to do
  • Give every role its own state keys so updates cannot silently overwrite each other
  • Return every specialist to the supervisor; keep the graph a star, not a mesh
  • Measure latency and cost per turn after any split, and be willing to merge roles that did not pay for themselves
  • Log the routing decision and the handoff payload together, so wrong answers can be traced to either

Interview Questions

Q1: What distinguishes a supervisor architecture from a handoff architecture?

In a supervisor architecture every delegation and every reply passes through one coordinating agent, which makes routing decisions easy to audit. In a handoff architecture agents pass control directly to each other, which is more flexible but spreads responsibility across the graph.

Q2: Why should the supervisor hold no tools?

A supervisor with tools will sometimes solve the problem itself instead of delegating, which brings back tool-selection ambiguity and makes the team's behavior harder to predict and to test.

Q3: How do you decide how much context to send across a handoff?

Send the original user ask, the decisions already committed, and the specific facts the next role needs. Exclude intermediate tool output and internal notes, which add cost without adding decisions.

Q4: What is the most common sign that a multi-agent split was premature?

The wrong specialist answers confidently, or every turn bounces through routing to reach an agent that shares tools with its neighbors. Both point to role boundaries that were drawn before the work was understood.

Key Takeaways

  • Split agents when tool sets and prompts genuinely conflict, not to simulate parallelism
  • The supervisor routes and composes; it should not execute tools itself
  • Keep the graph a star: specialists always return to the supervisor
  • Handoff payloads should be explicit, small, and defined in one place
  • Every shared state key needs a reducer or a clear owner
  • Measure latency and cost after each split, and merge roles that did not earn their hop
  • Log routing decisions alongside answers so wrong-specialist bugs are visible
CW

ChatWhole Learn Editorial Team

Written by experienced data scientists, software engineers, and educators. All content is reviewed by industry professionals to ensure accuracy and relevance.

Last reviewed: 2026-10-13

—
☆☆☆☆☆
0 ratings

Rate & Feedback

Continue Learning

Suggested next tutorials based on this topic

Need Expert AI Agents Beginner Help?

Get personalized tutoring, project support, or professional consulting.

Advertisement