AG2 is a Python framework for building agents that cooperate via tools, models, and typed channels. It targets autonomous and human-in-the-loop workflows.
Overview
AG2 is an open-source programming framework for building AI agents and coordinating multiple agents on shared tasks. The current top-level package uses the ag2 import name and replaces the older AutoGen-style autogen namespace, which now lives in a separate classic distribution with its own docs.
An Agent is the core unit: it talks to a configured model provider, invokes tools, and returns replies through an async ask flow. Tools are plain Python functions decorated for the runtime to call in a full tool-calling loop. Human-in-the-loop flows can pause inside tools to collect confirmation or missing input.
Multi-agent work uses a Network model with a hub, write-ahead logging, audit trail, and typed channels such as conversation, consulting, discussion, and workflow-style handoffs. Optional harness pieces add persistent knowledge stores, context assembly, and history compaction so long runs stay within context limits.
Install is via PyPI as ag2 with Python 3.11 or newer; provider extras cover OpenAI, Anthropic, Gemini, Ollama, and others. API keys are read from standard environment variables. Documentation and a playground cover examples from single agents through advanced patterns like middleware, telemetry, and evaluation.
Key features
- Async Agent turn API
- Python function tools
- Human-in-the-loop pauses
- Multi-agent Network and channels
- Knowledge store plugins
- History compaction strategies
- Multiple LLM provider extras
- Structured outputs and middleware
Use cases
- Multi-agent task orchestration
- Tool-using LLM agents
- Human-approved agent workflows
- Agent research and prototyping