Agent skill

Ag2 Ag UI

by ag2ai in ag2ai/build-with-ag2

Expose an AG2 beta Agent over the AG-UI protocol so a frontend (CopilotKit, custom React/Next.js, or any AG-UI client) can stream responses, render tool calls, sync shared state, and surface…

Apache-2.0Auto-check passedBackend & APIs

Install Ag2 Ag UI

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

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

GitHub CLI
$ gh skill install ag2ai/build-with-ag2 ag2-ag-ui --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-ag-ui .claude/skills/ag2-ag-ui && 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-ag-ui
GitHub stars
252
Token cost
~1.7k tokens
SKILL.md length
426 words
Files
1
Skills in repo
16
Repo updated
First seen
Licence
Apache-2.0

At a glance

Expose an AG2 beta Agent over the AG-UI protocol so a frontend (CopilotKit, custom React/Next.js, or any AG-UI client) can stream responses, render tool calls, sync shared state, and surface…

  • The user wants a web frontend in front of an AG2 agent rather than a CLI / script
  • SKILL.md covers When to use, Supported AG-UI features, Installation and 60-second recipe — FastAPI…, plus 5 more sections
  • Calls pip, curl and uvicorn; reaches github.com
  • Tasks that involve Backend development

What it does

Ag2 Ag UI is an agent skill from ag2ai/build-with-ag2. Expose an AG2 beta Agent over the AG-UI protocol so a frontend (CopilotKit, custom React/Next.js, or any AG-UI client) can stream responses, render tool calls, sync shared state, and surface human-input checkpoints. Wraps the agent with AGUIStream(agent) and mounts it in FastAPI via stream.dispatch(...) or stream.buildasgi(). Use when the user wants a web frontend in front of an AG2 agent rather than a CLI / script.

Its SKILL.md is about 1.7k tokens, which your agent loads only when the skill is triggered. It is a single SKILL.md file with no bundled scripts.

It sits in Backend & APIs, covering Backend development. It works with Next.js, React and FastAPI. 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 wants a web frontend in front of an AG2 agent rather than a CLI / script
  • Tasks that involve Backend development

Example prompts

  • “/ag2-ag-ui”

Requirements

  • Python 3
  • Node.js

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

    Shell commands in SKILL.md call:

    • pip
    • curl
    • uvicorn
    • npx

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

  • Network

    Hosts in commands or code, which the agent is likely to contact:

    • github.com

    Also links to:

    • docs.ag-ui.com
    • dojo.ag-ui.com

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

  • Credentials

    Names no API keys, tokens, secrets or passwords.

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

Context cost

Ag2 Ag UI loads about 1.7k tokens when it runs. Until then it costs about 110 tokens; SKILL.md has 426 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~110
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 passed

The automated check found no risky patterns in SKILL.md.

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). 426 words, ~1,658 tokens.

