Skip to content

Module 06 · Lesson 6.2

Supervisor, Specialist and Handoff Patterns

40 minUpdated 18 Nov 2026Part of Multi-Agent Systems and Orchestration · AI Agent Development
On this page
  1. What you will learn
  2. The three roles: supervisor, specialist and handoff
  3. The Quillfeather split: one supervisor, two specialists
  4. Supervisor, pipeline and peer handoff: three patterns compared
  5. Why routing must return a fixed value that code checks
  6. A checked router in a few lines of Python
  7. Choosing a pattern and passing the case with context
  8. Conclusion and your next step
  9. Common errors and fixes
  10. Validation checklist
  11. Hands-on exercise
  12. Knowledge check
  13. Frequently asked questions
  14. References

Picture a hospital front desk. The person at the desk does not treat anyone. They listen, decide whether you need the eye clinic, the X-ray room or a doctor, and send you there. Each clinic knows its own job well. If the desk sends you to the wrong place, the clinic should say so instead of guessing.

Multi-agent systems often work the same way. In this lesson you learn four common patterns: supervisor and specialists, pipeline, peer handoff and a plain single agent for comparison. You also learn one rule that matters more than the pattern: the supervisor must answer with a fixed value that your code checks. Most of the lesson needs no coding. One short Python example shows the check.

What you will learn

  • Describe the roles of a supervisor, a specialist and a handoff.
  • Choose between supervisor, pipeline and peer handoff for a given task.
  • Explain why routing must return a fixed value that code checks.
  • Run a Python example that rejects any route outside an allowed list.

Before you start

  • When Multi-Agent Architecture Is Worthwhile, the previous lesson. It explains when a split is justified.
  • No coding experience is needed for most of this lesson.
  • Optional: Python 3.10 or later, if you want to run the example yourself.

The three roles: supervisor, specialist and handoff

A supervisor is an agent that decides who works next. A specialist is an agent with a narrow job and a small set of tools. A handoff is the moment the case moves from one agent to another, together with what is known so far.

The key rule is about the supervisor: it routes, it does not do the work. If the supervisor also answers questions and calls tools, it becomes a big single agent with extra steps. Keeping it small makes it cheap, easy to test and hard to trick.

RoleDoesDoes not
SupervisorReads the customer message and picks one route.Call business tools or write the final answer.
SpecialistHandles one kind of task with its own instructions and tools.Decide that another specialist should take over, unless the design allows it.
Your code (orchestrator)Runs the supervisor, checks its answer, starts the specialist and counts handoffs.Make judgement calls about meaning. That is the model's job.
The orchestrator is ordinary program code that connects the agents. It is not another AI model.

The Quillfeather split: one supervisor, two specialists

In the lab at the end of this module you will split the Quillfeather support agent from Module 4. Here is the plan, in plain words.

  • supervisor reads the customer message and answers with one route: orders, help or person. It has no tools.
  • orders_specialist handles order questions and returns. Its tools are lookup_order and request_return.
  • help_specialist answers help-centre questions. Its only tool is search_help.
  • Route person means the case goes to a human, such as a customer who asks for a manager.
One customer message, one route, one specialist
  1. Customer message

    "Where is QF-1042?"

  2. Supervisor

    Returns one route: orders, help or person

  3. Route check (code)

    Rejects anything not on the allowed list

  4. Specialist

    orders_specialist or help_specialist, with its own tools

  5. Reply

    Final answer, or a handover to a person

Your code checks the route before any specialist starts.

Notice what this split gives you. The help_specialist has no write tool, so even a poisoned help page cannot create a return. The orders_specialist never loads the help pages, so its context stays small. These are the benefits from the previous lesson, made concrete.

Supervisor, pipeline and peer handoff: three patterns compared

There is more than one way to connect agents. Each pattern answers a different question: who decides what happens next?

Pattern 1: supervisor and specialists

One agent routes, others work. The supervisor decides each time. This is the pattern in the Quillfeather split. It fits tasks where the type of request varies and each type needs different tools.

Pattern 2: pipeline (sequential)

Agents run in a fixed order, like stations on a bakery line: one mixes, one bakes, one packs. Each agent receives the previous agent's result. Nobody chooses the next step because the order is written in code. It fits tasks that always follow the same stages, such as draft, check, then format.

Pattern 3: peer handoff

