A group chat is AG2's conversation pattern for more than two agents: all agents contribute to a single conversation thread and share the same context. A GroupChatManager orchestrates it, selecting an agent to speak, broadcasting the message to the others, and repeating until the conversation stops.
Before you start
You need Python with pyautogen installed, using pip install pyautogen[openai], and an API key for your model provider. Decide the three roles first: one triage agent and two specialists, each with a one-line description the manager can read.
Create the agents and the group chat
Create a ConversableAgent for triage, one for technical support and one for general support, each with a focused system message and a description of its job. Create a GroupChat object with the agent list, an empty message list and a maximum round count, then create a GroupChatManager with the group chat and your model configuration. Give the manager a user agent to start the conversation.
Start the chat with one request and watch the routing
Start the group chat from the user agent with a single support request. Read the event log to see which agent the manager picks first and whether the triage agent routes correctly. If the wrong specialist speaks first, the agent descriptions are too vague about who handles what.
Worked example: Triage for a fictional support desk
Northwind Support is a fictional help desk. Its group chat has a triage agent, a technical agent and a general agent. The table shows three requests and where each should go.
| Request | Routed to | Why |
|---|---|---|
| The app crashes on login | Technical support agent | A crash is a technical fault |
| What are the opening hours? | General support agent | A general question |
| The invoice total is wrong | Technical support agent | A billing data fault |
Expected result (UNTESTED): each request is answered by the specialist on its route, and the manager log shows the triage agent speaking first. We checked the AG2 group chat documentation, which describes the GroupChat, GroupChatManager and the triage example, but we did not run the chat on this machine.
Limits
A group chat costs a model call per speaker turn, and a vague description can send a request to the wrong agent. Keep the agent list short: three agents are enough for a first group chat, and more agents make speaker selection harder to control.
