AutoGen: A Programming Framework for Agentic AI

AutoGen: A Programming Framework for Agentic AI

Summary

AutoGen is a versatile programming framework from Microsoft designed for building multi-agent AI applications. It empowers AI agents to operate autonomously or collaborate seamlessly with human users, streamlining the execution of complex tasks. The framework offers a layered, extensible design, providing both high-level APIs for rapid prototyping and low-level components for fine-grained control.

Repository Info

Updated on March 30, 2026
View on GitHub

Introduction

AutoGen is a powerful programming framework developed by Microsoft for creating multi-agent AI applications. It enables AI agents to act autonomously or collaborate with humans, facilitating complex task execution. While AutoGen continues to be maintained, users new to the framework are encouraged to explore the Microsoft Agent Framework, as announced in recent updates.

Installation

AutoGen requires Python 3.10 or later.

To install the core components and OpenAI client, use pip:

pip install -U "autogen-agentchat" "autogen-ext[openai]"

For a no-code GUI experience, you can install AutoGen Studio:

pip install -U "autogenstudio"

Refer to the official AutoGen documentation for detailed installation instructions and migration guides for previous versions.

Examples

Here are a few quickstart examples demonstrating AutoGen's capabilities. Remember to set your OPENAI_API_KEY environment variable before running these examples.

Hello World

Create a simple assistant agent using OpenAI's GPT-4o model.

import asyncio
from autogen_agentchat.agents import AssistantAgent
from autogen_ext.models.openai import OpenAIChatCompletionClient

async def main() -> None:
    model_client = OpenAIChatCompletionClient(model="gpt-4.1")
    agent = AssistantAgent("assistant", model_client=model_client)
    print(await agent.run(task="Say 'Hello World!'"))
    await model_client.close()

asyncio.run(main())

Web Browsing with MCP Server

Create a web browsing assistant agent that utilizes the Playwright MCP server.

# First run `npm install -g @playwright/mcp@latest` to install the MCP server.
import asyncio
from autogen_agentchat.agents import AssistantAgent
from autogen_agentchat.ui import Console
from autogen_ext.models.openai import OpenAIChatCompletionClient
from autogen_ext.tools.mcp import McpWorkbench, StdioServerParams


async def main() -> None:
    model_client = OpenAIChatCompletionClient(model="gpt-4.1")
    server_params = StdioServerParams(
        command="npx",
        args=[
            "@playwright/mcp@latest",
            "--headless",
        ],
    )
    async with McpWorkbench(server_params) as mcp:
        agent = AssistantAgent(
            "web_browsing_assistant",
            model_client=model_client,
            workbench=mcp, # For multiple MCP servers, put them in a list.
            model_client_stream=True,
            max_tool_iterations=10,
        )
        await Console(agent.run_stream(task="Find out how many contributors for the microsoft/autogen repository"))


asyncio.run(main())

Warning: Only connect to trusted MCP servers as they may execute commands in your local environment or expose sensitive information.

Multi-Agent Orchestration

Set up a basic multi-agent orchestration using AgentTool to delegate tasks to specialized agents.

import asyncio

from autogen_agentchat.agents import AssistantAgent
from autogen_agentchat.tools import AgentTool
from autogen_agentchat.ui import Console
from autogen_ext.models.openai import OpenAIChatCompletionClient


async def main() -> None:
    model_client = OpenAIChatCompletionClient(model="gpt-4.1")

    math_agent = AssistantAgent(
        "math_expert",
        model_client=model_client,
        system_message="You are a math expert.",
        description="A math expert assistant.",
        model_client_stream=True,
    )
    math_agent_tool = AgentTool(math_agent, return_value_as_last_message=True)

    chemistry_agent = AssistantAgent(
        "chemistry_expert",
        model_client=model_client,
        system_message="You are a chemistry expert.",
        description="A chemistry expert assistant.",
        model_client_stream=True,
    )
    chemistry_agent_tool = AgentTool(chemistry_agent, return_value_as_last_message=True)

    agent = AssistantAgent(
        "assistant",
        system_message="You are a general assistant. Use expert tools when needed.",
        model_client=model_client,
        model_client_stream=True,
        tools=[math_agent_tool, chemistry_agent_tool],
        max_tool_iterations=10,
    )
    await Console(agent.run_stream(task="What is the integral of x^2?"))
    await Console(agent.run_stream(task="What is the molecular weight of water?"))


asyncio.run(main())

For more advanced multi-agent orchestrations and workflows, refer to the AgentChat documentation.

AutoGen Studio

Prototype and run multi-agent workflows without writing code using AutoGen Studio.

autogenstudio ui --port 8080 --appdir ./my-app

Caution: AutoGen Studio is intended for rapid prototyping and demonstration, not as a production-ready application. Developers should build their own applications with necessary security and authentication features.

Why Use AutoGen?

AutoGen provides a comprehensive ecosystem for creating AI agents, particularly for multi-agent workflows, encompassing a robust framework, essential developer tools, and example applications. Its layered and extensible design allows for flexible use, from high-level APIs to low-level components.

The framework is structured with:

  • Core API: Implements message passing, event-driven agents, and a flexible runtime, supporting both .NET and Python.
  • AgentChat API: Offers a simpler API for rapid prototyping, building on the Core API and supporting common multi-agent patterns.
  • Extensions API: Enables continuous expansion of framework capabilities through first and third-party extensions, including LLM clients and code execution.

Key developer tools include:

  • AutoGen Studio: A no-code GUI for building multi-agent applications.
  • AutoGen Bench: A benchmarking suite for evaluating agent performance.

AutoGen also fosters a thriving community with weekly office hours, talks, a Discord server, and GitHub Discussions for support and collaboration.

Links & Resources