Course Content
AutoGen Essentials
7 sections · 28 lessons
How do you define agent roles and prompts so multiple agents avoid overlap and endless conflict?
What you need to know
Two different texts per agent
Every AutoGen agent has two pieces of text, and they have different readers:
| Field | Who reads it | What it should say |
|---|---|---|
system_message | The agent's own model | How to do the job, what not to do, the output format |
description | The speaker selector (SelectorGroupChat, or 0.2 GroupChat in "auto" mode) and other agents | When this agent should speak next |
Most people copy the system message into description, or leave the default. Then the selector has to guess, and it picks the wrong agent.
Five rules for non-overlapping roles
- One responsibility, stated first. "You write Python. You do not run it and you do not review style."
- Name the exclusions. In a group chat, the "do not" half of the prompt prevents more trouble than the "do" half.
- An output contract. Each agent produces something the next one can parse: a numbered plan, a JSON object,
APPROVED. - A bounded critic. "At most three issues, and only ones that change correctness." An unbounded critic always finds something.
- A decider. When two agents disagree, one of them (or a human) has the final word, and the loop has a cap anyway.
What it looks like in code (0.4+)
1flights = AssistantAgent(2 "flights", model_client=client, tools=[search_flights],3 description="Pick me when the plan needs flight options or prices.",4 system_message=(5 "You find flights only. Return at most 3 options as JSON with "6 "airline, depart, arrive, price_inr. Do not suggest hotels, "7 "trains or itineraries."8 ),9)10hotels = AssistantAgent(11 "hotels", model_client=client, tools=[search_hotels],12 description="Pick me when the plan needs a place to stay.",13 system_message="You find hotels only. Return at most 3 options as JSON. "14 "Do not change dates or suggest transport.",15)Notice the description is written as "pick me when…", and the system message ends with the exclusions. Each agent's tools match its job, so even a confused agent cannot book the other's work.
Where conflict really comes from
- Shared goals with no owner. Two agents both "improve the plan" and undo each other's edits.
- Critic without an exit. The writer keeps changing wording to satisfy vague feedback.
- No tiebreak. The last agent to speak wins, which is random.
A real-life example
A travel-planning team had four agents: planner, flights, hotels, budget. Users kept getting itineraries with two different arrival times. The trace showed why: planner and flights both wrote travel legs, and hotels also suggested "take the 6 am Shatabdi" because its prompt said "help plan the stay". Round after round, they overwrote each other.
The fix took one afternoon:
plannerbecame the only agent allowed to write the day-by-day plan.flightsandhotelsreturned options as JSON only, with "do not suggest transport or itineraries".budgetgot a contract:APPROVED, or the rupee amount over budget and which line to cut.plannerwas named the decider; after two budget rounds it ships the cheapest valid plan.
Conflicting arrival times went from 1 in 6 runs to none in 50 test runs, and the average run fell from 14 messages to 8.
Follow-up questions to expect
- "How do you check that roles do not overlap?" — Read each system prompt alone and ask whether it could do another agent's job. Then check traces: if two agents produce the same kind of output, merge or narrow them.
- "Should agents know about each other?" — A planner or coordinator should list the team and what each member does. Workers usually should not; they only need their own job.
- "What if agents still disagree?" — Let the named decider pick using evidence (test results, budget numbers), and cap the rounds so disagreement ends in a decision or an escalation, never in a loop.