The supervisor

This is where AutoGen actually pays for itself. Instead of one agent with every tool, you build a team: a booking specialist, a search specialist, a support specialist. A supervisor reads the user message and picks who should answer.

Supervisor routing in GroupChat

The supervisor inspects each user message and hands it to the right specialist. Specialists only see their own tools.

service.py
python
booking_agent = AssistantAgent(
    name="booking_agent",
    model_client=create_model_client(),
    system_message=(
        "You are a booking specialist. You handle hotel, taxi, "
        "and cancellation requests. Only use your tools."
    ),
    tools=[book_hotel, book_taxi, cancel_booking],
    model_client_stream=True,
)

search_agent = AssistantAgent(
    name="search_agent",
    model_client=create_model_client(),
    system_message=(
        "You are a search specialist. You look up bookings, "
        "available hotels, and flight status."
    ),
    tools=[lookup_booking, search_hotels, check_flight_status],
    model_client_stream=True,
)

support_agent = AssistantAgent(
    name="support_agent",
    model_client=create_model_client(),
    system_message=(
        "You handle policy questions and currency conversions."
    ),
    tools=[search_policies, convert_currency],
    model_client_stream=True,
)

Each specialist has a narrow toolbox and a focused system message. The model is dramatically more reliable when it is not choosing between fourteen tools at once.

service.py
python
from autogen_agentchat.teams import SelectorGroupChat

supervisor_prompt = """You are the supervisor of a travel support team.
Given the user request, pick exactly one specialist to respond:
- booking_agent: for creating, changing, or cancelling bookings
- search_agent: for looking up existing bookings, hotels, flights
- support_agent: for policy questions or currency conversion

Return only the agent name. Do not explain."""

team = SelectorGroupChat(
    participants=[booking_agent, search_agent, support_agent],
    model_client=create_model_client(),
    selector_prompt=supervisor_prompt,
    max_turns=5,
)

SelectorGroupChat replaces round-robin with LLM-based routing. The selector_prompt is the supervisor. Every turn, the framework asks the selector which participant should speak next.

You can, and for narrow domains you should. A keyword router is cheap and deterministic. An LLM supervisor earns its cost when intents overlap, when users mix multiple requests in one message, or when you want a handoff mid-conversation based on what an earlier agent returned. Most production systems use a hybrid: cheap router for the easy 80%, LLM supervisor for the messy tail.

Quiz: Quiz

Loading practice…

Checkpoint: Orchestration checkpoint

Loading practice…