Agent skill

Ag2 Quickstart

by ag2ai in ag2ai/build-with-ag2

Build a minimal AG2 beta Agent end to end — pick a model provider, set a prompt, call agent.ask(), then continue the conversation with reply.ask() (multi-turn).

Apache-2.0Auto-check: notesAI & LLM Engineering

Install Ag2 Quickstart

skills CLI
$ npx skills add ag2ai/build-with-ag2 --skill ag2-quickstart -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install ag2ai/build-with-ag2 ag2-quickstart --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/ag2ai/build-with-ag2.git skills-src && mkdir -p .claude/skills && cp -r skills-src/.agents/skills/ag2-quickstart .claude/skills/ag2-quickstart && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
ag2-quickstart
GitHub stars
252
Token cost
~1.7k tokens
SKILL.md length
472 words
Files
3 (incl. assets)
Skills in repo
16
Repo updated
First seen
Licence
Apache-2.0

At a glance

Build a minimal AG2 beta Agent end to end — pick a model provider, set a prompt, call agent.ask(), then continue the conversation with reply.ask() (multi-turn).

  • The user is starting a new AG2 beta project
  • SKILL.md covers When to use, Prerequisites, 60-second recipe and Picking a provider, plus 4 more sections
  • Runs Python scripts from its folder; calls pip and python; needs OPENAI_API_KEY and ANTHROPIC_API_KEY
  • Has no working Agent yet

What it does

Ag2 Quickstart is an agent skill from ag2ai/build-with-ag2. Build a minimal AG2 beta Agent end to end — pick a model provider, set a prompt, call agent.ask(), then continue the conversation with reply.ask() (multi-turn). Use when the user is starting a new AG2 beta project, has no working Agent yet, or needs the multi-turn chaining pattern. Covers OpenAIConfig, AnthropicConfig, GeminiConfig, OllamaConfig etc., and env-var fallback for API keys.

Its SKILL.md is about 1.7k tokens, which your agent loads only when the skill is triggered. The skill folder holds 3 other files, including assets (for example `assets/hello_agent.py` and `assets/multi_turn.py`).

It sits in AI & LLM Engineering. It works with OpenAI. The repository describes itself as: Sample code and application showcases to get you going with AG2 (formally AutoGen). The licence is Apache-2.0.

When your agent uses it

  • The user is starting a new AG2 beta project
  • Has no working Agent yet
  • Needs the multi-turn chaining pattern

Example prompts

  • “/ag2-quickstart”

Requirements

  • Python 3
  • A credential in OPENAI_API_KEY
  • A credential in ANTHROPIC_API_KEY

What it can do on your machine

Read from SKILL.md and the folder at commit 29eeac3. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    Ships script files (Python), which the agent can run.

    Shell commands in SKILL.md call:

    • pip
    • python

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md. Its commands use pip, which can reach the network depending on how they are called.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names these keys or tokens, usually read from environment variables:

    • OPENAI_API_KEY
    • ANTHROPIC_API_KEY
    • GEMINI_API_KEY
    • GOOGLE_API_KEY
    • DASHSCOPE_API_KEY

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Ag2 Quickstart loads about 1.7k tokens when it runs. Until then it costs about 105 tokens; SKILL.md has 472 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~105
When it runs · the whole SKILL.md, loaded when a task matches
~1.7k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check: notes

The automated check noted patterns worth knowing about, such as sudo or a known installer.

  • NoteMentions a .env fileSKILL.md:29
    Load env vars from a project-root `.env` with `python-dotenv` so scripts pick up keys without exporting them in your she
  • NoteMentions a .env fileSKILL.md:33
    load_dotenv()  # reads .env at project root

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from ag2ai/build-with-ag2 at commit 29eeac3, republished under its Apache-2.0 licence (© ag2ai). 472 words, ~1,651 tokens.

