AG2 (formerly AutoGen) is an open-source multi-agent programming framework positioned as an "open-source AgentOS for AI agents." It aims to simplify the development and research of agentic AI, supporting the building of AI agents that can collaborate with one another to solve tasks together. The project is maintained by a team of volunteers from multiple organizations.
Starting with AG2 v1.0, the top-level package of the repository has become a protocol-driven framework, imported via import ag2 . The legacy classic framework (ConversableAgent, GroupChat,import autogen , etc.) has been migrated to the separate repository ag2ai/ag2-classic, where it continues to be maintained, installed by pinning the classic release rather than ag2>=1.0. AG2 v1.0 is not a direct drop-in upgrade of the classic framework; the agent model, orchestration, and import approach have all changed.
AG2 requires Python >= 3.10 and can be installed from PyPI as ag2. The default installation has minimal dependencies; you need to install the corresponding extension for your model provider, such as ag2[openai]、ag2[anthropic]、ag2[gemini]、ag2[ollama] , etc. Each provider's configuration reads its standard environment variables and also supports explicitly passing an API key (e.g., OpenAIConfig(model="gpt-4o-mini", api_key=...)). The framework is asynchronous throughout;Agent.ask(...) starts a round of conversation and returns AgentReply, with the text located in reply.body; calling ask() again on the returned reply continues the same conversation while preserving history.
Key concepts:
- Agent: the core building block that communicates with model providers, calls tools, and returns replies.
- Tools: ordinary Python functions decorated with
@toolthat agents can call; AG2 runs the full tool-calling loop, with the model deciding when to call, and AG2 executing and feeding the results back. - Human in the loop: calling
context.input(...)inside a tool can pause execution and ask a person, withhitl_hookdeciding how the response is provided (CLI prompt, Web UI, queue, etc.). - Multi-agent orchestration: use Network to coordinate multiple agents, with Hub responsible for the registry, write-ahead log, and audit trail, and agents communicating through typed channels, replacing the classic GroupChat / swarm / nested conversation patterns. Channel forms include conversation (free-form two-party exchange), consulting (strict question-and-answer), discussion (multi-agent rotation), and workflow (declarative TransitionGraph conditional handoff).
- Agent harness: optional overlay primitives such as
knowledge=(a readable/writable KnowledgeStore for cross-run memory),compact=(limits history growth; SummarizeCompact folds discarded turns into a summary), together with the WorkingMemoryPolicy inassembly=to inject memory into the system prompt each turn.
Applicable scenarios include multi-agent collaborative tasks, automated workflows, and AI application development requiring tool calling and human review. In terms of limitations: AG2 v1.0 is incompatible with the classic framework; detailed pricing, platform support, and other information are not yet provided.