How to Build a Two-Agent Team With Microsoft AutoGen

November 13, 2026

A minimal two-agent AutoGen team is about 25 lines: define a model client, create an assistant and a reviewer agent, put both in a RoundRobinGroupChat, and run it with a max_turns limit. Without a turn cap and a termination condition, the two agents will politely thank each other until you hit the token budget.

AutoGen is Microsoft Research’s framework for multi-agent conversation. Version 0.4 was a substantial rewrite: the old ConversableAgent API from most tutorials still works but is now the legacy path, and the new autogen-agentchat package is what new code should use.

What problem does AutoGen actually solve?

It gives you a way to run several LLM agents in a controlled conversation, where each agent has its own role and tools, and a manager decides who speaks next.

The practical value is review. One agent drafts, another critiques, the loop runs until a quality bar or a turn limit is hit. This produces better output than one prompt asking a model to check its own work, because the critic agent has a different system prompt and no investment in the draft.

Where it does not help: simple single-shot tasks. Two agents talking costs roughly twice the tokens and twice the latency for a task one good prompt completes.

How do you install the current version?

Install the new packages, not the old autogen package. The split matters — old tutorials will have you pip installing something that resolves to the legacy codebase.

  1. pip install autogen-agentchat autogen-ext[openai]
  2. Set OPENAI_API_KEY in your environment
  3. Import from autogen_agentchat.agents and autogen_agentchat.teams

If you are on Azure OpenAI, use the Azure client from autogen_ext.models.azure instead of the plain OpenAI one. The model client interface is the same after that point.

How do you define the two agents?

The system prompt is the entire design. Two agents with vague prompts behave like one agent with a vague prompt, only slower and more expensive.

A pair that works for writing tasks:

  • Writer — “You draft marketing copy. Output only the draft, no preamble, no explanation of your choices.”
  • Reviewer — “You critique drafts against a rubric: clarity, specificity, and whether every claim has a number or a named source. Reply with at most three issues and a verdict of APPROVE or REVISE.”

The “at most three issues” constraint is doing real work. Unbounded critique produces an endless list of nitpicks, and the writer agent spends its turns addressing style rather than substance.

The APPROVE / REVISE verdict is what makes termination possible.

How do you stop the conversation?

Two mechanisms, and you want both.

A MaxMessageTermination caps the total messages — set it to 6 for a two-agent review loop. That is a safety net.

A text-based termination watches for the verdict string, TextMentionTermination("APPROVE"). That is the normal exit.

Combine them with an | operator so either one ends the run. Without the text condition the loop always burns all six turns; without the count condition a reviewer that never approves runs until you kill the process.

A third option, HandoffTermination, is useful when a human needs to step in. It pauses the run and returns state you can resume later, which is the pattern for approval workflows.

What does the run cost?

Roughly the sum of every message in the conversation, not just the final answer. A six-turn review loop with a 2,000-token draft and a 500-token critique per turn lands around 15,000-25,000 input tokens because each turn resends history.

At GPT-4o-mini pricing that is fractions of a cent. At a frontier model it is a few cents per run. Multiply by a batch of 500 documents and the difference between a sensible model choice and a careless one is real money.

Use a cheap model for the reviewer and a stronger one for the writer. The reviewer’s job is structured critique; it does not need the best reasoning.

Where does a two-agent setup break down?

Agreement loops. Two agents with similar prompts converge on the same wrong answer and both approve it. The critic needs a distinctly different instruction, ideally a rubric the writer cannot see.

Tool access is the other trap. Give the writer a file-write tool without a sandbox and it will happily overwrite things. Run AutoGen in a container when tools touch the filesystem.

And observability. Two agents produce interleaved messages that are hard to read after the fact. Log every message with the speaker name to a file; debugging a bad run from console output alone is miserable.

Who should use AutoGen?

Engineering teams building agent pipelines with code-level control: document processing at volume, code review bots, research workflows with tool use. People comfortable reading framework source when the docs thin out.

Not for non-developers. If you want agents without Python, a no-code platform is the right choice and will get you further in a week. Skip AutoGen entirely if your task is one prompt deep — a single call with a good system prompt beats a two-agent loop on cost, latency and debuggability.

Quick Summary

  • Install autogen-agentchat plus autogen-ext; the 0.4+ API replaces the old ConversableAgent pattern.
  • Two agents work: a writer with a terse prompt, a reviewer with a rubric and a verdict.
  • Always combine a max-turn cap with a text termination.
  • Cost scales with total conversation length, roughly 15,000-25,000 tokens per six-turn review.
  • Use a cheap model for the critic, a stronger one for the writer.
Tags: