Velamuvi AIAcademy
AutoGen

Lesson 1 of 6 · AutoGen

What Is AutoGen?

What AutoGen is: Microsoft's multi-agent conversation framework, its history from 0.2 to 0.4, its building blocks, why it's archived and what replaced it.

  • 7 min read
  • Intermediate
  • Reviewed
In this lesson you will learn
  • Explain AutoGen's core idea: agents that solve tasks by conversing
  • Describe its packages and building blocks: agents, teams, termination and code executors
  • Know the project's status and its successor, Microsoft Agent Framework
  • Run a first AutoGen agent

Agents that talk to each other

AutoGen came out of Microsoft Research in 2023 with a simple, influential idea: build multi-agent applications as conversations. Each agent reads the messages so far and adds its own: a writer drafts, a critic comments, a coder writes code, an executor runs it and reports the result. The conversation itself drives the work, until a termination condition ends it.

Here is the core loop in plain Python: two agents take turns until the critic approves or a message limit is reached:

Try it yourselfPython
# AutoGen's core idea, in plain Python: agents solve a task by TALKING. Each agent reads the
# conversation so far and adds a message; the conversation ends when a termination condition is met.
def writer(conversation):                    # stands in for an LLM-backed agent
    drafts = ["Ride further, worry less.", "Ride further. Worry less. Smile more."]
    return drafts[sum(1 for who, _ in conversation if who == "writer")]

def critic(conversation):
    return "Too plain; add rhythm." if conversation[-1][1].startswith("Ride further,") else "APPROVE"

def should_stop(conversation, max_messages=8):
    return "APPROVE" in conversation[-1][1] or len(conversation) >= max_messages

conversation = [("user", "Write a slogan for a city e-bike.")]
agents = [("writer", writer), ("critic", critic)]
turn = 0
while not should_stop(conversation):
    name, agent = agents[turn % len(agents)]          # round robin: take turns in a fixed order
    conversation.append((name, agent(conversation)))
    turn += 1

for who, text in conversation:
    print(f"{who:>6}: {text}")

That's the shape of everything in this course: agents, a rule for who speaks next, and a rule for when to stop.

Project status: read this first

So why learn it? Because its ideas are everywhere: conversable agents, group chats with speaker selection, termination conditions and code-executing agents shaped how many later frameworks work, including its successor. And if you join a team with an AutoGen system, you'll need to read, maintain and eventually migrate it. Throughout this course, “Today” notes point out how Microsoft Agent Framework handles the same idea. The last lesson covers AutoGen's status, its limitations and how to migrate in detail.

The packages

AutoGen's 0.4 release (early 2025) was a full redesign of the original 0.2 version, built around asynchronous messages:

PackageWhat it contains
autogen-agentchatThe high-level API used in this course: agents, teams and termination conditions
autogen-coreThe event-driven runtime underneath, for advanced custom systems
autogen-extExtensions: model clients (OpenAI, Anthropic, Azure and others), code executors, tools

Code written for 0.2, with classes such as ConversableAgent and GroupChat, looks different and doesn't run on 0.4 or later. A separate community project, AG2 (pip install ag2), describes itself as formerly AutoGen and has since developed its own API.

Your first agent

pip install -U "autogen-agentchat" "autogen-ext[anthropic]"
import asyncio
from autogen_agentchat.agents import AssistantAgent
from autogen_ext.models.anthropic import AnthropicChatCompletionClient

async def main():
    model_client = AnthropicChatCompletionClient(model="MODEL_NAME")   # reads ANTHROPIC_API_KEY
    guide = AssistantAgent(
        "travel_guide",
        model_client=model_client,
        system_message="You are a concise travel guide for Portugal.",
    )
    result = await guide.run(task="Suggest one day trip from Lisbon.")
    for message in result.messages:
        print(f"{message.source}: {message.content}")
    await model_client.close()

asyncio.run(main())
Output
user: Suggest one day trip from Lisbon.
travel_guide: Sintra: palaces, gardens and forest trails, about 40 minutes by train from Rossio.

AutoGen is asynchronous: agents are run with await agent.run(...) inside an async function, started with asyncio.run(main()). The result holds every message of the run, each with its source (who said it). Replace MODEL_NAME with a current model name from your provider; autogen-ext also has clients for OpenAI, Azure OpenAI, Ollama and others.

Common mistakes

Practice exercise

Write a termination condition: AutoGen conversations need a rule that ends them, combining a stop word with a message limit.

Your solutionPython
def should_stop(messages, max_messages=6, stop_word="TERMINATE"):
    # Return a reason string if the conversation should end, otherwise None:
    # "max messages" if there are max_messages or more messages,
    # "stop word" if the last message contains stop_word.
    # (Check max messages first.)
    pass

print(should_stop(["task", "draft", "feedback"]))
print(should_stop(["task", "answer: 42. TERMINATE"]))
print(should_stop(["m"] * 6))
Knowledge check

What is AutoGen's core idea for multi-agent applications?

Summary

  • AutoGen builds multi-agent applications as conversations between agents.
  • Its building blocks: agents, teams that decide who speaks next, termination conditions and code executors.
  • 0.4 redesigned the 0.2 API; packages are autogen-agentchat, autogen-core and autogen-ext.
  • The project is archived: learn it for concepts and existing systems, and use Microsoft Agent Framework for new work.
  • Agents are asynchronous: await agent.run(task=...).

Next: conversable agents.

Finished reading? Tick it off to track your progress.