Open SourcePython

AG2

by AG2 CommunityUpdated Jun 15, 2025

Community-driven evolution of the original AutoGen project, focused on open multi-agent conversation patterns and group decision-making. AG2 emphasizes conversable agents that can engage in flexible, dynamic conversations with each other, supporting human participation and complex group chat scenarios.

Architecture Overview

AG2 uses a conversable agent architecture where each agent (ConversableAgent) can send and receive messages. Agents can be configured with LLM capabilities (AssistantAgent) or human input (UserProxyAgent). Group chats are managed by a GroupChatManager that coordinates turn-taking among multiple agents. The framework supports nested conversations, function calling, and code execution within the conversation flow.

When to Use AG2

  • Multi-agent conversations and debates
  • Group decision-making with diverse agent perspectives
  • Research and brainstorming with AI collaborators
  • Code generation with automated testing feedback loops
  • Complex problem decomposition across agent teams

Strengths & Weaknesses

Strengths

  • Flexible conversation-driven agent interactions
  • Strong group chat and multi-party dynamics
  • Active open-source community with rapid development
  • Built-in code execution capabilities
  • Supports nested and hierarchical conversations

Weaknesses

  • Complex API surface for beginners
  • Rapidly evolving with frequent breaking changes
  • Documentation can lag behind development pace

Quick Start

python
from ag2 import AssistantAgent, UserProxyAgent

# Create an assistant agent
assistant = AssistantAgent(
    name="assistant",
    llm_config={"model": "gpt-4o", "api_type": "openai"},
    system_message="You are a helpful AI assistant. Solve tasks step by step.",
)

# Create a user proxy that can execute code
user_proxy = UserProxyAgent(
    name="user_proxy",
    human_input_mode="NEVER",
    max_consecutive_auto_reply=5,
    code_execution_config={"work_dir": "coding", "use_docker": False},
)

# Start a conversation
user_proxy.initiate_chat(
    assistant,
    message="Write a Python function to calculate the Fibonacci sequence up to n terms, then test it with n=10.",
)

Features at a Glance

DeveloperAG2 Community
LanguagePython
LicenseApache-2.0
GitHub Stars5k+
MCP SupportYes
Multi-AgentYes

Notable Users

Penn State UniversityMicrosoft ResearchUniversity of Washington

Resources

Explore Related Content