CLI Overview
The AG2 CLI (ag2) is a terminal tool for the full agent development lifecycle — from scaffolding projects to running, testing, serving, and publishing agents.
Installation#
Verify it's installed:
Commands at a Glance#
| Command | Description |
|---|---|
ag2 run | Execute an agent with a message |
ag2 chat | Interactive terminal chat session |
ag2 create | Scaffold projects, agents, tools, and teams |
ag2 serve | Expose agents as REST, MCP, or A2A endpoints |
ag2 test | Run evaluation suites and benchmarks |
ag2 install | Install skills, templates, tools, and more |
ag2 replay | Replay and debug past sessions |
ag2 arena | A/B test agent implementations |
ag2 proxy | Wrap CLIs, APIs, or modules as AG2 tools |
ag2 publish | Publish artifacts to the AG2 registry |
Quick Start#
Create a new project and run it:
Or run an existing agent file:
Start an interactive chat session:
Agent Discovery#
Most commands (run, chat, serve, test) need to find an agent in your Python file. The CLI looks for these in order:
- A
main()function - A module-level variable named
agentorteam - A module-level list named
agents - Any single
ConversableAgentinstance
You can also use YAML config files instead of Python: