by ag2ai
AG2 (formerly AutoGen): The Open-Source AgentOS.Join us at: https://discord.gg/sNGSwQME3x
# Add to your Claude Code skills
git clone https://github.com/ag2ai/ag2ag2 is an open-source ai agents skill for AI coding assistants such as Claude Code, Codex CLI, and ChatGPT, built by ag2ai. AG2 (formerly AutoGen): The Open-Source AgentOS.Join us at: https://discord.gg/sNGSwQME3x. It has 5,097 GitHub stars.
ag2's catalog security scan is still queued. You can run an instant dependency and prompt-injection check now with the "Scan for vulnerabilities" button above.
Clone the repository with "git clone https://github.com/ag2ai/ag2" and add it to your Claude Code skills directory (see the Installation section above).
ag2 is primarily written in Python. It is open-source under ag2ai on GitHub, so you can review or fork the full source.
Yes. AgentsLLM lists many other AI Agents skills you can browse and compare side by side. Open the AI Agents category from the badge at the top of this page, or use the Related Skills and comparison links further down to weigh ag2 against similar tools.
No comments yet. Be the first to share your thoughts!
Unlocks once the catalog security scan passes (runs nightly).
The deep catalog scan for this skill is still queued. Run an instant dependency check now instead.
[!IMPORTANT] Looking for
ConversableAgent,GroupChat, orimport autogen? That's now AG2 Classic.As of AG2 v1.0, the protocol-driven framework is the top-level package, imported as
ag2. The classic framework has moved to its own repository — ag2ai/ag2-classic, documented at classic.docs.ag2.ai. It is still maintained and installable; nothing you have built stops working.This repository (
pip install ag2) no longer ships theautogenimport name or the classic agent classes.
AG2 is an open-source programming framework for building AI agents and facilitating cooperation among multiple agents to solve tasks. AG2 aims to streamline the development and research of agentic AI. It offers features such as agents capable of interacting with each other, facilitates the use of various large language models (LLMs) and tool use support, autonomous and human-in-the-loop workflows, and multi-agent conversation patterns.
The project is currently maintained by a dynamic group of volunteers from several organizations. Contact project administrators Chi Wang and Qingyun Wu via [email protected] if you are interested in becoming a maintainer.
autogen.* namespace)AG2 Classic is the original AutoGen-derived framework: the autogen.* import namespace and its agent classes — ConversableAgent, AssistantAgent, UserProxyAgent, GroupChat / GroupChatManager, swarms, register_function, LLMConfig / OAI_CONFIG_LIST, and the nested- and sequential-chat patterns.
It now lives in its own repository and has its own documentation site:
| AG2 Classic | AG2 (this repo) | |
|---|---|---|
| Repository | ag2ai/ag2-classic | ag2ai/ag2 |
| Documentation | classic.docs.ag2.ai | docs.ag2.ai |
| Import | import autogen |
import ag2 |
| Core agent | ConversableAgent |
Agent |
| Multi-agent | GroupChat, swarms, nested chats |
Network (hub + channels) |
If any of the following appear in your code, you are on Classic — stay on it, and use classic.docs.ag2.ai:
import autogen # the autogen.* namespace
from autogen import ConversableAgent, GroupChat # classic agent classes
from autogen import AssistantAgent, UserProxyAgent
Classic remains maintained and installable. Your existing code keeps working — pin the classic distribution instead of ag2>=1.0:
pip install ag2-classic
[!NOTE] AG2 v1.0 (
pip install ag2) is not a drop-in upgrade from Classic. The agent model, orchestration, and imports all changed. See the group chat migration guide.
The rest of this README covers AG2 v1.0 (import ag2).
For a step-by-step walk through of AG2 concepts and code, see the Quick Start in our documentation.
AG2 requires Python version >= 3.11. AG2 is available as ag2 on PyPI.
Windows/Linux:
pip install ag2[openai]
Mac:
pip install 'ag2[openai]'
Minimal dependencies are installed by default. Install the extra that matches your model provider — ag2[openai], ag2[anthropic], ag2[gemini], ag2[ollama], and so on.
Each provider config reads its standard environment variable, so keys never need to be hardcoded or checked in:
export OPENAI_API_KEY="<your-api-key>" # or ANTHROPIC_API_KEY, GEMINI_API_KEY, ...
You can also pass a key explicitly with OpenAICompletionsConfig(model="gpt-4o-mini", api_key=...) — useful when each request brings its own key.
AG2 is async throughout. Agent.ask(...) starts a turn and returns an AgentReply; the text is in reply.body.
import asyncio
from ag2 import Agent
from ag2.config import OpenAICompletionsConfig
agent = Agent(
"assistant",
prompt="You are a helpful assistant.",
config=OpenAICompletionsConfig(model="gpt-4o-mini"),
)
async def main() -> None:
reply = await agent.ask("Summarize the main differences between Python lists and tuples.")
print(reply.body)
asyncio.run(main())
We maintain both a live playground and a dedicated repository with a wide range of applications to help you get started with various use cases, and a set of runnable code examples in the documentation.
We have several agent concepts in AG2 to help you build your AI agents. We introduce the most common ones here.
Agent is the core building block — it talks to a model provider, calls tools, and returns a reply.@tool, that the agent can invoke.The Agent is the fundamental building block of AG2. ask() runs a turn; calling ask() on the returned reply continues the same conversation, preserving its history.
import asyncio
from ag2 import Agent
from ag2.config import OpenAICompletionsConfig
reviewer = Agent(
"reviewer",
prompt=(
"You are a code reviewer. Analyze the provided code and suggest improvements. "
"Do not generate code, only suggest improvements."
),
config=OpenAICompletionsConfig(model="gpt-4o-mini"),
)
async def main() -> None:
reply = await reviewer.ask("def fib(n): return n if n < 2 else fib(n-1) + fib(n-2)")
print(reply.body)
# Continue the same conversation — prior turns stay in scope.
follow_up = await reply.ask("Which of those matters most for large n?")
print(follow_up.body)
asyncio.run(main())
Agents gain significant utility through tools, which extend their capabilities with external data, APIs, or functions. Decorate a Python function with @tool and pass it to the agent — AG2 runs the full tool-calling loop: the model decides when to call it, AG2 executes it, and the result is fed back.
import asyncio
from datetime import datetime
from ag2 import Agent, tool
from ag2.config import OpenAICompletionsConfig
@tool
async def get_weekday(date_stri