There is no supervisor. A specialist decides when to pass the case to another specialist. For example, the help specialist notices that the customer wants to return an order and hands the case to the orders specialist. This is flexible, but harder to control, because any agent can start a handoff. It needs strict limits, which the lesson Avoiding Infinite Loops and Unnecessary Agent Handoffs covers.

PatternWho decides what is next?Best whenMain risk
Supervisor and specialistsThe supervisor, every time.Requests vary in type and each type needs different tools.A wrong route. Cost of the extra routing call.
PipelineYour code, in a fixed order.Work always goes through the same stages.One bad stage spoils everything after it.
Peer handoffEach specialist for itself.Tasks drift naturally from one role to another.Ping-pong between agents and weak control.
Single agentThe one agent.One kind of work and one toolset.A large instruction text and a wide toolset.

Why routing must return a fixed value that code checks

A model writes text. Even if you ask it to answer with one word, it may write "Orders." or "I think this is a billing question." If your program then looks for an agent with that name, it fails, or worse, it picks the wrong one.

The fix is the same idea you met in System Instructions, Role, Constraints and Output Contracts: an output contract. Define the allowed routes in code. Ask the supervisor for a structured answer such as {"route": "orders"}. Then check that the value is on the list before you act on it.

  • Allowed values live in code, not only in the prompt.
  • Anything that is not on the list is rejected.
  • The safe default for a rejected route is person, because a human can sort it out.
  • Log the rejected value so you can improve the prompt later.

A checked router in a few lines of Python

The script below uses a small keyword function as a stand-in for the supervisor model, so it runs offline and gives the same answer every time. In the lab you will replace it with a real model call. The part to study is route(), which checks the answer.

Pythonroute.py
ALLOWED_ROUTES = ("orders", "help", "person")


def keyword_supervisor(message):
    text = message.lower()
    if "qf-" in text or "my order" in text or "return" in text:
        return "orders"
    if any(word in text for word in ("warranty", "size", "delivery take", "brake")):
        return "help"
    return "person"


def chatty_supervisor(message):
    return "I think this is a billing question."


def route(message, supervisor):
    raw = supervisor(message).strip().lower()
    if raw in ALLOWED_ROUTES:
        return raw, "ok"
    return "person", "rejected " + repr(raw)


messages = [
    "Where is QF-1042?",
    "What size frame fits a 170 cm rider?",
    "How long does standard delivery take?",
    "I want to speak to the manager.",
]
for message in messages:
    chosen, why = route(message, keyword_supervisor)
    print(message, "->", chosen, "(" + why + ")")
print("--- a supervisor that breaks the rules ---")
chosen, why = route(messages[0], chatty_supervisor)
print(messages[0], "->", chosen, "(" + why + ")")

Runs offline with Python 3.10 or later. Save it and run python route.py.

What each part does

  • ALLOWED_ROUTES is a tuple, a fixed list that cannot change. It holds the only three values the program accepts.
  • keyword_supervisor pretends to be the model. It looks for words in the message and returns one route.
  • chatty_supervisor pretends to be a model that ignored the output contract. It returns a sentence instead of a route.
  • route(...) is the check. It cleans the answer with .strip().lower(), which removes spaces and capital letters.
  • if raw in ALLOWED_ROUTES accepts the value only when it is on the list. Otherwise the function returns person and a reason that starts with "rejected".
  • The for loop sends four sample messages through the router. The last two lines show a broken supervisor being caught.
OutputCaptured from a real run
Where is QF-1042? -> orders (ok)
What size frame fits a 170 cm rider? -> help (ok)
How long does standard delivery take? -> help (ok)
I want to speak to the manager. -> person (ok)
--- a supervisor that breaks the rules ---
Where is QF-1042? -> person (rejected 'i think this is a billing question.')

Choosing a pattern and passing the case with context

A good handoff passes enough for the next agent to start work, and not more. At minimum, pass the customer's message, any facts already found (such as the order id) and a short note about why the handoff happened. The next lesson, Shared State and Inter-Agent Communication, shows a fixed format for this.

  1. Step 1: List the kinds of request

    For Quillfeather these are order questions, help questions and anything else.

  2. Step 2: Check whether the order of work is fixed

    If every task goes through the same stages, use a pipeline. If the type varies, use a supervisor.

  3. Step 3: Give each specialist only what its job needs

    Its own tools, its own short instructions and its own context.

  4. Step 4: Write the allowed routes in code

    Include person as the safe exit.

  5. Step 5: Decide how a handoff ends

    A specialist returns a result to the orchestrator. It does not secretly start the next agent unless your design says so.

