explaingit

ag2ai/ag2

4,537PythonAudience · developerComplexity · 3/5Setup · easy

TLDR

An open-source Python framework for building systems where multiple AI assistants coordinate, pass messages, and work together to complete tasks, with built-in support for human oversight and approval checkpoints.

Mindmap

mindmap
  root((AG2))
    Core Concept
      ConversableAgent
      Message passing
      Multi-agent chat
    Coordination Patterns
      Sequential pipeline
      Group chat
      Swarm handoff
    Human Oversight
      Approval checkpoints
      Input requests
      Decision loop
    Setup
      Python 3.10 plus
      pip install
      JSON API key config
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

Things people build with this

USE CASE 1

Build a coding assistant where one AI agent writes Python code and another reviews it in a back-and-forth loop until it passes

USE CASE 2

Create a customer support pipeline where agents triage, research, and draft responses in sequence

USE CASE 3

Set up a research workflow where multiple agents search different sources then one agent synthesizes the results

USE CASE 4

Add a human approval checkpoint to an AI workflow so a person must approve before any sensitive action runs

Tech stack

Pythonpip

Getting it running

Difficulty · easy Time to first run · 30min

Requires Python 3.10 or newer and API keys for your chosen LLM provider stored in a local JSON config file.

In plain English

AG2 (formerly AutoGen) is an open-source Python framework for building AI agents that can work together to complete tasks. It grew out of the AutoGen project and is now maintained by a group of volunteers across multiple organizations. The library is designed to make it easier to create systems where multiple AI assistants coordinate with each other, share information, and pass work along through structured conversation. The core building block is something called a ConversableAgent: a software object that can send and receive messages, generate replies using a large language model, call external tools, or accept input from a real person. You can create as many of these agents as you need and set them up to talk to each other. A common example has one agent write code while another reviews it, with the two exchanging messages until the task is finished. AG2 includes several built-in patterns for organizing groups of agents. You can run them in a sequence (each agent hands off to the next), in a group chat (agents take turns in a shared thread), in nested conversations (an agent internally spawns a separate sub-conversation), or in a swarm (agents hand off control to one another based on conditions you define). Custom coordination logic is also supported if none of those patterns fit your needs. Human oversight is built into the framework. You can configure an agent to pause and ask a person for input or approval at any point in the workflow, which keeps a human in the decision loop for steps where that matters. To get started, you install the package via pip (Python 3.10 or newer is required) and store your API keys for whichever language model you plan to use in a local JSON config file. The README includes a minimal working example showing two agents exchanging messages about a coding task, which is enough to understand the basic pattern before exploring more advanced setups.

Copy-paste prompts

Prompt 1
Using AG2, create two ConversableAgents, one that writes Python code to scrape a website and one that reviews it for security issues, and have them exchange messages until the code passes review.
Prompt 2
How do I configure an AG2 swarm where agents hand off control to each other based on conditions? Show me the setup for a customer triage-then-respond workflow.
Prompt 3
I want a human-in-the-loop AG2 workflow that pauses and asks for my approval before sending any external API call. How do I configure that checkpoint on a ConversableAgent?
Prompt 4
Set up an AG2 group chat with four agents for writing, editing, fact-checking, and formatting so they collaborate on producing a polished article from a topic prompt.
Prompt 5
Write the minimal AG2 JSON config file for using a GPT-4o model and show me how to reference it when creating a ConversableAgent in Python.
Open on GitHub → Explain another repo

← ag2ai on gitmyhub — every repo by this author, as a profile.

Verify against the repo before relying on details.