Download SKILL.mdSave it as .claude/skills/ag2-ag-ui/SKILL.md (or your agent's skills folder).
name
ag2-ag-ui
description
Expose an AG2 beta `Agent` over the AG-UI protocol so a frontend (CopilotKit, custom React/Next.js, or any AG-UI client) can stream responses, render tool calls, sync shared state, and surface human-input checkpoints. Wraps the agent with `AGUIStream(agent)` and mounts it in FastAPI via `stream.dispatch(...)` or `stream.build_asgi()`. Use when the user wants a web frontend in front of an AG2 agent rather than a CLI / script.
license
Apache-2.0

AG-UI integration

When to use

  • The user is building a web UI (React / Next.js / anything HTTP+SSE) that should talk to an AG2 beta agent.
  • They want streaming text, tool-call rendering, shared state sync, or HITL checkpoints surfaced to the frontend with a standard protocol — not a custom REST/WebSocket contract.
  • They're using or considering CopilotKit (the recommended React client).

For a custom narrow-purpose API where you own the contract end-to-end, skip AG-UI and write a plain endpoint instead.

Supported AG-UI features

FeatureStatus
Streaming text events (TEXT_MESSAGE_*, TEXT_MESSAGE_CHUNK)✓
Backend tool lifecycle (TOOL_CALL_START / _ARGS / _RESULT / _END)✓
Frontend-tool dispatch (TOOL_CALL_CHUNK for client tools in RunAgentInput.tools)✓
Shared-state snapshots (STATE_SNAPSHOT)✓
Human input checkpoints (surfaced as user-visible message events)✓

Installation

bash
pip install "ag2[ag-ui]"

60-second recipe — FastAPI server

python
from fastapi import FastAPI, Header
from fastapi.responses import StreamingResponse

from autogen.beta import Agent
from autogen.beta.ag_ui import AGUIStream, RunAgentInput
from autogen.beta.config import OpenAIConfig

agent = Agent(
    name="support_bot",
    prompt="You help users with billing questions.",
    config=OpenAIConfig(model="gpt-4o-mini"),
)

stream = AGUIStream(agent)
app = FastAPI()

@app.post("/chat")
async def run_agent(message: RunAgentInput, accept: str | None = Header(None)) -> StreamingResponse:
    return StreamingResponse(
        stream.dispatch(message, accept=accept),
        media_type=accept or "text/event-stream",
    )
bash
uvicorn run_ag_ui:app --reload --port 8000

Test:

bash
curl -N -X POST http://127.0.0.1:8000/chat \
  -H "Content-Type: application/json" \
  -H "Accept: text/event-stream" \
  -d '{"thread_id":"t1","run_id":"r1","messages":[{"id":"m1","role":"user","content":"Hello"}],"state":{},"context":[],"tools":[]}'

Lower-friction alternative — build_asgi()

If you don't need custom auth / middleware, mount the ASGI endpoint directly:

python
from autogen.beta.ag_ui import AGUIStream
from fastapi import FastAPI

app = FastAPI()
stream = AGUIStream(agent)
app.mount("/chat", stream.build_asgi())

Two ways to start:

bash
# Option A — CopilotKit bootstrap
npx copilotkit@latest create -f ag2

# Option B — clone the reference starter
# https://github.com/ag2ai/ag2-copilotkit-starter

The starter layout:

ag2-copilotkit-starter/
├── agent-py/     # Python backend (AG2 + AG-UI)
└── ui-react/     # React + CopilotKit frontend

Backend serves /chat on port 8008 by default. The Next.js route at ui-react/app/api/copilotkit/route.ts bridges the UI to the backend:

tsx
import { HttpAgent } from "@ag-ui/client";
import { CopilotRuntime, ExperimentalEmptyAdapter, copilotRuntimeNextJSAppRouterEndpoint } from "@copilotkit/runtime";
import { NextRequest } from "next/server";

const agent = new HttpAgent({ url: "http://localhost:8008/chat" });
const runtime = new CopilotRuntime({ agents: { weather_agent: agent } });

export async function POST(req: NextRequest) {
  const { handleRequest } = copilotRuntimeNextJSAppRouterEndpoint({
    runtime,
    serviceAdapter: new ExperimentalEmptyAdapter(),
    endpoint: "/api/copilotkit",
  });
  return handleRequest(req);
}

Wrap your app:

tsx
import { CopilotKit } from "@copilotkit/react-core";
import "@copilotkit/react-ui/styles.css";

export default function RootLayout({ children }: { children: React.ReactNode }) {
  return (
    <html lang="en">
      <body>
        <CopilotKit agent="weather_agent" runtimeUrl="/api/copilotkit">
          {children}
        </CopilotKit>
      </body>
    </html>
  );
}

Render chat (<CopilotChat />), and use useCopilotAction({...}) in client components to render generative UI tied to backend tool calls.

Production checklist

  • CORS — allow your frontend origin on the AG-UI backend (POST, OPTIONS, auth headers).
  • Auth — protect both /api/copilotkit (Next.js route) and backend /chat. Don't rely on client-only secrets.
  • SSE buffering — verify backend response is Content-Type: text/event-stream and that proxy layers (Nginx, CloudFront, etc.) don't buffer SSE.
  • Timeouts / retries — conservative values for long-running tool workflows; only retry idempotent requests.
  • Tool inputs are untrusted — validate and authorize server-side before invoking privileged tools. Log tool execution with request IDs.
  • Tool name parity — frontend useCopilotAction name must match backend @tool name exactly.
Show full SKILL.md (150 more words)Show less

Going deeper

Common pitfalls

  • Missing ag-ui extra — pip install "ag2[ag-ui]" is required; without it from autogen.beta.ag_ui import AGUIStream will fail.
  • CORS blocked — frontend can't hit the backend in dev. Add CORSMiddleware to the FastAPI app for the dev origin.
  • No streaming output — proxy or Content-Type issue. Test with raw curl -N first to isolate.
  • Tool UI not rendering — tool name on the React side (useCopilotAction({ name: "..." })) doesn't exactly match the backend @tool name.
  • Putting the endpoint behind a SSE-incompatible proxy — many proxies buffer event-stream responses by default. Disable buffering on the route.
  • Trying to use AGUIStream with classic ConversableAgent — the description here covers autogen.beta.Agent. Classic AG2 agents can be exposed differently; check the AG2 docs for that path.

© 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

Just SKILL.md in .agents/skills/ag2-ag-ui of ag2ai/build-with-ag2.

Open the folder on GitHubat commit 29eeac3

Compare with similar skills

Ag2 Ag UI 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 Ag UI compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Ag2 Ag UI this skillag2ai/build-with-ag2252—~1.7kAutomated safety check: PassApache-2.0
Docs Guidefivetaku/gptaku-plugins-codex128—~3.5kAutomated safety check: PassMIT
Htmxericrisco/rsc-harness180—~3.4kAutomated safety check: PassMIT
Senior Fullstackalirezarezvani/claude-skills28k1 repos~3.7kAutomated safety check: NotesMIT
Senior Fullstackborghei/Claude-Skills891—~1.7kAutomated safety check: PassMIT
Clean Code Refactorerfike/fastapi-blog101—~402Automated safety check: PassMIT

Similar skills

  • Docs Guide

    fivetaku/gptaku-plugins-codex

    Fetch and explain official documentation for any library, framework, API, or service using an llms.txt-first strategy — triggers on "How do I…", "What is…", "How does X work", "Best practice for…"…

    128 GitHub stars~3.5k tokensUpdated 1 mo ago
    Backend & APIsAuto-check passed
  • Htmx

    ericrisco/rsc-harness

    A skill your agent uses when adding interactivity to a server-rendered app (FastAPI/Jinja, Django, Rails, Laravel, Go templates, Express) without adopting a JS framework — hx-get/post/put/delete…

    180 GitHub stars~3.4k tokensUpdated today
    Backend & APIsAuto-check passed
  • Senior Fullstack

    alirezarezvani/claude-skills

    Fullstack development toolkit with project scaffolding for Next.js, FastAPI, MERN, and Django stacks, code quality analysis with security and complexity scoring, and stack selection guidance.

    28k GitHub starsUsed in 1 repo~3.7k tokens
    DevelopmentAuto-check: notes
  • Senior Fullstack

    borghei/Claude-Skills

    Fullstack development toolkit with project scaffolding for Next.js/FastAPI/MERN/Django stacks and code quality analysis.

    891 GitHub stars~1.7k tokensUpdated 3 days ago
    DevelopmentAuto-check passed
  • Clean Code Refactorer

    fike/fastapi-blog

    Skill for identifying code smells and refactoring code using Clean Code, SOLID, and DRY principles.

    101 GitHub stars~402 tokensUpdated yesterday
    DevelopmentAuto-check passed
  • Andrej Karpathy Perspective

    nazarli-shabnam/clevis

    Andrej Karpathy的思维框架与表达方式。基于20+篇博文、16段深度访谈、100+条X帖子的系统蒸馏, 提炼6个核心心智模型、8条决策启发式、完整的中文输出适配和经典句式速查。

    170 GitHub starsUsed in 2 repos~3.8k tokens
    Backend & APIsAuto-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 Quickstart

    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).

    252 GitHub stars~1.7k tokensUpdated 1 mo ago
    Auto-check: notes