Conclusion and your next step

A supervisor routes, a specialist works and a handoff passes the case on. Pick a supervisor when request types vary, a pipeline when stages are fixed, and peer handoff only with strict limits. Whatever the pattern, make routing return a fixed value and check it in code.

Your next step: sketch the Quillfeather split on paper with the routes orders, help and person, and write one sample customer message for each route. Then continue to Shared State and Inter-Agent Communication, where you define the message and case record that agents share.

For more on tool permissions, see Authentication, Secrets and Least-Privilege Access. For parallel steps, see Sequential, Parallel and Conditional Tool Execution.

Common errors and how to fix them

The supervisor starts answering customer questions itself.

Why it happens: Its instructions or tools let it do the work, so it is no longer only a router.

Fix: Give the supervisor no business tools and ask only for a route. Let specialists write the reply.

The program crashes or picks the wrong agent when the supervisor replies with a sentence.

Why it happens: The route was used directly, without checking it against a list.

Fix: Check every route against the allowed list in code and fall back to person.

Specialists keep passing the case to each other.

Why it happens: Peer handoff was used without limits.

Fix: Prefer a supervisor, or add a handoff limit and a repeat check. The next lessons cover both.

The specialist asks the customer for the order number again.

Why it happens: The handoff did not include facts the supervisor already had.

Fix: Pass the message, the facts found so far and a short reason with each handoff.

Validation checklist

Tick each item once you have confirmed it.

Hands-on exercise

Add a fourth route to the router

Change route.py so that delivery-address questions go to a new route called address. Keep the check in route() working.

You will need

  • The route.py file from this lesson.
  • A new sample message: "Can I change the delivery address for QF-1042?"

Acceptance criteria

Your work is done when every one of these is true.

Hints (3)
  • Put the address check before the order check, because the new message also contains "qf-".
  • Add a keyword such as "address" and test your change on all five messages.
  • The list in code is the single source of truth. A value outside it fails the in test.
Show a model answer

Add "address" to the tuple. In keyword_supervisor, add an early check: if "address" in text, return "address". It must come first, otherwise the message is caught by the "qf-" rule and goes to orders. The chatty supervisor still fails, because its sentence is not in the list. A route that is missing from ALLOWED_ROUTES is rejected because the check compares the supervisor's answer with the list and nothing else. This is the point of the pattern: the program decides what is allowed, and the model only chooses among those options.

Knowledge check

Choose an answer, then check it. Nothing is recorded — this is for you.

  1. 1.What should a supervisor agent do?
    Show the answer and explanation

    Answer: B. A supervisor routes. If it also does the work, you have a large single agent with an extra step. Reviewing replies can be a useful separate role, but it is not what a routing supervisor is for.

  2. 2.The supervisor returns "I think this is a billing question." What does your code do?
    Show the answer and explanation

    Answer: B. Only values on the allowed list are accepted. Searching free text for a route name is tempting, but it lets a model or a customer steer the program with loose wording.

  3. 3.Work always goes through three stages in the same order: draft, check, format. Which pattern fits best?
    Show the answer and explanation

    Answer: B. A fixed order needs no decision, so code can run the stages in sequence. Peer handoff adds freedom you do not need and makes the flow harder to control.

Frequently asked questions

What is a supervisor agent?

It is an agent whose only job is to decide which other agent should handle a request. It reads the message and returns a route such as orders or help. It does not use business tools or write the final answer.

What is an agent handoff?

A handoff is when one agent passes a task to another agent, along with what it knows so far. In a good design the handoff is a structured message that your code checks, not free text.

What is the difference between a supervisor and a pipeline?

In a supervisor design, an agent chooses the next step each time. In a pipeline, the order is fixed in code, so no agent has to choose. Use a pipeline when the stages never change.

Why not let the model choose any agent name it likes?

Models can write unexpected text, and customers can try to steer the model. A fixed list of allowed routes, checked in code, means the program only ever goes to places you chose.

Written by
PromptFable Editorial
Last updated 18 Nov 2026
Review
Reviewed by Waseem Nadir, Technical Reviewer
Last reviewed 27 Nov 2026

References

Primary sources for the technical details in this lesson. Vendor platforms change — check the official page if anything here looks different from what you see.

PromptFable is independent and is not affiliated with, endorsed by or sponsored by Anthropic, Google, OpenAI or any other vendor. Claude, Gemini, Google AI Studio and other product names are trademarks of their respective owners.