Zenaique

Walk through AutoGen GroupChat handoffs between UserProxyAgent and AssistantAgent

Flashcard·Medium·4.0 · 0·~30s·Asked atHugging FaceKpmgPolyai
Attempt it
TL;DR

AutoGen routes every turn through a GroupChatManager whose select_speaker policy chooses the next agent; the UserProxyAgent doubles as the human stand-in and the tool executor.

Memory aid
Sign in to see the mnemonic that makes this stick.
Easy to grasp

Picture a small meeting with a chairperson, a question-asker, and an expert. The chairperson never answers questions. They just point at whoever should speak next. The question-asker raises their hand and asks something. The chair points at the expert. The expert says, 'I need to look that up in the filing cabinet first,' so the chair points back at the question-asker, who in this room is also the person who can open the cabinet. They read out what they found, the chair points at the expert again, and the expert gives the final answer. Everyone hears every word; nothing is whispered. The meeting ends when someone says the magic stop phrase.

Concept explanation~2 min read

Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.

AutoGen's GroupChat is the framework's answer to the question, 'How do I let several conversable agents share one conversation without inventing my own message bus?' The answer is a small, opinionated routing layer: a GroupChatManager that picks the next speaker on every turn, plus a shared list of messages that every participant sees.

The canonical example pairs a UserProxyAgent with an AssistantAgent. That pair is small enough to inspect end to end, but it already exposes every load-bearing concept in the framework: speaker selection, the dual role of the UserProxyAgent, the shared-history invariant, and termination signalling.

The GroupChatManager is a router, not a thinker

The GroupChatManager does not produce answers. Its job, per turn, is to look at the current message list and the list of participating agents and call select_speaker(messages, agents). The result is a single agent reference, which the manager then asks for a reply. That reply gets appended to the shared messages and the loop repeats.

The three speaker-selection policies

AutoGen ships three out of the box policies, configured via speaker_selection_method.

  • Round-robin. Deterministic rotation through chat.agents. Cheapest, used when the topology is fixed.
  • LLM-driven. The manager makes its own LLM call with a small selection prompt, asking the model to pick the next agent. Most flexible, costs an extra inference per turn.
  • Manual / callable. You pass a Python function that returns the next agent. Used when routing must follow business logic that an LLM cannot be trusted to enforce.

The choice is a real architectural commitment. LLM-driven selection is what makes GroupChat feel agentic, but it also makes the chat non-deterministic and adds latency.

Why the UserProxyAgent has two jobs
The single-turn flow, step by step
Shared history, termination, and the cost shape
Sign in to unlock the full deep dive.

Situations where this technique stops working.

Sign in to see when this approach fails.

2–4 min · Everything important, quickly.

Sign in to see the quick scan of the deep dive.
python
from autogen import AssistantAgent, UserProxyAgent, GroupChat, GroupChatManager

assistant = AssistantAgent(
    name="assistant",
    llm_config={"model": "claude-sonnet-4-6"},
)
user = UserProxyAgent(
    name="user",
    human_input_mode="NEVER",
    code_execution_config={"work_dir": "runs", "use_docker": True},
    is_termination_msg=lambda m: "TERMINATE" in m.get("content", ""),
)

chat = GroupChat(agents=[user, assistant], messages=[], max_round=12)
manager = GroupChatManager(groupchat=chat, llm_config={"model": "gpt-5.5"})

user.initiate_chat(manager, message="Compute the SHA-256 of 'autogen'. End with TERMINATE.")

Real products, models, and research that use this idea.

  • Microsoft Research's original AutoGen paper, which introduced GroupChat as a generalisation of two-agent chat for conversable multi-agent programs.
  • AutoGen Studio (the no-code UI shipped by the AutoGen team) exposes the speaker-selection policy directly as a dropdown, illustrating how central the routing primitive is.
Sign in to see more production examples.

What an interviewer would ask next. Try answering before peeking at the approach.

QHow would you implement a custom select_speaker that always routes tool outputs back to the assistant?
A

Inspect the last message: if it carries a tool_response role, return the AssistantAgent; otherwise fall back to round-robin among remaining agents.

2 more follow-ups an interviewer would ask next. Sign in to reveal them.

Red flags & common mistakes

The phrases that signal junior thinking. Click to expand.

Most common mistake

Treating the UserProxyAgent as only the human relay and forgetting it is also the side that runs tool calls. So disabling code execution silently breaks every tool-using turn.

Sign in to see all red flags and common mistakes.

60 second bullets to scan on the way to the call.

  • Role of the GroupChatManager versus the participating agents

  • The three speaker-selection policies and when each fits

Sign in to unlock the revision sheet.

Primary sources. Browse if you want the original framing.

Similar questions

Same topic, related formats. Practice these next.

4 curated
Next question
Design a sensible migration…
Short answer·Hard