Categories

Questions about Ag2 Ag UI

What does Ag2 Ag UI do?

Expose an AG2 beta Agent over the AG-UI protocol so a frontend (CopilotKit, custom React/Next.js, or any AG-UI client) can stream responses, render tool calls, sync shared state, and surface…. Ag2 Ag UI is an agent skill from ag2ai/build-with-ag2.js, or any AG-UI client) can stream responses, render tool calls, sync shared state, and surface human-input checkpoints.

When should I use Ag2 Ag UI?

Ag2 Ag UI fits situations like: the user wants a web frontend in front of an AG2 agent rather than a CLI / script; tasks that involve Backend development.

How do I install Ag2 Ag UI in Claude Code?

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

How do I install Ag2 Ag UI in Codex?

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

Can I use Ag2 Ag UI 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-ag-ui -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-ag-ui, .gemini/skills/ag2-ag-ui, .github/skills/ag2-ag-ui and .opencode/skills/ag2-ag-ui in your project.

What does Ag2 Ag UI need to run?

Going by SKILL.md and its folder, Ag2 Ag UI needs the command-line tools its instructions call (pip, curl, uvicorn and npx). Our summary lists: Python 3; Node.js.

Does Ag2 Ag UI access the network?

SKILL.md names 3 domains. In commands or code: github.com; the agent is likely to contact it when it follows the instructions. As links in the text: docs.ag-ui.com and dojo.ag-ui.com. This is read from the text; nothing was executed.

Is Ag2 Ag UI safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Ag2 Ag UI use?

Ag2 Ag UI 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 Ag UI 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 Ag UI?

Skills that share tags, products or a category with Ag2 Ag UI: Docs Guide (fivetaku/gptaku-plugins-codex, 128 stars), Htmx (ericrisco/rsc-harness, 180 stars), Senior Fullstack (alirezarezvani/claude-skills, 28k stars) and Senior Fullstack (borghei/Claude-Skills, 891 stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Ag2 Ag UI?

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.