AG2 is a Python framework for building AI agents and coordinating several of them on a task. Its core building block is an Agent that talks to a model provider, calls tools, and returns a reply, and the framework is async throughout. Continuing from a reply keeps the same conversation and its history.
Tools are plain Python functions marked with a decorator, and AG2 runs the full tool-calling loop. A tool can pause a run to ask a person for confirmation or missing information, and a hook decides how that question is answered (a CLI prompt, a web UI, or a queue). When agents need to work together, a Network hub holds the registry, a write-ahead log, and the audit trail, and agents talk over typed channels: free-form conversation, strict one-question consulting, round-robin discussion, and declarative workflow graphs for conditional handoffs.
Optional harness primitives layer onto an agent: a knowledge store it can read and write across runs, compaction strategies that summarize dropped history instead of discarding it, and a working-memory policy that injects stored memory into the system prompt on every turn. Further concepts include structured output, middleware, observers, telemetry, evaluation, and testing. Model providers are selected through per-provider configs, with extras for OpenAI, Anthropic, Gemini, Ollama, and others.
Version 1.0 replaced the earlier AutoGen-derived API. That classic framework, with ConversableAgent, GroupChat, and swarms under the autogen namespace, now lives in a separate AG2 Classic repository and remains maintained, and 1.0 is not a drop-in upgrade from it.
Features
- Agents: a core Agent class that calls a model, runs tools, and continues conversations with history
- Tools: decorated Python functions with the tool-calling loop handled by the framework
- Human in the loop: tools can pause a run to collect approval or input through a configurable hook
- Multi-agent Network: a hub with registry, write-ahead log, and audit trail, connecting agents over typed channels
- Channel types: conversation, consulting, round-robin discussion, and workflow graphs for conditional handoffs
- Knowledge and compaction: persistent knowledge stores, summarizing history compaction, and working-memory injection
- Advanced patterns: structured output, middleware, observers, telemetry, evaluation, and testing
- Provider configs: OpenAI, Anthropic, Gemini, Ollama, and other model providers
- AG2 Classic: the earlier AutoGen-style API kept in a separate maintained repository