Download SKILL.mdSave it as .claude/skills/ag2-quickstart/SKILL.md (or your agent's skills folder). This skill also uses 2 other files; get the full folder from GitHub.
name
ag2-quickstart
description
Build a minimal AG2 beta `Agent` end to end — pick a model provider, set a prompt, call `agent.ask()`, then continue the conversation with `reply.ask()` (multi-turn). Use when the user is starting a new AG2 beta project, has no working `Agent` yet, or needs the multi-turn chaining pattern. Covers `OpenAIConfig`, `AnthropicConfig`, `GeminiConfig`, `OllamaConfig` etc., and env-var fallback for API keys.
license
Apache-2.0

Quickstart: build your first AG2 beta Agent

When to use

  • The user is starting from a blank file and wants a working AG2 beta agent.
  • The user is unsure which provider config to use.
  • The user wants to chain follow-up turns without losing conversation context.
  • A larger task needs the basic Agent setup as its skeleton — start here, then layer the relevant feature skill on top.

Prerequisites

Install the right provider extra and have a key for it. Each *Config requires its provider SDK — without the matching extra you'll see ImportError: ... requires optional dependencies. Install with pip install "ag2[<provider>]".

ProviderInstallEnv varConfig class
OpenAIpip install "ag2[openai]"OPENAI_API_KEYOpenAIConfig, OpenAIResponsesConfig
Anthropicpip install "ag2[anthropic]"ANTHROPIC_API_KEYAnthropicConfig
Gemini (API key)pip install "ag2[gemini]"GEMINI_API_KEY (or GOOGLE_API_KEY)GeminiConfig
Vertex AI (Gemini)pip install "ag2[gemini]"service-account / ADCVertexAIConfig
Ollama (local)pip install "ag2[ollama]"—OllamaConfig
DashScope (Qwen)pip install "ag2[dashscope]"DASHSCOPE_API_KEYDashScopeConfig

Load env vars from a project-root .env with python-dotenv so scripts pick up keys without exporting them in your shell:

python
from dotenv import load_dotenv
load_dotenv()  # reads .env at project root

Quick sanity-check before debugging weird import errors — make sure you're running against the ag2 you think:

bash
python -c "import sys, autogen; print(sys.executable); print('ag2', autogen.__version__)"

60-second recipe

python
import asyncio
from autogen.beta import Agent
from autogen.beta.config import OpenAIConfig

async def main() -> None:
    agent = Agent(
        "assistant",
        prompt="You are a helpful assistant. Reply in one sentence.",
        config=OpenAIConfig(model="gpt-4o-mini"),
    )

    # First turn
    reply = await agent.ask("What is the capital of France?")
    print(reply.body)

    # Continue the same conversation — context is preserved
    reply = await reply.ask("And of Germany?")
    print(reply.body)

asyncio.run(main())

Agent.ask(...) starts a new turn and returns an AgentReply. AgentReply.ask(...) continues the same conversation, preserving its context and history. The reply text is in reply.body; for typed output see the ag2-structured-output skill (reply.content()).

Picking a provider

Each provider has its own config class in autogen.beta.config. All accept model=, optional api_key=, and (where supported) streaming=True. Streaming is recommended — AG2 beta is async- and streaming-first.

python
from autogen.beta.config import OpenAIConfig          # gpt-4o, gpt-5-*, o-series, etc.
from autogen.beta.config import OpenAIResponsesConfig # OpenAI Responses API (image gen, file_id support)
from autogen.beta.config import AnthropicConfig       # claude-sonnet-4-6, claude-opus-4-7, etc.
from autogen.beta.config import GeminiConfig          # Gemini Developer API (api_key)
from autogen.beta.config import VertexAIConfig        # Gemini on Google Vertex AI (project + location)
from autogen.beta.config import OllamaConfig          # local Ollama
from autogen.beta.config import DashScopeConfig       # Alibaba Qwen

config = AnthropicConfig(model="claude-sonnet-4-6", streaming=True)

If api_key= is omitted, the config reads the standard env var — OPENAI_API_KEY, ANTHROPIC_API_KEY, GEMINI_API_KEY (or GOOGLE_API_KEY), etc.

For OpenAI-compatible endpoints (vLLM, LM Studio, Together, NVIDIA NIM, etc.) use OpenAIConfig with base_url= set:

python
config = OpenAIConfig(
    model="qwen-3",
    base_url="http://localhost:8000/v1",
    api_key="NotRequired",  # pragma: allowlist secret
)
Show full SKILL.md (189 more words)Show less

Multi-turn — chain reply.ask()

python
agent = Agent("planner", prompt="...", config=config)
reply = await agent.ask("Plan a 5-day Japan trip in late April.")
reply = await reply.ask("Budget is $2500 per person, two travellers.")
reply = await reply.ask("Prefer trains. Day-by-day itinerary.")
print(reply.body)

reply.ask() keeps the prior turns in scope so the LLM remembers the constraints. Calling agent.ask(...) again instead would start a fresh conversation. See assets/multi_turn.py for the full travel-planner example.

Reusing model configs

Configs are immutable. Use .copy(...) to fork one with overrides:

python
base = OpenAIConfig(model="gpt-5")
hot = base.copy(temperature=0.8)
cheap = base.copy(model="gpt-5-mini")

You can also override the model per ask — useful when the user brings their own API key per request:

python
agent = Agent("assistant", prompt="Help.")
reply = await agent.ask("Hello!", config=OpenAIConfig(model="gpt-5", api_key="sk-..."))  # pragma: allowlist secret

The per-ask config completely replaces the agent's config for that turn.

Going deeper

  • Working starter (single-turn): assets/hello_agent.py (mirrors code_examples/01).
  • Multi-turn starter: assets/multi_turn.py (mirrors code_examples/03).
  • Full provider reference, including VertexAIConfig auth, extra_body, custom httpx client, env-var fallback table: website/docs/beta/model_configuration.mdx.
  • Agent communication API surface (events, observing, HITL): website/docs/beta/agents.mdx.
  • Static, dynamic, per-turn prompts: website/docs/beta/system_prompts.mdx.

Common pitfalls

  • Forgetting to await — every method on Agent / AgentReply is async. Wrap in asyncio.run(main()) for scripts.
  • Calling agent.ask() twice expecting context to carry — it doesn't; use reply.ask() instead.
  • Hardcoding API keys — prefer env-var fallback (OPENAI_API_KEY, etc.) so configs commit cleanly.
  • Skipping streaming=True — AG2 beta is streaming-first; you'll get a worse user experience without it on supported providers.
  • Per-ask config= is total override, not a partial merge — be deliberate about which knobs you set.

© ag2ai, Apache-2.0. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

SKILL.md and 2 other files (assets) in .agents/skills/ag2-quickstart of ag2ai/build-with-ag2.

  • SKILL.md
  • assets/hello_agent.py
  • assets/multi_turn.py

Open the folder on GitHubat commit 29eeac3

Compare with similar skills

Ag2 Quickstart next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Ag2 Quickstart compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Ag2 Quickstart this skillag2ai/build-with-ag2252—~1.7kAutomated safety check: NotesApache-2.0
Chroma Vector DatabaseOrchestra-Research/AI-Research-SKILLs13k8 repos~2.3kAutomated safety check: PassMIT
CLIP Image-Text MatchingOrchestra-Research/AI-Research-SKILLs13k8 repos~1.7kAutomated safety check: PassMIT
Codebase Managementgiancarloerra/SocratiCode3.3k1 repos~1.8kAutomated safety check: PassAGPL-3.0
Azure AI Projects Python SDKmicrosoft/skills3.1k6 repos~2.8kAutomated safety check: PassMIT
Fine-Tuning ExpertJeffallan/claude-skills12k1 repos~1.7kAutomated safety check: PassMIT

Similar skills

  • Chroma Vector Database

    Orchestra-Research/AI-Research-SKILLs

    Shows how to store documents and embeddings in Chroma, query them by similarity with metadata filters, and persist them to disk for RAG and semantic search projects.

    13k GitHub starsUsed in 8 repos~2.3k tokens
    AI & LLM EngineeringAuto-check passed
  • CLIP Image-Text Matching

    Orchestra-Research/AI-Research-SKILLs

    Explains OpenAI's CLIP model for zero-shot image classification, image-text similarity, semantic image search and content moderation, with install steps and code patterns.

    13k GitHub starsUsed in 8 repos~1.7k tokens
    AI & LLM EngineeringAuto-check passed
  • Codebase Management

    giancarloerra/SocratiCode

    Set up, index, and manage SocratiCode codebase indexing. An agent skill from giancarloerra/SocratiCode.

    3.3k GitHub starsUsed in 1 repo~1.8k tokens
    AI & LLM EngineeringAuto-check passed
  • Official

    Reference for building on Microsoft Foundry with the azure-ai-projects Python SDK: project clients, versioned agents, evaluations, connections, datasets and indexes.

    3.1k GitHub starsUsed in 6 repos~2.8k tokens
    AI & LLM EngineeringAuto-check passed
  • Fine-Tuning Expert

    Jeffallan/claude-skills

    Guides LLM fine-tuning with LoRA and QLoRA through Hugging Face PEFT, from dataset validation and training checks to adapter merging, quantization and deployment.

    12k GitHub starsUsed in 1 repo~1.7k tokens
    AI & LLM EngineeringAuto-check passed
  • Docs Planner

    strands-agents/harness-sdk

    Identify documentation gaps and prioritize the docs backlog.

    8.7k GitHub stars~821 tokensUpdated yesterday
    AI & LLM EngineeringAuto-check passed

More from ag2ai/build-with-ag2

All 16 skills in this repo
  • Ag2 Add Custom Tool

    ag2ai/build-with-ag2

    Add a custom Python tool to an AG2 beta Agent using the @tool decorator.

    252 GitHub stars~1.9k tokensUpdated 1 mo ago
    Auto-check passed
  • Ag2 Middleware

    ag2ai/build-with-ag2

    Intercept the AG2 beta agent loop with BaseMiddleware — wrap full turns (onturn), each LLM call (onllmcall), each tool execution (ontoolexecution), or each human-input request (onhumaninput).

    252 GitHub stars~1.9k tokensUpdated 1 mo ago
    Auto-check passed
  • Ag2 Use Builtin Tools

    ag2ai/build-with-ag2

    Wire AG2 beta's shipped tools into an Agent — both provider-native server-side tools (web search, web fetch, code execution, MCP, image generation, memory) and locally-executed common toolkits…

    252 GitHub stars~1.3k tokensUpdated 1 mo ago
    Auto-check passed
  • Ag2 Knowledge And Memory

    ag2ai/build-with-ag2

    Persist agent state across runs, shape what the LLM sees per turn, and cap history to fit a context window.

    252 GitHub stars~2.9k tokensUpdated 1 mo ago
    Auto-check passed
  • Ag2 Observers And Alerts

    ag2ai/build-with-ag2

    Monitor an AG2 beta agent's stream — log events, detect repeated tool calls, track token spend, build trigger-driven observers, route observer alerts to the model, and halt on FATAL conditions.

    252 GitHub stars~2.5k tokensUpdated 1 mo ago
    Auto-check passed
  • Ag2 Structured Output

    ag2ai/build-with-ag2

    Get a typed Python value back from an AG2 beta Agent instead of free text.

    252 GitHub stars~1.8k tokensUpdated 1 mo ago
    Auto-check passed

Works with

Questions about Ag2 Quickstart

What does Ag2 Quickstart do?

Build a minimal AG2 beta Agent end to end — pick a model provider, set a prompt, call agent.ask(), then continue the conversation with reply.ask() (multi-turn). Ag2 Quickstart is an agent skill from ag2ai/build-with-ag2.ask() (multi-turn).

When should I use Ag2 Quickstart?

Ag2 Quickstart fits situations like: the user is starting a new AG2 beta project; has no working Agent yet; needs the multi-turn chaining pattern.

How do I install Ag2 Quickstart in Claude Code?

Run `npx skills add ag2ai/build-with-ag2 --skill ag2-quickstart -a claude-code`. Or copy the skill folder (.agents/skills/ag2-quickstart in ag2ai/build-with-ag2) into .claude/skills/ag2-quickstart in your project. Claude Code loads it when a task matches its description.

How do I install Ag2 Quickstart in Codex?

Run `npx skills add ag2ai/build-with-ag2 --skill ag2-quickstart -a codex`. Or copy the skill folder (.agents/skills/ag2-quickstart in ag2ai/build-with-ag2) into .agents/skills/ag2-quickstart in your project. Codex loads it when a task matches its description.

Can I use Ag2 Quickstart in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add ag2ai/build-with-ag2 --skill ag2-quickstart -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/ag2-quickstart, .gemini/skills/ag2-quickstart, .github/skills/ag2-quickstart and .opencode/skills/ag2-quickstart in your project.

What does Ag2 Quickstart need to run?

Going by SKILL.md and its folder, Ag2 Quickstart needs Python for the scripts in its folder, the command-line tools its instructions call (pip and python) and credentials named OPENAI_API_KEY, ANTHROPIC_API_KEY, GEMINI_API_KEY and GOOGLE_API_KEY. Our summary lists: Python 3; A credential in OPENAI_API_KEY; A credential in ANTHROPIC_API_KEY.

Does Ag2 Quickstart access the network?

SKILL.md contains no URLs. Its commands use pip, which can reach the network depending on how they are called. This is read from the text; nothing was executed.

Is Ag2 Quickstart safe to install?

Our automated static check of SKILL.md found notes only (mentions a .env file), nothing it rates as a warning. It is not a guarantee. Review the folder before installing.

What licence does Ag2 Quickstart use?

Ag2 Quickstart is published under the Apache-2.0 licence (declared in SKILL.md). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Ag2 Quickstart use?

About 1.7k tokens (SKILL.md is roughly 6.6k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to Ag2 Quickstart?

Skills that share tags, products or a category with Ag2 Quickstart: Chroma Vector Database (Orchestra-Research/AI-Research-SKILLs, 13k stars), CLIP Image-Text Matching (Orchestra-Research/AI-Research-SKILLs, 13k stars), Codebase Management (giancarloerra/SocratiCode, 3.3k stars) and Azure AI Projects Python SDK (microsoft/skills, 3.1k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Ag2 Quickstart?

ag2ai (a GitHub organization) maintains it in ag2ai/build-with-ag2, which has 252 GitHub stars. The repository holds 16 skills in this directory. The repository was last updated on September 6, 2026.

Source: ag2ai/build-with-ag2 on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.