Ship it

A working demo is not a production system. Before anyone depends on this, you need termination conditions, sensible limits, and a testing ritual that catches broken tool routing before users do.

service.py
python
from autogen_agentchat.conditions import MaxMessageTermination, TextMentionTermination

termination = MaxMessageTermination(max_messages=10) | TextMentionTermination("DONE")

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

Termination conditions are how you stop a runaway team. MaxMessageTermination is your safety net. A keyword termination lets an agent say "DONE" and end the conversation cleanly.

terminal
bash
# Booking intent, should route to booking_agent
curl -N -X POST http://localhost:8000/travel-support/chat/stream \
  -H "Content-Type: application/json" \
  -d '{"message": "Book the Taj Mahal Palace in Mumbai for next week"}'

# Search intent, should route to search_agent
curl -N -X POST http://localhost:8000/travel-support/chat/stream \
  -H "Content-Type: application/json" \
  -d '{"message": "What is the status of booking BK123456?"}'

# Policy intent, should route to support_agent
curl -N -X POST http://localhost:8000/travel-support/chat/stream \
  -H "Content-Type: application/json" \
  -d '{"message": "What is the cancellation policy for Indigo flights?"}'

A simple smoke test covers all three specialist paths. Run this after any change to the supervisor prompt or the tool scoping. Watch the SSE stream for the tool_name events and confirm the right agent picked up each message.

The supervisor prompt. Users will phrase things you did not anticipate, and the selector will hand the message to the wrong specialist. Treat the supervisor prompt like a classifier and add explicit examples for ambiguous intents. The second thing that breaks is tool output drift: a backend changes its response shape and your agent quotes stale data. Pin the tool contracts and log every tool result.

Quiz: Quiz

Loading practice…

AI prompt: Try it: plan your own specialist

Loading practice…