AG2 (formerly AutoGen) is an open-source multi-agent AI framework from the original AutoGen research team, positioned as an AgentOS — a universal runtime for agents built in AG2, Google ADK, OpenAI Agents SDK, and LangChain.
AG2 (formerly AutoGen) is an open-source multi-agent AI framework from the original AutoGen research team, positioned as an AgentOS — a universal runtime for agents built in AG2, Google ADK, OpenAI Agents SDK, and LangChain.
AG2's open-source framework is a Python library (pyautogen legacy install; ag2 current) that supports single-agent, multi-agent, group chat, and hierarchical orchestration patterns. It exposes tool calling, code execution in a sandbox, human-in-the-loop steps, and pluggable LLM backends (any OpenAI-compatible endpoint). The commercial AgentOS adds shared state, cross-framework interoperability, hosted execution, observability hooks, and enterprise auth. The company retains the original AutoGen research team and continues to publish papers (StateFlow, group chat coordination).
AG2 delivers enterprise-grade multi-agent AI through conversational orchestration that no other open-source framework matches in flexibility. Its four conversation patterns, native human-in-the-loop support, and cross-framework interoperability via AgentOS make it the most versatile option for Python developers building complex agent systems. The tradeoffs are real — Python-only, no managed hosting, and a learning curve steeper than CrewAI — but for teams that need fine-grained control over how agents collaborate, AG2 remains the strongest open-source choice in 2026.
AG2 provides four distinct collaboration patterns — swarms for parallel task distribution, sequential chains for pipeline workflows, group chats with LLM-based automatic speaker selection for multi-party collaboration, and nested conversations for hierarchical agent compositions. The GroupChatManager coordinates turn-taking and routing, while developers can customize speaker selection logic, termination conditions, and maximum turn limits for each pattern.
AG2 uniquely bridges agent ecosystems by connecting agents built in CrewAI, LangChain, LlamaIndex, and other frameworks into unified conversations through standardized A2A and MCP protocols. This cross-framework orchestration means teams are not locked into a single agent framework — they can leverage the best tools from each ecosystem while AG2's AgentOS runtime handles message routing, state synchronization, and lifecycle management across heterogeneous agent populations.
The UserProxyAgent class provides granular control over human involvement in agent conversations. Developers configure human_input_mode to ALWAYS (human approves every message), TERMINATE (human intervenes only at conversation end), or NEVER (fully autonomous). The agent can relay messages to humans, execute code on their behalf, and seamlessly transition between autonomous operation and human oversight at any conversation turn.
Agents can write, execute, and iteratively debug Python code within sandboxed environments. AG2 supports LocalCommandLineCodeExecutor for development, DockerCommandLineCodeExecutor for production-safe isolation, and Jupyter-based execution for notebook-style workflows. Configurable timeouts, allowed languages, and working directories give developers control over the execution environment while preventing runaway processes.
Register any Python function as an agent tool with automatic schema generation using simple decorators. The @register_for_llm decorator exposes a tool to an agent's LLM for function calling, while @register_for_execution designates which agent runs the function. This separation of calling and execution enables secure patterns where one agent decides to use a tool but a different, authorized agent performs the action. LangChain tool adapters provide additional interoperability.
Built-in RAG capabilities allow agents to ingest, index, and reason over external documents during conversations. The RetrieveUserProxyAgent handles document chunking, embedding generation, and vector store queries (with native ChromaDB support and adapters for Pinecone and Weaviate). Agents automatically retrieve relevant passages and inject them as context, enabling document-grounded conversations without requiring separate RAG infrastructure.
Every agent inherits from the ConversableAgent base class, providing a unified interface for sending and receiving messages, maintaining conversation history, and registering reply functions. This architecture means any agent can talk to any other agent, conversations are composable (a two-agent chat can be nested inside a group chat), and new agent types are created by subclassing and overriding reply logic rather than implementing complex interfaces.
AG2 integrates with all major LLM providers — OpenAI GPT-4 and GPT-4o, Anthropic Claude, Google Gemini, Mistral, Azure OpenAI, and local open-weight models via Ollama and LM Studio. Different agents in the same conversation can use different models, enabling cost optimization by routing simple tasks to cheaper models while reserving expensive frontier models for complex reasoning. Model failover chains automatically switch providers if a primary model is unavailable.
Define strict output schemas using Pydantic models, enforce JSON response formats, and set precise termination conditions to maintain control over agent conversations. Developers can specify max_turns limits, custom termination keywords, reply function overrides, and conversation hooks that trigger at specific points in the dialogue flow. This ensures agent conversations produce machine-parseable results and terminate predictably.
The shared state system provides a centralized context store accessible to all agents in a conversation. In sequential chats, the carryover mechanism automatically passes relevant context from one conversation stage to the next. Context variables can be set, read, and updated by any participating agent, enabling coordination without requiring agents to explicitly pass information through conversation messages. AgentOS extends this with persistent state across sessions.
$0
Request Access (no public pricing)
Ready to get started with AG2?
View Pricing Options →AG2 works with these platforms and services:
We believe in transparent reviews. Here's what AG2 doesn't handle well:
AG2 has sharpened its positioning around AgentOS as a universal, cross-framework agent runtime. Key developments include swarm-style orchestration for lightweight agent handoffs, Captain Agent for dynamic sub-agent creation and management, reasoning agents with built-in chain-of-thought and reflection capabilities, and improved structured output support via Pydantic models. The cross-framework interoperability story has matured significantly, with production-ready integrations for CrewAI, LangChain, and LlamaIndex agents through standardized A2A and MCP protocols.
AI Development
Leading multi-agent framework and platform for building, deploying, and monitoring collaborative AI agent teams.
AI agent framework
LangGraph is LangChain’s framework for reliable agents with low-level control, deployment, observability, evaluation, sandboxes and enterprise LangSmith services.
AI Agent Builders
OpenAI Agents SDK is an open-source Python framework for building agentic apps with handoffs, guardrails, sessions, tracing, MCP tools, sandbox agents, and realtime voice agents.
Knowledge agents
A framework and managed platform for building agents over documents and enterprise data.
Pricing and features change often. If anything on this AG2 page is wrong or missing, tell us and include a link to the source. We review every correction.