A AgDex.ai
Directory Blog About Contact
AgDex.ai / Blog / AG-UI Protocol Architecture

AG-UI Protocol Explained: The Missing Frontend Layer After MCP & A2A (2026)

AgDex Engineering Editorial • • 14 min read • Agentic Protocols • Dec 2026
AG-UI Protocol Explained: The Missing Frontend Layer After MCP & A2A (2026)
TL;DR: Why AG-UI 1.0 Completes the Agentic Protocol Stack

By late 2026, MCP standardized how agents call tools and A2A standardized how agents delegate tasks to each other—yet frontends were still glued together with brittle, framework-specific SSE hacks. AG-UI (Agent–User Interaction Protocol)—an MIT-licensed open standard with 22.3k GitHub stars, 31 typed events across 8 families, and native JSON Patch (RFC 6902) state synchronization—provides the missing runtime wire between backend agents and user-facing apps.

1. The Missing Layer After MCP and A2A

Modern agentic systems are no longer simple request-response chatbots. A single user prompt in a coding workspace, analytics dashboard, or enterprise copilot can trigger multi-minute reasoning, subagent delegation, tool execution, and mid-flight human approval. While Anthropic's Model Context Protocol (MCP) solved Agent ↔ Tools connectivity and Google's Agent-to-Agent (A2A) protocol solved Agent ↔ Agent orchestration, neither protocol was designed to manage the stateful, high-frequency, bi-directional UI loop between an agent and a human user.

+─────────────────────────────────────────────────────────────────────────────────────────────────+
|          Table 1: The 2026 Agentic Protocol Stack — MCP vs A2A vs AG-UI vs GenUI Specs          |
+──────────────────────────┬────────────────────────┬──────────────────────┬──────────────────────+
| Protocol / Spec          | Layer & Direction      | Primary Transport    | Core Responsibility  |
+──────────────────────────┼────────────────────────┼──────────────────────┼──────────────────────+
| MCP (Anthropic)          | Agent <-> Tools & Data | stdio / Streamable   | Tool discovery, auth,|
|                          |                        | HTTP (JSON-RPC 2.0)  | & resource context   |
+──────────────────────────┼────────────────────────┼──────────────────────┼──────────────────────+
| A2A (Google)             | Agent <-> Agent        | HTTP + SSE / JSON-   | Cross-agent task     |
|                          |                        | RPC (Agent Cards)    | delegation & handoff |
+──────────────────────────┼────────────────────────┼──────────────────────┼──────────────────────+
| AG-UI 1.0 (MIT, 22.3k*)  | Agent <-> User / App   | HTTP+SSE (default),  | 31-event streaming,  |
|                          |                        | Protobuf, WebSockets | RFC 6902 state, HITL |
+──────────────────────────┼────────────────────────┼──────────────────────┼──────────────────────+
| A2UI / MCP Apps /        | Declarative UI Schema  | Carried over AG-UI   | Dynamic UI widget    |
| Open-JSON-UI             | (Agent -> Renderer)    | or MCP payloads      | & card definitions   |
+──────────────────────────┴────────────────────────┴──────────────────────┴──────────────────────+

Without a shared frontend wire standard, every team rebuilding an AI product ends up inventing proprietary JSON-over-SSE schemas for token streaming, tool-call progress, reasoning traces, and mutable UI state. Every time the backend migrates—for example from LangGraph to Google ADK, Mastra, CrewAI, or Pydantic AI—the React or mobile client breaks.

AG-UI 1.0 solves this exact boundary. Maintained as an MIT-licensed open protocol at ag-ui-protocol/ag-ui (22.3k stars, 2.1k forks, 168+ contributors), AG-UI sits cleanly alongside MCP and A2A so one agent can speak MCP to databases, A2A to peer agents, and AG-UI to the user interface.

2. AG-UI 1.0 Wire Architecture: 31 Events Across 8 Families

AG-UI is transport-agnostic: HTTP + Server-Sent Events (SSE) is the mandatory default binding for HTTP servers, with an optional binary HTTP + Protobuf binding and support for WebSockets, webhooks, or in-process pipes. Every message emitted by the agent conforms to a lightweight BaseEvent envelope containing a required type plus optional timestamp, rawEvent, metadata, and subagentRunId.

+─────────────────────────────────────────────────────────────────────────────────────────────────+
|           AG-UI 1.0 Bi-Directional Runtime Architecture (HTTP+SSE / Protobuf / RFC 6902)        |
+─────────────────────────────────────────────────────────────────────────────────────────────────+
|                                                                                                 |
|  [User App: React / CopilotKit / Terminal / Slack]     [Backend Agent: LangGraph / ADK / CrewAI]|
|         │                                                     ▲                                 |
|         ├─ 1. HTTP POST (RunAgentInput JSON) ─────────────────┤                                 |
|         │     { threadId, runId, state, messages, tools }     │                                 |
|         │                                                     ▼                                 |
|         │  2. SSE Stream (31 Event Types, 8 Families) ────────┤                                 |
|         │◀──── RUN_STARTED / STEP_STARTED / SUBAGENT_STARTED  │  (MCP Tools & A2A Subagents)    |
|         │◀──── REASONING_MESSAGE_CONTENT (delta)              │                                 |
|         │◀──── TEXT_MESSAGE_CONTENT (delta)                   │                                 |
|         │◀──── STATE_SNAPSHOT / STATE_DELTA (RFC 6902 Patch)  │                                 |
|         │◀──── TOOL_CALL_START -> ARGS -> END (Frontend HITL) │                                 |
|         │                                                     │                                 |
|         └─ 3. Next Turn: Send TOOL_CALL_RESULT + Updated State┘                                 |
+─────────────────────────────────────────────────────────────────────────────────────────────────+

According to the AG-UI 1.0 specification, the protocol defines 31 typed events organized into 8 clean families:

  • Runs, Steps & Subagents: RUN_STARTED, RUN_FINISHED, RUN_ERROR, STEP_STARTED, STEP_FINISHED, plus SUBAGENT_STARTED, SUBAGENT_FINISHED, and SUBAGENT_ERROR for multi-agent attribution via subagentRunId.
  • Text & Reasoning Streams: TEXT_MESSAGE_START/CONTENT/END/CHUNK for assistant output, alongside REASONING_START/END, REASONING_MESSAGE_*, and REASONING_ENCRYPTED_VALUE (replacing deprecated THINKING_* events).
  • Tool Calls & Passthrough: TOOL_CALL_START, TOOL_CALL_ARGS, TOOL_CALL_END, TOOL_CALL_CHUNK, and TOOL_CALL_RESULT for backend or frontend tools, plus RAW and CUSTOM passthrough events.
  • State & Activity Snapshots: STATE_SNAPSHOT, STATE_DELTA, MESSAGES_SNAPSHOT, ACTIVITY_SNAPSHOT, and ACTIVITY_DELTA to synchronize rich application state without re-transmitting full payloads.

Because the wire contract is strictly typed across TypeScript (@ag-ui/[email protected]), Python (ag-ui-protocol), and .NET (AGUI.Client), frontend components can subscribe to lifecycle, reasoning, tool, and state events deterministically.

3. Shared State (RFC 6902), Human-in-the-Loop & Python SSE Server

Two capabilities separate AG-UI from basic LLM chat wrappers: incremental state synchronization and interruptible tool loops. Instead of forcing the agent to re-emit a 50 KB JSON document on every step, AG-UI emits an initial STATE_SNAPSHOT followed by compact STATE_DELTA arrays formatted as standard JSON Patch (RFC 6902) operations (add, remove, replace, move, copy, test).

# server.py — Official AG-UI Python FastAPI SSE Endpoint (pip install ag-ui-protocol fastapi uvicorn)
import uuid
from fastapi import FastAPI, Request
from fastapi.responses import StreamingResponse
from ag_ui.core import (
    PROTOCOL_VERSION,
    RunAgentInput,
    RunStartedEvent,
    RunFinishedEvent,
    TextMessageStartEvent,
    TextMessageContentEvent,
    TextMessageEndEvent,
)
from ag_ui.encoder import EventEncoder

app = FastAPI()

@app.post("/")
async def run_agent(input_data: RunAgentInput, request: Request):
    encoder = EventEncoder(accept=request.headers.get("accept"))

    async def events():
        yield encoder.encode(RunStartedEvent(
            thread_id=input_data.thread_id,
            run_id=input_data.run_id,
            protocol_version=PROTOCOL_VERSION,
        ))
        message_id = str(uuid.uuid4())
        yield encoder.encode(TextMessageStartEvent(message_id=message_id, role="assistant"))
        for chunk in ["Hello ", "from ", "AG-UI!"]:
            yield encoder.encode(TextMessageContentEvent(message_id=message_id, delta=chunk))
        yield encoder.encode(TextMessageEndEvent(message_id=message_id))
        yield encoder.encode(RunFinishedEvent(
            thread_id=input_data.thread_id,
            run_id=input_data.run_id,
        ))

    return StreamingResponse(events(), media_type=encoder.get_content_type())

On the server side, standing up a compliant AG-UI FastAPI endpoint takes under 35 lines of Python using ag_ui.core and EventEncoder. EventEncoder(accept=request.headers.get("accept")) automatically negotiates text/event-stream (SSE) or Protobuf based on the client's Accept header.

For Human-in-the-Loop (HITL) workflows—such as approving a production database migration or editing an email draft—the backend emits TOOL_CALL_START, streams arguments via TOOL_CALL_ARGS, and closes with TOOL_CALL_END. The frontend renders an interactive confirmation card, awaits user input, and sends the resulting TOOL_CALL_RESULT back on the next RunAgentInput turn.

4. TypeScript HttpAgent Client & Late-2026 Ecosystem

On the client side, @ag-ui/[email protected] ships HttpAgent for Node.js 20+ and browser runtimes. You attach bearer headers, append user messages, and pass typed event callbacks such as onRunStartedEvent, onTextMessageContentEvent, and onRunFinishedEvent.

// client.ts — Official AG-UI TypeScript Client (npm install @ag-ui/client tsx)
import { HttpAgent } from "@ag-ui/client";

const agent = new HttpAgent({
  url: "http://localhost:8000/",
  headers: {
    Authorization: `Bearer ${process.env.AGENT_API_KEY ?? ""}`,
  },
});

agent.addMessage({
  id: crypto.randomUUID(),
  role: "user",
  content: "Hi there! Summarize our deployment state.",
});

await agent.runAgent({}, {
  onRunStartedEvent: ({ event }) =>
    console.log(`run started (AG-UI ${event.protocolVersion})`),
  onTextMessageContentEvent: ({ event }) => {
    process.stdout.write(event.delta);
  },
  onRunFinishedEvent: () => console.log("\nrun finished"),
});

Following the Release 2026-11-17 (core 1.0.5 + @ag-ui/[email protected]), Release 2026-11-21 (ag_ui_adk==0.14.0, ag-ui-openai-agents==0.2.0), and Release 2026-11-27 (@ag-ui/[email protected], ag-ui-langgraph==0.1.0) updates, AG-UI now spans virtually every major agent runtime:

+─────────────────────────────────────────────────────────────────────────────────────────────────+
|            Table 2: Frontend-to-Agent Transport Comparison (AG-UI 1.0 vs Alternatives)          |
+──────────────────────────┬──────────────────────┬───────────────────────┬───────────────────────+
| Capability               | Custom Ad-Hoc SSE    | Raw WebSockets        | AG-UI 1.0 Protocol    |
+──────────────────────────┼──────────────────────┼───────────────────────┼───────────────────────+
| Event Taxonomy           | Proprietary JSON per | Unstandardized frames | 31 typed events across|
|                          | backend framework    | & custom reconnects   | 8 standard families   |
+──────────────────────────┼──────────────────────┼───────────────────────┼───────────────────────+
| Shared Mutable State     | Re-send full JSON or | Manual diffing &      | Native STATE_SNAPSHOT |
|                          | custom Redux actions | conflict handling     | + STATE_DELTA RFC 6902|
+──────────────────────────┼──────────────────────┼───────────────────────┼───────────────────────+
| Frontend Tool & HITL     | Fragile polling or   | Custom RPC correlation| Built-in TOOL_CALL_*  |
| Approval Loops           | ad-hoc callbacks     | IDs & state machines  | & TOOL_CALL_RESULT    |
+──────────────────────────┼──────────────────────┼───────────────────────┼───────────────────────+
| Framework Portability    | Rewritten per agent  | Tightly coupled to    | Official adapters for |
|                          | framework upgrade    | socket server code    | LangGraph/ADK/Mastra+ |
+──────────────────────────┴──────────────────────┴───────────────────────┴───────────────────────+

Supported frameworks include LangGraph, CrewAI, Google ADK, Microsoft Agent Framework, AWS Strands Agents, Mastra, Pydantic AI, LlamaIndex, Agno, AG2, Claude Agent SDK, OpenAI Agents SDK, Spring AI, and Cloudflare Agents—alongside community SDKs for Kotlin, Go, Java, Rust, Swift, and Dart.

5. AG-UI vs Generative UI Specs (A2UI, MCP Apps, Open-JSON-UI)

A common architectural misconception is treating AG-UI as a competitor to declarative UI schemas like Google's A2UI, OpenAI's Open-JSON-UI, or Microsoft & Shopify's MCP Apps. In reality, they operate at different layers of the stack:

  • Declarative UI Specs (What to Render): A2UI, MCP Apps, and Open-JSON-UI describe the layout, fields, and actions of dynamic widgets, cards, and interactive forms.
  • AG-UI Runtime Protocol (How It Streams & Syncs): AG-UI is the bi-directional transport and event loop that carries those declarative payloads alongside text tokens, reasoning traces, and RFC 6902 state deltas.
  • First-Class Middleware Support: The repository ships official bridges such as @ag-ui/[email protected] so teams can render A2UI or MCP Apps components directly inside CopilotKit, React, Angular, Vue, or terminal clients.

Think of AG-UI as the WebSocket/SSE nervous system, while A2UI or MCP Apps are the visual payload cards riding across it.

6. Production Deployment Checklist & Stack Integration

To adopt AG-UI 1.0 cleanly in production without rewriting your agent logic, follow this four-step rollout:

# 1. Scaffold a full-stack AG-UI + CopilotKit application
npx create-ag-ui-app@latest

# 2. Or install core packages directly in TypeScript / Python / .NET
npm install @ag-ui/[email protected] @ag-ui/[email protected] @ag-ui/[email protected]
pip install ag-ui-protocol ag-ui-langgraph==0.1.0
dotnet add package AGUI.Client
  • Step 1 — Scaffold or Add Core Packages: Use npx create-ag-ui-app@latest for new projects, or add @ag-ui/[email protected] and ag-ui-protocol to an existing frontend/backend pair.
  • Step 2 — Use Official Framework Middleware: Pick the native adapter for your orchestrator (e.g., ag-ui-langgraph==0.1.0, ag_ui_adk==0.14.0, or @ag-ui/[email protected]) instead of hand-rolling event encoders.
  • Step 3 — Isolate Subagent Events with subagentRunId: When delegating tasks over A2A or parallel worker graphs, tag nested events with subagentRunId so the UI can render collapsible subagent timelines cleanly.
  • Step 4 — Pair with MCP, A2A & Typed State Guards: Validate incoming RunAgentInput payloads and keep STATE_DELTA patches idempotent so client reconnects never corrupt shared UI state.

Explore the full protocol stack in the AgDex.ai Directory and 3-Step Stack Finder—including our MCP vs A2A Protocol Guide, deep dives on MCP, LangGraph, and CrewAI, plus Quick View specs for AG-UI Protocol, CopilotKit, and PydanticAI.

7. Frequently Asked Questions (FAQ)

Q1: Does AG-UI replace MCP or A2A?

No. MCP connects agents to tools and data, A2A connects agents to other agents, and AG-UI connects agents to user-facing frontends. Production agents commonly run all three together.

Q2: Why does AG-UI default to HTTP + SSE instead of requiring WebSockets?

HTTP POST + SSE works seamlessly through corporate proxies, CDNs, serverless edge workers, and standard load balancers, while still allowing optional Protobuf or custom WebSocket bindings when ultra-low-latency binary streaming is required.

Q3: How does AG-UI prevent huge JSON payloads when agent state changes?

AG-UI pairs an initial STATE_SNAPSHOT with incremental STATE_DELTA events encoded as JSON Patch (RFC 6902) operations, transmitting only the exact keys or array indices that changed.

Q4: Which client frameworks and languages are supported?

Official SDKs cover TypeScript (@ag-ui/client), Python (ag-ui-protocol), and .NET (AGUI.Client), with CopilotKit UI integrations for React, Angular, Vue, and React Native, plus community SDKs for Kotlin, Go, Java, Rust, Swift, and Dart.

Protocolo AG-UI explicado: la capa frontend que faltaba tras MCP y A2A (2026)

Equipo Editorial de Ingeniería AgDex • • 14 min de lectura • Protocolos Agénticos • Dic 2026
Protocolo AG-UI explicado: la capa frontend que faltaba tras MCP y A2A (2026)
Resumen ejecutivo: por qué AG-UI 1.0 completa el stack de protocolos

A finales de 2026, MCP estandarizó cómo los agentes invocan herramientas y A2A cómo delegan tareas entre sí, pero las interfaces seguían atadas con parches SSE propietarios. AG-UI (Agent–User Interaction Protocol)—estándar abierto bajo licencia MIT con 22.3k estrellas en GitHub, 31 eventos tipados en 8 familias y sincronización de estado con JSON Patch (RFC 6902)—provee el cableado en tiempo real entre agentes y aplicaciones.

1. La capa que faltaba después de MCP y A2A

Los sistemas agénticos modernos ya no son simples chats de petición-respuesta. Un solo prompt en un entorno de desarrollo o panel analítico puede disparar razonamiento prolongado, delegación a subagentes, ejecución de herramientas y aprobaciones humanas en medio del flujo. Aunque Model Context Protocol (MCP) de Anthropic resolvió Agente ↔ Herramientas y Agent-to-Agent (A2A) de Google resolvió Agente ↔ Agente, ninguno gestiona el bucle UI bidireccional y con estado entre agente y usuario.

+─────────────────────────────────────────────────────────────────────────────────────────────────+
|          Table 1: The 2026 Agentic Protocol Stack — MCP vs A2A vs AG-UI vs GenUI Specs          |
+──────────────────────────┬────────────────────────┬──────────────────────┬──────────────────────+
| Protocol / Spec          | Layer & Direction      | Primary Transport    | Core Responsibility  |
+──────────────────────────┼────────────────────────┼──────────────────────┼──────────────────────+
| MCP (Anthropic)          | Agent <-> Tools & Data | stdio / Streamable   | Tool discovery, auth,|
|                          |                        | HTTP (JSON-RPC 2.0)  | & resource context   |
+──────────────────────────┼────────────────────────┼──────────────────────┼──────────────────────+
| A2A (Google)             | Agent <-> Agent        | HTTP + SSE / JSON-   | Cross-agent task     |
|                          |                        | RPC (Agent Cards)    | delegation & handoff |
+──────────────────────────┼────────────────────────┼──────────────────────┼──────────────────────+
| AG-UI 1.0 (MIT, 22.3k*)  | Agent <-> User / App   | HTTP+SSE (default),  | 31-event streaming,  |
|                          |                        | Protobuf, WebSockets | RFC 6902 state, HITL |
+──────────────────────────┼────────────────────────┼──────────────────────┼──────────────────────+
| A2UI / MCP Apps /        | Declarative UI Schema  | Carried over AG-UI   | Dynamic UI widget    |
| Open-JSON-UI             | (Agent -> Renderer)    | or MCP payloads      | & card definitions   |
+──────────────────────────┴────────────────────────┴──────────────────────┴──────────────────────+

Sin un estándar compartido para el frontend, cada equipo termina inventando esquemas JSON sobre SSE propios para streaming de tokens, progreso de herramientas, trazas de razonamiento y estado mutable. Cada vez que el backend migra—por ejemplo de LangGraph a Google ADK, Mastra, CrewAI o Pydantic AI—el cliente React o móvil se rompe.

AG-UI 1.0 resuelve exactamente esa frontera. Mantenido bajo licencia MIT en ag-ui-protocol/ag-ui (22.3k estrellas, 2.1k forks, 168+ colaboradores), AG-UI convive con MCP y A2A para que un mismo agente hable MCP con bases de datos, A2A con otros agentes y AG-UI con la interfaz.

2. Arquitectura AG-UI 1.0: 31 eventos en 8 familias

AG-UI es agnóstico al transporte: HTTP + Server-Sent Events (SSE) es el enlace obligatorio por defecto en servidores HTTP, con un enlace binario opcional HTTP + Protobuf y soporte para WebSockets, webhooks o pipes locales. Cada mensaje emitido por el agente sigue el sobre BaseEvent con type obligatorio y campos opcionales timestamp, rawEvent, metadata y subagentRunId.

+─────────────────────────────────────────────────────────────────────────────────────────────────+
|           AG-UI 1.0 Bi-Directional Runtime Architecture (HTTP+SSE / Protobuf / RFC 6902)        |
+─────────────────────────────────────────────────────────────────────────────────────────────────+
|                                                                                                 |
|  [User App: React / CopilotKit / Terminal / Slack]     [Backend Agent: LangGraph / ADK / CrewAI]|
|         │                                                     ▲                                 |
|         ├─ 1. HTTP POST (RunAgentInput JSON) ─────────────────┤                                 |
|         │     { threadId, runId, state, messages, tools }     │                                 |
|         │                                                     ▼                                 |
|         │  2. SSE Stream (31 Event Types, 8 Families) ────────┤                                 |
|         │◀──── RUN_STARTED / STEP_STARTED / SUBAGENT_STARTED  │  (MCP Tools & A2A Subagents)    |
|         │◀──── REASONING_MESSAGE_CONTENT (delta)              │                                 |
|         │◀──── TEXT_MESSAGE_CONTENT (delta)                   │                                 |
|         │◀──── STATE_SNAPSHOT / STATE_DELTA (RFC 6902 Patch)  │                                 |
|         │◀──── TOOL_CALL_START -> ARGS -> END (Frontend HITL) │                                 |
|         │                                                     │                                 |
|         └─ 3. Next Turn: Send TOOL_CALL_RESULT + Updated State┘                                 |
+─────────────────────────────────────────────────────────────────────────────────────────────────+

Según la especificación AG-UI 1.0, el protocolo define 31 eventos tipados organizados en 8 familias:

  • Runs, Steps y Subagentes: RUN_STARTED, RUN_FINISHED, RUN_ERROR, STEP_STARTED, STEP_FINISHED, además de SUBAGENT_STARTED, SUBAGENT_FINISHED y SUBAGENT_ERROR con trazabilidad vía subagentRunId.
  • Streams de Texto y Razonamiento: TEXT_MESSAGE_START/CONTENT/END/CHUNK para la respuesta, junto con REASONING_START/END, REASONING_MESSAGE_* y REASONING_ENCRYPTED_VALUE (que reemplazan los eventos obsoletos THINKING_*).
  • Tool Calls y Passthrough: TOOL_CALL_START, TOOL_CALL_ARGS, TOOL_CALL_END, TOOL_CALL_CHUNK y TOOL_CALL_RESULT para herramientas de backend o frontend, más RAW y CUSTOM.
  • Snapshots de Estado y Actividad: STATE_SNAPSHOT, STATE_DELTA, MESSAGES_SNAPSHOT, ACTIVITY_SNAPSHOT y ACTIVITY_DELTA para sincronizar estado complejo sin reenviar payloads completos.

Al estar estrictamente tipado en TypeScript (@ag-ui/[email protected]), Python (ag-ui-protocol) y .NET (AGUI.Client), los componentes frontend se suscriben al ciclo de vida de forma determinista.

3. Estado compartido (RFC 6902), Human-in-the-Loop y servidor FastAPI

Dos capacidades distinguen a AG-UI de un simple chat LLM: la sincronización incremental de estado y los bucles de herramientas interrumpibles. En lugar de reenviar un JSON de 50 KB en cada paso, AG-UI envía un STATE_SNAPSHOT inicial seguido de compactos STATE_DELTA en formato estándar JSON Patch (RFC 6902) (add, remove, replace, move, copy, test).

# server.py — Official AG-UI Python FastAPI SSE Endpoint (pip install ag-ui-protocol fastapi uvicorn)
import uuid
from fastapi import FastAPI, Request
from fastapi.responses import StreamingResponse
from ag_ui.core import (
    PROTOCOL_VERSION,
    RunAgentInput,
    RunStartedEvent,
    RunFinishedEvent,
    TextMessageStartEvent,
    TextMessageContentEvent,
    TextMessageEndEvent,
)
from ag_ui.encoder import EventEncoder

app = FastAPI()

@app.post("/")
async def run_agent(input_data: RunAgentInput, request: Request):
    encoder = EventEncoder(accept=request.headers.get("accept"))

    async def events():
        yield encoder.encode(RunStartedEvent(
            thread_id=input_data.thread_id,
            run_id=input_data.run_id,
            protocol_version=PROTOCOL_VERSION,
        ))
        message_id = str(uuid.uuid4())
        yield encoder.encode(TextMessageStartEvent(message_id=message_id, role="assistant"))
        for chunk in ["Hello ", "from ", "AG-UI!"]:
            yield encoder.encode(TextMessageContentEvent(message_id=message_id, delta=chunk))
        yield encoder.encode(TextMessageEndEvent(message_id=message_id))
        yield encoder.encode(RunFinishedEvent(
            thread_id=input_data.thread_id,
            run_id=input_data.run_id,
        ))

    return StreamingResponse(events(), media_type=encoder.get_content_type())

En el servidor, levantar un endpoint FastAPI compatible con AG-UI requiere menos de 35 líneas usando ag_ui.core y EventEncoder. EventEncoder(accept=request.headers.get("accept")) negocia automáticamente text/event-stream (SSE) o Protobuf según la cabecera Accept.

Para flujos Human-in-the-Loop (HITL)—como aprobar una migración de base de datos o editar un borrador—el backend emite TOOL_CALL_START, transmite argumentos con TOOL_CALL_ARGS y cierra con TOOL_CALL_END. El frontend muestra la tarjeta de confirmación, espera al usuario y devuelve el TOOL_CALL_RESULT en el siguiente turno de RunAgentInput.

4. Cliente TypeScript HttpAgent y ecosistema de finales de 2026

En el cliente, @ag-ui/[email protected] incluye HttpAgent para Node.js 20+ y navegadores. Basta configurar la URL, cabeceras de autorización, añadir mensajes y registrar callbacks tipados como onRunStartedEvent, onTextMessageContentEvent y onRunFinishedEvent.

// client.ts — Official AG-UI TypeScript Client (npm install @ag-ui/client tsx)
import { HttpAgent } from "@ag-ui/client";

const agent = new HttpAgent({
  url: "http://localhost:8000/",
  headers: {
    Authorization: `Bearer ${process.env.AGENT_API_KEY ?? ""}`,
  },
});

agent.addMessage({
  id: crypto.randomUUID(),
  role: "user",
  content: "Hi there! Summarize our deployment state.",
});

await agent.runAgent({}, {
  onRunStartedEvent: ({ event }) =>
    console.log(`run started (AG-UI ${event.protocolVersion})`),
  onTextMessageContentEvent: ({ event }) => {
    process.stdout.write(event.delta);
  },
  onRunFinishedEvent: () => console.log("\nrun finished"),
});

Tras las entregas Release 2026-11-17 (core 1.0.5 + @ag-ui/[email protected]), Release 2026-11-21 (ag_ui_adk==0.14.0, ag-ui-openai-agents==0.2.0) y Release 2026-11-27 (@ag-ui/[email protected], ag-ui-langgraph==0.1.0), AG-UI cubre prácticamente todo el ecosistema:

+─────────────────────────────────────────────────────────────────────────────────────────────────+
|            Table 2: Frontend-to-Agent Transport Comparison (AG-UI 1.0 vs Alternatives)          |
+──────────────────────────┬──────────────────────┬───────────────────────┬───────────────────────+
| Capability               | Custom Ad-Hoc SSE    | Raw WebSockets        | AG-UI 1.0 Protocol    |
+──────────────────────────┼──────────────────────┼───────────────────────┼───────────────────────+
| Event Taxonomy           | Proprietary JSON per | Unstandardized frames | 31 typed events across|
|                          | backend framework    | & custom reconnects   | 8 standard families   |
+──────────────────────────┼──────────────────────┼───────────────────────┼───────────────────────+
| Shared Mutable State     | Re-send full JSON or | Manual diffing &      | Native STATE_SNAPSHOT |
|                          | custom Redux actions | conflict handling     | + STATE_DELTA RFC 6902|
+──────────────────────────┼──────────────────────┼───────────────────────┼───────────────────────+
| Frontend Tool & HITL     | Fragile polling or   | Custom RPC correlation| Built-in TOOL_CALL_*  |
| Approval Loops           | ad-hoc callbacks     | IDs & state machines  | & TOOL_CALL_RESULT    |
+──────────────────────────┼──────────────────────┼───────────────────────┼───────────────────────+
| Framework Portability    | Rewritten per agent  | Tightly coupled to    | Official adapters for |
|                          | framework upgrade    | socket server code    | LangGraph/ADK/Mastra+ |
+──────────────────────────┴──────────────────────┴───────────────────────┴───────────────────────+

Incluye integraciones oficiales con LangGraph, CrewAI, Google ADK, Microsoft Agent Framework, AWS Strands Agents, Mastra, Pydantic AI, LlamaIndex, Agno, AG2, Claude Agent SDK, OpenAI Agents SDK, Spring AI y Cloudflare Agents, junto con SDKs comunitarios en Kotlin, Go, Java, Rust, Swift y Dart.

5. AG-UI frente a especificaciones de UI generativa (A2UI, MCP Apps)

Un error común es ver a AG-UI como competidor de esquemas declarativos de interfaz como A2UI (Google), Open-JSON-UI (OpenAI) o MCP Apps (Microsoft y Shopify). En realidad operan en capas complementarias:

  • Especificaciones UI declarativas (Qué renderizar): A2UI, MCP Apps y Open-JSON-UI describen la estructura, campos y acciones de tarjetas y formularios dinámicos.
  • Protocolo de ejecución AG-UI (Cómo fluye y sincroniza): AG-UI es el transporte bidireccional y bucle de eventos que transporta esos payloads junto con tokens, razonamiento y deltas RFC 6902.
  • Middleware oficial incluido: El repositorio incluye puentes como @ag-ui/[email protected] para renderizar componentes A2UI o MCP Apps en CopilotKit, React, Angular, Vue o terminal.

AG-UI actúa como el sistema nervioso de transporte SSE/Protobuf, mientras que A2UI o MCP Apps son las tarjetas visuales que viajan sobre él.

6. Checklist de despliegue en producción e integración

Para adoptar AG-UI 1.0 en producción sin reescribir la lógica de tus agentes, sigue estos cuatro pasos:

# 1. Scaffold a full-stack AG-UI + CopilotKit application
npx create-ag-ui-app@latest

# 2. Or install core packages directly in TypeScript / Python / .NET
npm install @ag-ui/[email protected] @ag-ui/[email protected] @ag-ui/[email protected]
pip install ag-ui-protocol ag-ui-langgraph==0.1.0
dotnet add package AGUI.Client
  • Paso 1 — Inicializar o instalar paquetes base: Usa npx create-ag-ui-app@latest en proyectos nuevos o añade @ag-ui/[email protected] y ag-ui-protocol a tu stack actual.
  • Paso 2 — Usar adaptadores oficiales del framework: Emplea el middleware nativo (ag-ui-langgraph==0.1.0, ag_ui_adk==0.14.0 o @ag-ui/[email protected]) en lugar de codificar eventos manualmente.
  • Paso 3 — Aislar subagentes con subagentRunId: Al delegar tareas vía A2A o grafos paralelos, etiqueta los eventos con subagentRunId para renderizar líneas de tiempo limpias.
  • Paso 4 — Combinar con MCP, A2A y validación de parches: Valida cada RunAgentInput entrante y mantén idempotentes los parches STATE_DELTA ante reconexiones.

Explora todo el stack en el Directorio de AgDex.ai y el 3-Step Stack Finder—incluyendo nuestra Guía MCP vs A2A, análisis de MCP, LangGraph y CrewAI, y fichas Quick View de AG-UI Protocol, CopilotKit y PydanticAI.

7. Preguntas frecuentes (FAQ)

P1: ¿AG-UI reemplaza a MCP o A2A?

No. MCP conecta agentes con herramientas y datos, A2A conecta agentes entre sí y AG-UI conecta agentes con la interfaz de usuario. En producción suelen usarse los tres juntos.

P2: ¿Por qué AG-UI usa HTTP + SSE por defecto en lugar de exigir WebSockets?

HTTP POST + SSE atraviesa sin fricción proxies corporativos, CDNs, edge workers y balanceadores estándar, permitiendo igualmente Protobuf o WebSockets cuando se requiere baja latencia binaria.

P3: ¿Cómo evita AG-UI reenviar JSON enormes cuando cambia el estado?

Combina un STATE_SNAPSHOT inicial con eventos incrementales STATE_DELTA en formato JSON Patch (RFC 6902), transmitiendo solo las claves o índices modificados.

P4: ¿Qué lenguajes y frameworks frontend son compatibles?

Los SDKs oficiales cubren TypeScript (@ag-ui/client), Python (ag-ui-protocol) y .NET (AGUI.Client), con integración CopilotKit para React, Angular, Vue y React Native, además de SDKs comunitarios en Kotlin, Go, Java, Rust, Swift y Dart.

AG-UI-Protokoll erklärt: Die fehlende Frontend-Schicht nach MCP & A2A (2026)

AgDex Engineering-Redaktion • • 14 Min. Lesezeit • Agentic Protocols • Dez 2026
AG-UI-Protokoll erklärt: Die fehlende Frontend-Schicht nach MCP &amp; A2A (2026)
Kurzfassung: Warum AG-UI 1.0 den Agenten-Protokollstack schließt

Ende 2026 hat MCP den Zugriff von Agenten auf Tools und A2A die Agent-zu-Agent-Delegation standardisiert – doch Frontends hingen weiterhin an fragilen, framework-spezifischen SSE-Hacks. AG-UI (Agent–User Interaction Protocol) – ein MIT-lizenziertes Open-Source-Protokoll mit 22.3k GitHub-Stars, 31 typisierten Events in 8 Familien und JSON Patch (RFC 6902) State-Sync – liefert die fehlende Laufzeitverbindung zwischen Agent und UI.

1. Die fehlende Schicht nach MCP und A2A

Moderne Agenten-Systeme sind keine einfachen Request-Response-Chatbots mehr. Ein einziger Prompt in einer IDE oder einem Analyse-Dashboard kann mehrminütiges Reasoning, Subagent-Delegation, Tool-Aufrufe und menschliche Freigaben auslösen. Während Anthropics Model Context Protocol (MCP) Agent ↔ Tools und Googles Agent-to-Agent (A2A) Agent ↔ Agent löste, verwaltet keines von beiden die zustandsbehaftete, bidirektionale UI-Schleife zum Nutzer.

+─────────────────────────────────────────────────────────────────────────────────────────────────+
|          Table 1: The 2026 Agentic Protocol Stack — MCP vs A2A vs AG-UI vs GenUI Specs          |
+──────────────────────────┬────────────────────────┬──────────────────────┬──────────────────────+
| Protocol / Spec          | Layer & Direction      | Primary Transport    | Core Responsibility  |
+──────────────────────────┼────────────────────────┼──────────────────────┼──────────────────────+
| MCP (Anthropic)          | Agent <-> Tools & Data | stdio / Streamable   | Tool discovery, auth,|
|                          |                        | HTTP (JSON-RPC 2.0)  | & resource context   |
+──────────────────────────┼────────────────────────┼──────────────────────┼──────────────────────+
| A2A (Google)             | Agent <-> Agent        | HTTP + SSE / JSON-   | Cross-agent task     |
|                          |                        | RPC (Agent Cards)    | delegation & handoff |
+──────────────────────────┼────────────────────────┼──────────────────────┼──────────────────────+
| AG-UI 1.0 (MIT, 22.3k*)  | Agent <-> User / App   | HTTP+SSE (default),  | 31-event streaming,  |
|                          |                        | Protobuf, WebSockets | RFC 6902 state, HITL |
+──────────────────────────┼────────────────────────┼──────────────────────┼──────────────────────+
| A2UI / MCP Apps /        | Declarative UI Schema  | Carried over AG-UI   | Dynamic UI widget    |
| Open-JSON-UI             | (Agent -> Renderer)    | or MCP payloads      | & card definitions   |
+──────────────────────────┴────────────────────────┴──────────────────────┴──────────────────────+

Ohne einheitlichen Frontend-Standard baut jedes Team eigene JSON-über-SSE-Formate für Token-Streaming, Tool-Fortschritt, Reasoning-Traces und veränderlichen UI-State. Sobald das Backend von LangGraph zu Google ADK, Mastra, CrewAI oder Pydantic AI wechselt, bricht der React- oder Mobile-Client.

AG-UI 1.0 schließt genau diese Lücke. Als MIT-Projekt unter ag-ui-protocol/ag-ui (22.3k Stars, 2.1k Forks, 168+ Mitwirkende) ergänzt AG-UI bestehende Standards: Ein Agent nutzt MCP für Datenquellen, A2A für Partner-Agenten und AG-UI für das Frontend.

2. AG-UI 1.0 Wire-Architektur: 31 Events in 8 Familien

AG-UI ist transportagnostisch: HTTP + Server-Sent Events (SSE) ist das verpflichtende Standard-Binding für HTTP-Server, ergänzt durch optionales binäres HTTP + Protobuf sowie WebSockets, Webhooks oder In-Process-Pipes. Jedes Event nutzt den kompakten BaseEvent-Umschlag mit Pflichtfeld type sowie optional timestamp, rawEvent, metadata und subagentRunId.

+─────────────────────────────────────────────────────────────────────────────────────────────────+
|           AG-UI 1.0 Bi-Directional Runtime Architecture (HTTP+SSE / Protobuf / RFC 6902)        |
+─────────────────────────────────────────────────────────────────────────────────────────────────+
|                                                                                                 |
|  [User App: React / CopilotKit / Terminal / Slack]     [Backend Agent: LangGraph / ADK / CrewAI]|
|         │                                                     ▲                                 |
|         ├─ 1. HTTP POST (RunAgentInput JSON) ─────────────────┤                                 |
|         │     { threadId, runId, state, messages, tools }     │                                 |
|         │                                                     ▼                                 |
|         │  2. SSE Stream (31 Event Types, 8 Families) ────────┤                                 |
|         │◀──── RUN_STARTED / STEP_STARTED / SUBAGENT_STARTED  │  (MCP Tools & A2A Subagents)    |
|         │◀──── REASONING_MESSAGE_CONTENT (delta)              │                                 |
|         │◀──── TEXT_MESSAGE_CONTENT (delta)                   │                                 |
|         │◀──── STATE_SNAPSHOT / STATE_DELTA (RFC 6902 Patch)  │                                 |
|         │◀──── TOOL_CALL_START -> ARGS -> END (Frontend HITL) │                                 |
|         │                                                     │                                 |
|         └─ 3. Next Turn: Send TOOL_CALL_RESULT + Updated State┘                                 |
+─────────────────────────────────────────────────────────────────────────────────────────────────+

Laut AG-UI 1.0 Spezifikation definiert das Protokoll 31 typisierte Events in 8 Familien:

  • Runs, Steps & Subagents: RUN_STARTED, RUN_FINISHED, RUN_ERROR, STEP_STARTED, STEP_FINISHED sowie SUBAGENT_STARTED, SUBAGENT_FINISHED und SUBAGENT_ERROR mit subagentRunId-Zuordnung.
  • Text- & Reasoning-Streams: TEXT_MESSAGE_START/CONTENT/END/CHUNK für Antworten sowie REASONING_START/END, REASONING_MESSAGE_* und REASONING_ENCRYPTED_VALUE (ersetzen veraltete THINKING_*-Events).
  • Tool Calls & Passthrough: TOOL_CALL_START, TOOL_CALL_ARGS, TOOL_CALL_END, TOOL_CALL_CHUNK und TOOL_CALL_RESULT für Backend- oder Frontend-Tools plus RAW und CUSTOM.
  • State- & Activity-Snapshots: STATE_SNAPSHOT, STATE_DELTA, MESSAGES_SNAPSHOT, ACTIVITY_SNAPSHOT und ACTIVITY_DELTA zur präzisen Synchronisation ohne Voll-Payloads.

Durch strikte Typisierung in TypeScript (@ag-ui/[email protected]), Python (ag-ui-protocol) und .NET (AGUI.Client) lassen sich UI-Komponenten deterministisch an den Agenten-Lebenszyklus binden.

3. Shared State (RFC 6902), Human-in-the-Loop & Python SSE-Server

Zwei Mechanismen heben AG-UI von simplen Chat-Wrappern ab: inkrementelle State-Synchronisation und unterbrechbare Tool-Loops. Statt bei jedem Schritt 50 KB JSON neu zu senden, überträgt AG-UI einen initialen STATE_SNAPSHOT gefolgt von schlanken STATE_DELTA-Arrays im Standardformat JSON Patch (RFC 6902) (add, remove, replace, move, copy, test).

# server.py — Official AG-UI Python FastAPI SSE Endpoint (pip install ag-ui-protocol fastapi uvicorn)
import uuid
from fastapi import FastAPI, Request
from fastapi.responses import StreamingResponse
from ag_ui.core import (
    PROTOCOL_VERSION,
    RunAgentInput,
    RunStartedEvent,
    RunFinishedEvent,
    TextMessageStartEvent,
    TextMessageContentEvent,
    TextMessageEndEvent,
)
from ag_ui.encoder import EventEncoder

app = FastAPI()

@app.post("/")
async def run_agent(input_data: RunAgentInput, request: Request):
    encoder = EventEncoder(accept=request.headers.get("accept"))

    async def events():
        yield encoder.encode(RunStartedEvent(
            thread_id=input_data.thread_id,
            run_id=input_data.run_id,
            protocol_version=PROTOCOL_VERSION,
        ))
        message_id = str(uuid.uuid4())
        yield encoder.encode(TextMessageStartEvent(message_id=message_id, role="assistant"))
        for chunk in ["Hello ", "from ", "AG-UI!"]:
            yield encoder.encode(TextMessageContentEvent(message_id=message_id, delta=chunk))
        yield encoder.encode(TextMessageEndEvent(message_id=message_id))
        yield encoder.encode(RunFinishedEvent(
            thread_id=input_data.thread_id,
            run_id=input_data.run_id,
        ))

    return StreamingResponse(events(), media_type=encoder.get_content_type())

Serverseitig genügt ein FastAPI-Endpunkt in unter 35 Zeilen Python mit ag_ui.core und EventEncoder. EventEncoder(accept=request.headers.get("accept")) verhandelt automatisch text/event-stream (SSE) oder Protobuf anhand des Accept-Headers.

Für Human-in-the-Loop (HITL) – etwa die Freigabe einer Datenbank-Migration – sendet das Backend TOOL_CALL_START, streamt Argumente per TOOL_CALL_ARGS und schließt mit TOOL_CALL_END. Das Frontend rendert eine Freigabekarte und sendet das TOOL_CALL_RESULT im nächsten RunAgentInput-Turn zurück.

4. TypeScript HttpAgent Client & Ökosystem Ende 2026

Clientseitig stellt @ag-ui/[email protected] den HttpAgent für Node.js 20+ und Browser bereit. URL und Auth-Header setzen, Nachricht hinzufügen und typisierte Callbacks wie onRunStartedEvent, onTextMessageContentEvent und onRunFinishedEvent übergeben.

// client.ts — Official AG-UI TypeScript Client (npm install @ag-ui/client tsx)
import { HttpAgent } from "@ag-ui/client";

const agent = new HttpAgent({
  url: "http://localhost:8000/",
  headers: {
    Authorization: `Bearer ${process.env.AGENT_API_KEY ?? ""}`,
  },
});

agent.addMessage({
  id: crypto.randomUUID(),
  role: "user",
  content: "Hi there! Summarize our deployment state.",
});

await agent.runAgent({}, {
  onRunStartedEvent: ({ event }) =>
    console.log(`run started (AG-UI ${event.protocolVersion})`),
  onTextMessageContentEvent: ({ event }) => {
    process.stdout.write(event.delta);
  },
  onRunFinishedEvent: () => console.log("\nrun finished"),
});

Nach den Releases 2026-11-17 (Core 1.0.5 + @ag-ui/[email protected]), 2026-11-21 (ag_ui_adk==0.14.0, ag-ui-openai-agents==0.2.0) und 2026-11-27 (@ag-ui/[email protected], ag-ui-langgraph==0.1.0) deckt AG-UI nahezu jedes führende Framework ab:

+─────────────────────────────────────────────────────────────────────────────────────────────────+
|            Table 2: Frontend-to-Agent Transport Comparison (AG-UI 1.0 vs Alternatives)          |
+──────────────────────────┬──────────────────────┬───────────────────────┬───────────────────────+
| Capability               | Custom Ad-Hoc SSE    | Raw WebSockets        | AG-UI 1.0 Protocol    |
+──────────────────────────┼──────────────────────┼───────────────────────┼───────────────────────+
| Event Taxonomy           | Proprietary JSON per | Unstandardized frames | 31 typed events across|
|                          | backend framework    | & custom reconnects   | 8 standard families   |
+──────────────────────────┼──────────────────────┼───────────────────────┼───────────────────────+
| Shared Mutable State     | Re-send full JSON or | Manual diffing &      | Native STATE_SNAPSHOT |
|                          | custom Redux actions | conflict handling     | + STATE_DELTA RFC 6902|
+──────────────────────────┼──────────────────────┼───────────────────────┼───────────────────────+
| Frontend Tool & HITL     | Fragile polling or   | Custom RPC correlation| Built-in TOOL_CALL_*  |
| Approval Loops           | ad-hoc callbacks     | IDs & state machines  | & TOOL_CALL_RESULT    |
+──────────────────────────┼──────────────────────┼───────────────────────┼───────────────────────+
| Framework Portability    | Rewritten per agent  | Tightly coupled to    | Official adapters for |
|                          | framework upgrade    | socket server code    | LangGraph/ADK/Mastra+ |
+──────────────────────────┴──────────────────────┴───────────────────────┴───────────────────────+

Offiziell integriert sind LangGraph, CrewAI, Google ADK, Microsoft Agent Framework, AWS Strands Agents, Mastra, Pydantic AI, LlamaIndex, Agno, AG2, Claude Agent SDK, OpenAI Agents SDK, Spring AI und Cloudflare Agents – ergänzt durch Community-SDKs für Kotlin, Go, Java, Rust, Swift und Dart.

5. AG-UI vs. Generative UI Specs (A2UI, MCP Apps, Open-JSON-UI)

Häufig wird AG-UI fälschlich als Konkurrenz zu deklarativen UI-Schemas wie Googles A2UI, OpenAIs Open-JSON-UI oder Microsoft & Shopifys MCP Apps gesehen. Tatsächlich arbeiten sie auf unterschiedlichen Ebenen:

  • Deklarative UI-Specs (Was gerendert wird): A2UI, MCP Apps und Open-JSON-UI beschreiben Layout, Felder und Aktionen dynamischer Widgets und Formulare.
  • AG-UI Laufzeitprotokoll (Wie gestreamt & synchronisiert wird): AG-UI bildet den bidirektionalen Event-Kanal, der diese UI-Payloads zusammen mit Text-Tokens, Reasoning und RFC-6902-Deltas überträgt.
  • Offizielle Middleware-Brücken: Pakete wie @ag-ui/[email protected] binden A2UI- oder MCP-Apps-Komponenten direkt in CopilotKit, React, Angular, Vue oder CLI-Clients ein.

AG-UI ist das Transport-Nervensystem, während A2UI oder MCP Apps die visuellen Nutzlast-Karten darüber liefern.

6. Produktions-Checkliste & Stack-Integration

Für eine saubere Einführung von AG-UI 1.0 in Produktivsystemen empfiehlt sich dieses 4-Schritte-Vorgehen:

# 1. Scaffold a full-stack AG-UI + CopilotKit application
npx create-ag-ui-app@latest

# 2. Or install core packages directly in TypeScript / Python / .NET
npm install @ag-ui/[email protected] @ag-ui/[email protected] @ag-ui/[email protected]
pip install ag-ui-protocol ag-ui-langgraph==0.1.0
dotnet add package AGUI.Client
  • Schritt 1 — Projekt initialisieren oder Core-Pakete ergänzen: Starten Sie neu mit npx create-ag-ui-app@latest oder installieren Sie @ag-ui/[email protected] und ag-ui-protocol.
  • Schritt 2 — Offizielle Framework-Middleware nutzen: Verwenden Sie native Adapter (ag-ui-langgraph==0.1.0, ag_ui_adk==0.14.0, @ag-ui/[email protected]) statt eigener Event-Encoder.
  • Schritt 3 — Subagents via subagentRunId trennen: Markieren Sie delegierte A2A- oder Worker-Läufe mit subagentRunId für saubere UI-Timelines.
  • Schritt 4 — Mit MCP, A2A & idempotenten Deltas absichern: Validieren Sie RunAgentInput und halten Sie STATE_DELTA-Patches für Reconnects idempotent.

Entdecken Sie den gesamten Protokoll-Stack im AgDex.ai Verzeichnis und im 3-Step Stack Finder – darunter unser MCP vs A2A Leitfaden, Analysen zu MCP, LangGraph und CrewAI sowie Quick-View-Profile für AG-UI Protocol, CopilotKit und PydanticAI.

7. Häufig gestellte Fragen (FAQ)

F1: Ersetzt AG-UI MCP oder A2A?

Nein. MCP verbindet Agenten mit Tools und Daten, A2A verbindet Agenten untereinander und AG-UI verbindet Agenten mit Benutzeroberflächen. Produktive Systeme kombinieren meist alle drei.

F2: Warum nutzt AG-UI standardmäßig HTTP + SSE statt WebSockets zu erzwingen?

HTTP POST + SSE funktioniert problemlos über Unternehmens-Proxys, CDNs, Edge-Worker und Standard-Load-Balancer, lässt aber bei Bedarf binäres Protobuf oder WebSockets zu.

F3: Wie vermeidet AG-UI riesige JSON-Payloads bei State-Änderungen?

Ein initialer STATE_SNAPSHOT wird über kompakte STATE_DELTA-Events im Format JSON Patch (RFC 6902) aktualisiert – übertragen werden nur geänderte Pfade.

F4: Welche Client-Frameworks und Sprachen werden unterstützt?

Offizielle SDKs existieren für TypeScript (@ag-ui/client), Python (ag-ui-protocol) und .NET (AGUI.Client), mit CopilotKit-Integrationen für React, Angular, Vue und React Native sowie Community-SDKs für Kotlin, Go, Java, Rust, Swift und Dart.

AG-UIプロトコル詳解:MCPとA2Aの次に必要なフロントエンド標準層 (2026)

AgDex エンジニアリング編集部 • • 14分で読了 • Agentic Protocols • 2026年12月
AG-UIプロトコル詳解:MCPとA2Aの次に必要なフロントエンド標準層 (2026)
要旨:なぜAG-UI 1.0がエージェント・プロトコルスタックを完成させるのか

2026年後半、MCPが「エージェント↔ツール」、A2Aが「エージェント↔エージェント」の接続を標準化した一方で、フロントエンドは依然としてフレームワーク固有の脆弱なSSE実装に依存していました。AG-UI(Agent–User Interaction Protocol)は、GitHubスター22.3k・MITライセンスのオープン標準であり、8ファミリー・31種類の型付きイベントとJSON Patch(RFC 6902)による状態同期によって、バックエンドとUIを結ぶ標準ランタイム層を提供します。

1. MCPとA2Aの次に欠けていたフロントエンド標準層

現代のエージェントシステムは単純な一問一答チャットではありません。コーディング支援や分析ダッシュボードでは、1回のプロンプトから数分間の推論、サブエージェント委任、ツール実行、人間の承認(HITL)が連鎖します。AnthropicのMCP(Model Context Protocol)はエージェント ↔ ツールを、GoogleのA2A(Agent-to-Agent)はエージェント ↔ エージェントを解決しましたが、どちらもユーザーUIとの双方向・ステートフルな同期ループを扱う設計ではありません。

+─────────────────────────────────────────────────────────────────────────────────────────────────+
|          Table 1: The 2026 Agentic Protocol Stack — MCP vs A2A vs AG-UI vs GenUI Specs          |
+──────────────────────────┬────────────────────────┬──────────────────────┬──────────────────────+
| Protocol / Spec          | Layer & Direction      | Primary Transport    | Core Responsibility  |
+──────────────────────────┼────────────────────────┼──────────────────────┼──────────────────────+
| MCP (Anthropic)          | Agent <-> Tools & Data | stdio / Streamable   | Tool discovery, auth,|
|                          |                        | HTTP (JSON-RPC 2.0)  | & resource context   |
+──────────────────────────┼────────────────────────┼──────────────────────┼──────────────────────+
| A2A (Google)             | Agent <-> Agent        | HTTP + SSE / JSON-   | Cross-agent task     |
|                          |                        | RPC (Agent Cards)    | delegation & handoff |
+──────────────────────────┼────────────────────────┼──────────────────────┼──────────────────────+
| AG-UI 1.0 (MIT, 22.3k*)  | Agent <-> User / App   | HTTP+SSE (default),  | 31-event streaming,  |
|                          |                        | Protobuf, WebSockets | RFC 6902 state, HITL |
+──────────────────────────┼────────────────────────┼──────────────────────┼──────────────────────+
| A2UI / MCP Apps /        | Declarative UI Schema  | Carried over AG-UI   | Dynamic UI widget    |
| Open-JSON-UI             | (Agent -> Renderer)    | or MCP payloads      | & card definitions   |
+──────────────────────────┴────────────────────────┴──────────────────────┴──────────────────────+

共通のフロントエンド規格がなければ、開発チームごとにトークンストリーミングやツール進捗、推論トレース、共有ステート用の独自JSON-over-SSEスキーマを作ることになります。その結果、バックエンドをLangGraphからGoogle ADK、Mastra、CrewAI、Pydantic AIへ移行するたびにReactやモバイルクライアントが壊れてしまいます。

AG-UI 1.0はこの境界を標準化します。MITライセンスでag-ui-protocol/ag-ui(22.3kスター、2.1kフォーク、168+コントリビューター)で開発されており、1つのエージェントがデータ層にMCP、協調層にA2A、UI層にAG-UIを同時に使う構成が可能です。

2. AG-UI 1.0 ワイヤアーキテクチャ:8ファミリー・31イベント

AG-UIはトランスポート非依存です。HTTPサーバーではHTTP + Server-Sent Events(SSE)が必須のデフォルトバインディングとなっており、バイナリのHTTP + ProtobufやWebSocket、Webhook、インプロセス・パイプも選択可能です。エージェントが送出するすべてのイベントは、必須のtypeと任意のtimestamp・rawEvent・metadata・subagentRunIdを持つ軽量なBaseEventエンベロープに準拠します。

+─────────────────────────────────────────────────────────────────────────────────────────────────+
|           AG-UI 1.0 Bi-Directional Runtime Architecture (HTTP+SSE / Protobuf / RFC 6902)        |
+─────────────────────────────────────────────────────────────────────────────────────────────────+
|                                                                                                 |
|  [User App: React / CopilotKit / Terminal / Slack]     [Backend Agent: LangGraph / ADK / CrewAI]|
|         │                                                     ▲                                 |
|         ├─ 1. HTTP POST (RunAgentInput JSON) ─────────────────┤                                 |
|         │     { threadId, runId, state, messages, tools }     │                                 |
|         │                                                     ▼                                 |
|         │  2. SSE Stream (31 Event Types, 8 Families) ────────┤                                 |
|         │◀──── RUN_STARTED / STEP_STARTED / SUBAGENT_STARTED  │  (MCP Tools & A2A Subagents)    |
|         │◀──── REASONING_MESSAGE_CONTENT (delta)              │                                 |
|         │◀──── TEXT_MESSAGE_CONTENT (delta)                   │                                 |
|         │◀──── STATE_SNAPSHOT / STATE_DELTA (RFC 6902 Patch)  │                                 |
|         │◀──── TOOL_CALL_START -> ARGS -> END (Frontend HITL) │                                 |
|         │                                                     │                                 |
|         └─ 3. Next Turn: Send TOOL_CALL_RESULT + Updated State┘                                 |
+─────────────────────────────────────────────────────────────────────────────────────────────────+

AG-UI 1.0 仕様では、31種類の型付きイベントが以下の8ファミリーに整理されています:

  • Runs・Steps・Subagents: RUN_STARTED、RUN_FINISHED、RUN_ERROR、STEP_STARTED、STEP_FINISHEDに加え、subagentRunIdで紐付けるSUBAGENT_STARTED/FINISHED/ERROR。
  • テキスト&推論ストリーム: 応答用のTEXT_MESSAGE_START/CONTENT/END/CHUNKと、旧THINKING_*を置き換えたREASONING_START/END・REASONING_MESSAGE_*・REASONING_ENCRYPTED_VALUE。
  • ツール呼び出し&パススルー: バックエンド/フロントエンドツール用のTOOL_CALL_START・TOOL_CALL_ARGS・TOOL_CALL_END・TOOL_CALL_CHUNK・TOOL_CALL_RESULT、およびRAW/CUSTOM。
  • ステート&アクティビティ: STATE_SNAPSHOT、STATE_DELTA、MESSAGES_SNAPSHOT、ACTIVITY_SNAPSHOT、ACTIVITY_DELTAにより全量再送なしで状態を同期。

TypeScript(@ag-ui/[email protected])、Python(ag-ui-protocol)、.NET(AGUI.Client)間で厳密に型定義されているため、フロントエンドはライフサイクルや状態変化を決定論的に購読できます。

3. 共有ステート(RFC 6902)・HITL・Python SSEサーバー実装

AG-UIを単なるLLMラッパーと分ける2大機能が差分ステート同期と中断可能なツールループです。毎ステップ50 KBのJSONを再送する代わりに、初回のSTATE_SNAPSHOTに続けてJSON Patch(RFC 6902)形式(add、remove、replace、move、copy、test)の軽量なSTATE_DELTA配列を配信します。

# server.py — Official AG-UI Python FastAPI SSE Endpoint (pip install ag-ui-protocol fastapi uvicorn)
import uuid
from fastapi import FastAPI, Request
from fastapi.responses import StreamingResponse
from ag_ui.core import (
    PROTOCOL_VERSION,
    RunAgentInput,
    RunStartedEvent,
    RunFinishedEvent,
    TextMessageStartEvent,
    TextMessageContentEvent,
    TextMessageEndEvent,
)
from ag_ui.encoder import EventEncoder

app = FastAPI()

@app.post("/")
async def run_agent(input_data: RunAgentInput, request: Request):
    encoder = EventEncoder(accept=request.headers.get("accept"))

    async def events():
        yield encoder.encode(RunStartedEvent(
            thread_id=input_data.thread_id,
            run_id=input_data.run_id,
            protocol_version=PROTOCOL_VERSION,
        ))
        message_id = str(uuid.uuid4())
        yield encoder.encode(TextMessageStartEvent(message_id=message_id, role="assistant"))
        for chunk in ["Hello ", "from ", "AG-UI!"]:
            yield encoder.encode(TextMessageContentEvent(message_id=message_id, delta=chunk))
        yield encoder.encode(TextMessageEndEvent(message_id=message_id))
        yield encoder.encode(RunFinishedEvent(
            thread_id=input_data.thread_id,
            run_id=input_data.run_id,
        ))

    return StreamingResponse(events(), media_type=encoder.get_content_type())

サーバー側では、ag_ui.coreとEventEncoderを使えば35行未満のPythonコードでAG-UI準拠のFastAPIエンドポイントを構築できます。EventEncoder(accept=request.headers.get("accept"))がクライアントのAcceptヘッダーに応じてtext/event-stream(SSE)またはProtobufを自動選択します。

Human-in-the-Loop(HITL)承認フローでは、バックエンドがTOOL_CALL_START→TOOL_CALL_ARGS→TOOL_CALL_ENDを送信すると、フロントエンドが承認UIを表示し、ユーザー操作後の結果を次ターンのRunAgentInputでTOOL_CALL_RESULTとして返却します。

4. TypeScript HttpAgentクライアントと2026年11月最新エコシステム

クライアント側では、@ag-ui/[email protected]がNode.js 20+およびブラウザ向けのHttpAgentを提供します。認証ヘッダーを設定し、ユーザーメッセージを追加してonRunStartedEventやonTextMessageContentEventなどの型付きコールバックを渡すだけで接続できます。

// client.ts — Official AG-UI TypeScript Client (npm install @ag-ui/client tsx)
import { HttpAgent } from "@ag-ui/client";

const agent = new HttpAgent({
  url: "http://localhost:8000/",
  headers: {
    Authorization: `Bearer ${process.env.AGENT_API_KEY ?? ""}`,
  },
});

agent.addMessage({
  id: crypto.randomUUID(),
  role: "user",
  content: "Hi there! Summarize our deployment state.",
});

await agent.runAgent({}, {
  onRunStartedEvent: ({ event }) =>
    console.log(`run started (AG-UI ${event.protocolVersion})`),
  onTextMessageContentEvent: ({ event }) => {
    process.stdout.write(event.delta);
  },
  onRunFinishedEvent: () => console.log("\nrun finished"),
});

Release 2026-11-17(コア1.0.5 + @ag-ui/[email protected])、Release 2026-11-21(ag_ui_adk==0.14.0、ag-ui-openai-agents==0.2.0)、Release 2026-11-27(@ag-ui/[email protected]、ag-ui-langgraph==0.1.0)を経て、主要ランタイムをほぼ網羅しました:

+─────────────────────────────────────────────────────────────────────────────────────────────────+
|            Table 2: Frontend-to-Agent Transport Comparison (AG-UI 1.0 vs Alternatives)          |
+──────────────────────────┬──────────────────────┬───────────────────────┬───────────────────────+
| Capability               | Custom Ad-Hoc SSE    | Raw WebSockets        | AG-UI 1.0 Protocol    |
+──────────────────────────┼──────────────────────┼───────────────────────┼───────────────────────+
| Event Taxonomy           | Proprietary JSON per | Unstandardized frames | 31 typed events across|
|                          | backend framework    | & custom reconnects   | 8 standard families   |
+──────────────────────────┼──────────────────────┼───────────────────────┼───────────────────────+
| Shared Mutable State     | Re-send full JSON or | Manual diffing &      | Native STATE_SNAPSHOT |
|                          | custom Redux actions | conflict handling     | + STATE_DELTA RFC 6902|
+──────────────────────────┼──────────────────────┼───────────────────────┼───────────────────────+
| Frontend Tool & HITL     | Fragile polling or   | Custom RPC correlation| Built-in TOOL_CALL_*  |
| Approval Loops           | ad-hoc callbacks     | IDs & state machines  | & TOOL_CALL_RESULT    |
+──────────────────────────┼──────────────────────┼───────────────────────┼───────────────────────+
| Framework Portability    | Rewritten per agent  | Tightly coupled to    | Official adapters for |
|                          | framework upgrade    | socket server code    | LangGraph/ADK/Mastra+ |
+──────────────────────────┴──────────────────────┴───────────────────────┴───────────────────────+

LangGraph、CrewAI、Google ADK、Microsoft Agent Framework、AWS Strands Agents、Mastra、Pydantic AI、LlamaIndex、Agno、AG2、Claude Agent SDK、OpenAI Agents SDK、Spring AI、Cloudflare Agentsの公式統合に加え、Kotlin・Go・Java・Rust・Swift・Dart向けコミュニティSDKも揃っています。

5. AG-UI vs 生成UI仕様(A2UI・MCP Apps・Open-JSON-UI)

よくある誤解として、AG-UIをGoogleのA2UI、OpenAIのOpen-JSON-UI、Microsoft & ShopifyのMCP Appsといった宣言的UI仕様の競合と捉えるケースがありますが、実際にはレイヤーが異なります:

  • 宣言的UI仕様(何を描画するか): A2UI、MCP Apps、Open-JSON-UIは動的ウィジェットやフォームのレイアウト・項目・アクションを定義します。
  • AG-UIランタイムプロトコル(どう流し同期するか): AG-UIはテキストトークンや推論トレース、RFC 6902ステート差分とともにそれらのUIペイロードを運ぶ双方向トランスポート層です。
  • 公式ミドルウェア連携: @ag-ui/[email protected]などの公式ブリッジにより、CopilotKit・React・Angular・Vue・ターミナル上でA2UIやMCP Appsをそのまま描画できます。

AG-UIはSSE/Protobufの「神経網」であり、A2UIやMCP Appsはその上を流れる「UIカード・ペイロード」という関係です。

6. 本番デプロイ・チェックリストとスタック連携

既存のエージェントロジックを書き直さずにAG-UI 1.0を本番導入するための4ステップです:

# 1. Scaffold a full-stack AG-UI + CopilotKit application
npx create-ag-ui-app@latest

# 2. Or install core packages directly in TypeScript / Python / .NET
npm install @ag-ui/[email protected] @ag-ui/[email protected] @ag-ui/[email protected]
pip install ag-ui-protocol ag-ui-langgraph==0.1.0
dotnet add package AGUI.Client
  • ステップ1 — スキャフォールドまたはコア導入: 新規プロジェクトはnpx create-ag-ui-app@latest、既存環境には@ag-ui/[email protected]とag-ui-protocolを追加します。
  • ステップ2 — 公式フレームワークミドルウェアを使用: 独自エンコーダを書かず、ag-ui-langgraph==0.1.0やag_ui_adk==0.14.0、@ag-ui/[email protected]等の公式アダプターを採用します。
  • ステップ3 — subagentRunIdでサブエージェントを分離: A2A委任や並列グラフ実行時はsubagentRunIdを付与し、UI上で折りたたみ可能なタイムラインを描画します。
  • ステップ4 — MCP・A2A・冪等な差分ガードと併用: 受信RunAgentInputを検証し、再接続時に状態が壊れないようSTATE_DELTAパッチを冪等に保ちます。

プロトコル全体の比較やツール仕様はAgDex.ai ディレクトリおよび3-Step Stack Finderで確認できます。MCP vs A2A プロトコル比較ガイド、MCP・LangGraph・CrewAIの詳細ページ、さらにAG-UI Protocol・CopilotKit・PydanticAIのクイック仕様もご活用ください。

7. よくある質問(FAQ)

Q1: AG-UIはMCPやA2Aを置き換えるものですか?

いいえ。MCPはエージェントとツール・データ、A2Aはエージェント同士、AG-UIはエージェントとユーザーUIを接続します。本番システムでは3つを併用するのが標準的です。

Q2: なぜAG-UIはWebSocket必須ではなくHTTP + SSEをデフォルトにしているのですか?

HTTP POST + SSEは企業プロキシやCDN、エッジワーカー、標準ロードバランサーを通過しやすく、超低遅延のバイナリ転送が必要な場合のみProtobufやWebSocketを選択できるためです。

Q3: 状態が変わるたびに巨大なJSONが送られるのをどう防ぎますか?

初回のSTATE_SNAPSHOTの後、JSON Patch(RFC 6902)形式のSTATE_DELTAイベントで変更されたキーや配列インデックスのみを差分送信します。

Q4: どのクライアントフレームワークと言語がサポートされていますか?

公式SDKはTypeScript(@ag-ui/client)、Python(ag-ui-protocol)、.NET(AGUI.Client)に対応し、CopilotKit経由でReact・Angular・Vue・React Nativeをサポート。さらにKotlin・Go・Java・Rust・Swift・DartのコミュニティSDKがあります。

شرح بروتوكول AG-UI: طبقة الواجهة المفقودة بعد MCP وA2A (2026)

فريق الهندسة التحريري في AgDex • • 14 دقيقة قراءة • بروتوكولات الوكلاء • ديسمبر 2026
شرح بروتوكول AG-UI: طبقة الواجهة المفقودة بعد MCP وA2A (2026)
الخلاصة: لماذا يُكمل AG-UI 1.0 منظومة بروتوكولات الوكلاء

بحلول أواخر عام 2026، وحّد بروتوكول MCP اتصال الوكيل بالأدوات ووحّد A2A تنسيق المهام بين الوكلاء—لكن الواجهات الأمامية ظلت تعتمد على ترقيعات SSE خاصة بكل إطار عمل. يقدّم AG-UI (Agent–User Interaction Protocol)—المعيار المفتوح بترخيص MIT مع 22.3k نجمة على GitHub و31 نوع حدث ضمن 8 عائلات ومزامنة حالة عبر JSON Patch (RFC 6902)—حلقة الوصل القياسية بين الوكلاء والتطبيقات.

1. الطبقة المفقودة بعد MCP وA2A

لم تعد أنظمة الوكلاء الحديثة مجرد نوافذ دردشة بسيطة. فطلب واحد من المستخدم داخل بيئة برمجة أو لوحة تحليلات قد يطلق دقائق من الاستدلال، وتفويض وكلاء فرعيين، وتشغيل أدوات، وطلب موافقة بشرية في منتصف التنفيذ. وبينما عالج MCP من Anthropic ربط الوكيل بالأدوات وعالج A2A من Google التنسيق بين الوكلاء، لم يُصمم أي منهما لإدارة حلقة التفاعل ثنائية الاتجاه والمحافظة على الحالة مع المستخدم.

+─────────────────────────────────────────────────────────────────────────────────────────────────+
|          Table 1: The 2026 Agentic Protocol Stack — MCP vs A2A vs AG-UI vs GenUI Specs          |
+──────────────────────────┬────────────────────────┬──────────────────────┬──────────────────────+
| Protocol / Spec          | Layer & Direction      | Primary Transport    | Core Responsibility  |
+──────────────────────────┼────────────────────────┼──────────────────────┼──────────────────────+
| MCP (Anthropic)          | Agent <-> Tools & Data | stdio / Streamable   | Tool discovery, auth,|
|                          |                        | HTTP (JSON-RPC 2.0)  | & resource context   |
+──────────────────────────┼────────────────────────┼──────────────────────┼──────────────────────+
| A2A (Google)             | Agent <-> Agent        | HTTP + SSE / JSON-   | Cross-agent task     |
|                          |                        | RPC (Agent Cards)    | delegation & handoff |
+──────────────────────────┼────────────────────────┼──────────────────────┼──────────────────────+
| AG-UI 1.0 (MIT, 22.3k*)  | Agent <-> User / App   | HTTP+SSE (default),  | 31-event streaming,  |
|                          |                        | Protobuf, WebSockets | RFC 6902 state, HITL |
+──────────────────────────┼────────────────────────┼──────────────────────┼──────────────────────+
| A2UI / MCP Apps /        | Declarative UI Schema  | Carried over AG-UI   | Dynamic UI widget    |
| Open-JSON-UI             | (Agent -> Renderer)    | or MCP payloads      | & card definitions   |
+──────────────────────────┴────────────────────────┴──────────────────────┴──────────────────────+

بدون معيار موحد للواجهة الأمامية، يضطر كل فريق إلى ابتكار صيغ JSON مخصصة فوق SSE لبث الرموز وتتبع الأدوات ومزامنة الحالة. وفي كل مرة يتغير فيها إطار الخلفية—مثلاً من LangGraph إلى Google ADK أو Mastra أو CrewAI أو Pydantic AI—تتعطل واجهة React أو تطبيق الجوال.

يعالج AG-UI 1.0 هذه الحدود بدقة. وبصفته بروتوكولاً مفتوح المصدر بترخيص MIT عبر ag-ui-protocol/ag-ui (22.3k نجمة و2.1k تفرع و168+ مساهماً)، يعمل AG-UI جنباً إلى جنب مع MCP وA2A ليتحدث الوكيل الواحد مع قواعد البيانات عبر MCP ومع الوكلاء عبر A2A ومع الواجهة عبر AG-UI.

2. معمارية AG-UI 1.0: 31 حدثاً ضمن 8 عائلات

بروتوكول AG-UI مستقل عن طبقة النقل: يُعد HTTP + Server-Sent Events (SSE) الربط الافتراضي الإلزامي لخوادم HTTP، مع دعم ربط ثنائي اختياري عبر HTTP + Protobuf وكذلك WebSockets والـ webhooks. يتبع كل حدث مغلفاً خفيفاً باسم BaseEvent يحتوي على الحقل الإلزامي type وحقول اختيارية مثل timestamp وrawEvent وmetadata وsubagentRunId.

+─────────────────────────────────────────────────────────────────────────────────────────────────+
|           AG-UI 1.0 Bi-Directional Runtime Architecture (HTTP+SSE / Protobuf / RFC 6902)        |
+─────────────────────────────────────────────────────────────────────────────────────────────────+
|                                                                                                 |
|  [User App: React / CopilotKit / Terminal / Slack]     [Backend Agent: LangGraph / ADK / CrewAI]|
|         │                                                     ▲                                 |
|         ├─ 1. HTTP POST (RunAgentInput JSON) ─────────────────┤                                 |
|         │     { threadId, runId, state, messages, tools }     │                                 |
|         │                                                     ▼                                 |
|         │  2. SSE Stream (31 Event Types, 8 Families) ────────┤                                 |
|         │◀──── RUN_STARTED / STEP_STARTED / SUBAGENT_STARTED  │  (MCP Tools & A2A Subagents)    |
|         │◀──── REASONING_MESSAGE_CONTENT (delta)              │                                 |
|         │◀──── TEXT_MESSAGE_CONTENT (delta)                   │                                 |
|         │◀──── STATE_SNAPSHOT / STATE_DELTA (RFC 6902 Patch)  │                                 |
|         │◀──── TOOL_CALL_START -> ARGS -> END (Frontend HITL) │                                 |
|         │                                                     │                                 |
|         └─ 3. Next Turn: Send TOOL_CALL_RESULT + Updated State┘                                 |
+─────────────────────────────────────────────────────────────────────────────────────────────────+

وفق مواصفة AG-UI 1.0، يحدد البروتوكول 31 حدثاً مصنفاً في 8 عائلات:

  • التشغيل والخطوات والوكلاء الفرعيون: أحداث RUN_STARTED وRUN_FINISHED وRUN_ERROR وSTEP_STARTED وSTEP_FINISHED، إضافة إلى SUBAGENT_STARTED وSUBAGENT_FINISHED وSUBAGENT_ERROR عبر subagentRunId.
  • بث النصوص والاستدلال: أحداث TEXT_MESSAGE_START/CONTENT/END/CHUNK للنص، مع REASONING_START/END وREASONING_MESSAGE_* وREASONING_ENCRYPTED_VALUE بدلاً من أحداث THINKING_* القديمة.
  • استدعاء الأدوات والتمرير المباشر: أحداث TOOL_CALL_START وTOOL_CALL_ARGS وTOOL_CALL_END وTOOL_CALL_CHUNK وTOOL_CALL_RESULT لأدوات الخلفية أو الواجهة، إلى جانب RAW وCUSTOM.
  • لقطات الحالة والنشاط: أحداث STATE_SNAPSHOT وSTATE_DELTA وMESSAGES_SNAPSHOT وACTIVITY_SNAPSHOT وACTIVITY_DELTA لمزامنة حالة التطبيق دون إعادة إرسال الحمولات كاملة.

ونظراً لأن العقد البرمجي معرف بدقة عبر TypeScript (@ag-ui/[email protected]) وPython (ag-ui-protocol) و.NET (AGUI.Client)، يمكن لمكونات الواجهة الاشتراك في دورة حياة الوكيل بشكل حتمي.

3. الحالة المشتركة (RFC 6902) والتدخل البشري وخادم Python SSE

يميز AG-UI عن أغلفة الدردشة البسيطة ميزتان أساسيتان: المزامنة التزايدية للحالة وحلقات الأدوات القابلة للمقاطعة. بدلاً من إجبار الوكيل على إعادة إرسال مستند JSON بحجم 50 كيلوبايت في كل خطوة، يرسل AG-UI لقطة أولية STATE_SNAPSHOT تتبعها تحديثات STATE_DELTA بصيغة JSON Patch (RFC 6902) القياسية (add، remove، replace، move، copy، test).

# server.py — Official AG-UI Python FastAPI SSE Endpoint (pip install ag-ui-protocol fastapi uvicorn)
import uuid
from fastapi import FastAPI, Request
from fastapi.responses import StreamingResponse
from ag_ui.core import (
    PROTOCOL_VERSION,
    RunAgentInput,
    RunStartedEvent,
    RunFinishedEvent,
    TextMessageStartEvent,
    TextMessageContentEvent,
    TextMessageEndEvent,
)
from ag_ui.encoder import EventEncoder

app = FastAPI()

@app.post("/")
async def run_agent(input_data: RunAgentInput, request: Request):
    encoder = EventEncoder(accept=request.headers.get("accept"))

    async def events():
        yield encoder.encode(RunStartedEvent(
            thread_id=input_data.thread_id,
            run_id=input_data.run_id,
            protocol_version=PROTOCOL_VERSION,
        ))
        message_id = str(uuid.uuid4())
        yield encoder.encode(TextMessageStartEvent(message_id=message_id, role="assistant"))
        for chunk in ["Hello ", "from ", "AG-UI!"]:
            yield encoder.encode(TextMessageContentEvent(message_id=message_id, delta=chunk))
        yield encoder.encode(TextMessageEndEvent(message_id=message_id))
        yield encoder.encode(RunFinishedEvent(
            thread_id=input_data.thread_id,
            run_id=input_data.run_id,
        ))

    return StreamingResponse(events(), media_type=encoder.get_content_type())

على جانب الخادم، يتطلب بناء نقطة نهاية FastAPI متوافقة مع AG-UI أقل من 35 سطراً من Python باستخدام ag_ui.core وEventEncoder. حيث يتفاوض EventEncoder(accept=request.headers.get("accept")) تلقائياً بين text/event-stream (SSE) وProtobuf بناءً على ترويسة Accept.

وفي مسارات التدخل البشري (HITL)—مثل اعتماد ترحيل قاعدة بيانات—يبث الخادم TOOL_CALL_START ثم المعاملات عبر TOOL_CALL_ARGS ثم TOOL_CALL_END، فتُظهر الواجهة بطاقة تأكيد وتعيد النتيجة عبر TOOL_CALL_RESULT في جولة RunAgentInput التالية.

4. عميل TypeScript HttpAgent ومنظومة أواخر 2026

على جانب العميل، يوفر @ag-ui/[email protected] الفئة HttpAgent لبيئات Node.js 20+ والمتصفحات. يكفي تمرير عنوان الخادم وترويسات التفويض وإضافة رسائل المستخدم مع دوال استدعاء مثل onRunStartedEvent وonTextMessageContentEvent وonRunFinishedEvent.

// client.ts — Official AG-UI TypeScript Client (npm install @ag-ui/client tsx)
import { HttpAgent } from "@ag-ui/client";

const agent = new HttpAgent({
  url: "http://localhost:8000/",
  headers: {
    Authorization: `Bearer ${process.env.AGENT_API_KEY ?? ""}`,
  },
});

agent.addMessage({
  id: crypto.randomUUID(),
  role: "user",
  content: "Hi there! Summarize our deployment state.",
});

await agent.runAgent({}, {
  onRunStartedEvent: ({ event }) =>
    console.log(`run started (AG-UI ${event.protocolVersion})`),
  onTextMessageContentEvent: ({ event }) => {
    process.stdout.write(event.delta);
  },
  onRunFinishedEvent: () => console.log("\nrun finished"),
});

عقب إصدارات Release 2026-11-17 (النواة 1.0.5 + @ag-ui/[email protected]) وRelease 2026-11-21 (ag_ui_adk==0.14.0، ag-ui-openai-agents==0.2.0) وRelease 2026-11-27 (@ag-ui/[email protected]، ag-ui-langgraph==0.1.0)، بات البروتوكول يغطي معظم المنصات:

+─────────────────────────────────────────────────────────────────────────────────────────────────+
|            Table 2: Frontend-to-Agent Transport Comparison (AG-UI 1.0 vs Alternatives)          |
+──────────────────────────┬──────────────────────┬───────────────────────┬───────────────────────+
| Capability               | Custom Ad-Hoc SSE    | Raw WebSockets        | AG-UI 1.0 Protocol    |
+──────────────────────────┼──────────────────────┼───────────────────────┼───────────────────────+
| Event Taxonomy           | Proprietary JSON per | Unstandardized frames | 31 typed events across|
|                          | backend framework    | & custom reconnects   | 8 standard families   |
+──────────────────────────┼──────────────────────┼───────────────────────┼───────────────────────+
| Shared Mutable State     | Re-send full JSON or | Manual diffing &      | Native STATE_SNAPSHOT |
|                          | custom Redux actions | conflict handling     | + STATE_DELTA RFC 6902|
+──────────────────────────┼──────────────────────┼───────────────────────┼───────────────────────+
| Frontend Tool & HITL     | Fragile polling or   | Custom RPC correlation| Built-in TOOL_CALL_*  |
| Approval Loops           | ad-hoc callbacks     | IDs & state machines  | & TOOL_CALL_RESULT    |
+──────────────────────────┼──────────────────────┼───────────────────────┼───────────────────────+
| Framework Portability    | Rewritten per agent  | Tightly coupled to    | Official adapters for |
|                          | framework upgrade    | socket server code    | LangGraph/ADK/Mastra+ |
+──────────────────────────┴──────────────────────┴───────────────────────┴───────────────────────+

تشمل التكاملات الرسمية كلاً من LangGraph وCrewAI وGoogle ADK وMicrosoft Agent Framework وAWS Strands Agents وMastra وPydantic AI وLlamaIndex وAgno وAG2 وClaude Agent SDK وOpenAI Agents SDK وSpring AI وCloudflare Agents، مع حزم مجتمعية للغات Kotlin وGo وJava وRust وSwift وDart.

5. مقارنة AG-UI مع مواصفات الواجهات التوليدية (A2UI وMCP Apps)

من المفاهيم الخاطئة الشائعة اعتبار AG-UI منافساً لمخططات الواجهات التصريحية مثل A2UI من Google أو Open-JSON-UI من OpenAI أو MCP Apps من Microsoft وShopify. في الواقع، يعمل كل منها في طبقة مختلفة:

  • مواصفات الواجهات التصريحية (ماذا نعرض): تصف A2UI وMCP Apps وOpen-JSON-UI بنية البطاقات والحقول والإجراءات للواجهات الديناميكية.
  • بروتوكول تشغيل AG-UI (كيف يتدفق ويتزامن): يمثل AG-UI قناة النقل ثنائية الاتجاه التي تحمل تلك الحمولات جنباً إلى جنب مع بث النصوص والاستدلال وتحديثات RFC 6902.
  • جسر وسطي رسمي جاهز: يوفر المستودع حزماً مثل @ag-ui/[email protected] لعرض مكونات A2UI أو MCP Apps مباشرة داخل CopilotKit وReact وAngular وVue أو الطرفية.

يمكن تشبيه AG-UI بالجهاز العصبي للنقل عبر SSE/Protobuf، بينما تمثل A2UI وMCP Apps بطاقات العرض المرئية التي تنتقل عبره.

6. قائمة فحص النشر الإنتاجي والتكامل

لاعتماد AG-UI 1.0 في بيئة الإنتاج دون إعادة كتابة منطق الوكلاء، اتبع هذه الخطوات الأربع:

# 1. Scaffold a full-stack AG-UI + CopilotKit application
npx create-ag-ui-app@latest

# 2. Or install core packages directly in TypeScript / Python / .NET
npm install @ag-ui/[email protected] @ag-ui/[email protected] @ag-ui/[email protected]
pip install ag-ui-protocol ag-ui-langgraph==0.1.0
dotnet add package AGUI.Client
  • الخطوة 1 — تهيئة المشروع أو تثبيت الحزم الأساسية: استخدم npx create-ag-ui-app@latest للمشاريع الجديدة، أو أضف @ag-ui/[email protected] وag-ui-protocol لتطبيقك الحالي.
  • الخطوة 2 — استخدام محولات الأطر الرسمية: اعتمد المحول الرسمي لإطارك مثل ag-ui-langgraph==0.1.0 أو ag_ui_adk==0.14.0 أو @ag-ui/[email protected] بدلاً من كتابة مرمّز أحداث يدوياً.
  • الخطوة 3 — عزل الوكلاء الفرعيين عبر subagentRunId: عند تفويض المهام عبر A2A أو تنفيذ رسوم بيانية متوازية، وسّم الأحداث بمعرّف subagentRunId لعرض خط زمني منظم.
  • الخطوة 4 — الدمج مع MCP وA2A وحماية دلتا الحالة: تحقق من صحة حمولات RunAgentInput واجعل رقع STATE_DELTA متكافئة التكرار (idempotent) عند إعادة الاتصال.

استكشف منظومة البروتوكولات الكاملة داخل دليل AgDex.ai وأداة 3-Step Stack Finder—بما في ذلك دليل مقارنة MCP وA2A والمراجعات المتعمقة لأدوات MCP وLangGraph وCrewAI، إلى جانب المواصفات السريعة لكل من AG-UI Protocol وCopilotKit وPydanticAI.

7. الأسئلة الشائعة (FAQ)

س1: هل يحل AG-UI محل MCP أو A2A؟

لا. يربط MCP الوكلاء بالأدوات والبيانات، ويربط A2A الوكلاء ببعضهم، بينما يربط AG-UI الوكلاء بواجهة المستخدم. تعتمد الأنظمة الإنتاجية على الثلاثة معاً.

س2: لماذا يعتمد AG-UI على HTTP + SSE افتراضياً بدلاً من فرض WebSockets؟

يعمل HTTP POST + SSE بسلاسة عبر وكلاء الشبكات المؤسسية وشبكات CDN وموازنات الأحمال القياسية، مع إتاحة Protobuf أو WebSockets اختيارياً عند الحاجة لزمن استجابة ثنائي فائق الانخفاض.

س3: كيف يتجنب AG-UI إرسال حمولات JSON ضخمة عند تغير الحالة؟

يدمج AG-UI بين لقطة أولية STATE_SNAPSHOT وأحداث STATE_DELTA التزايدية بصيغة JSON Patch (RFC 6902) لإرسال المفاتيح أو الفهارس المتغيرة فقط.

س4: ما اللغات وأطر الواجهة المدعومة؟

تغطي الحزم الرسمية TypeScript (@ag-ui/client) وPython (ag-ui-protocol) و.NET (AGUI.Client)، مع دعم CopilotKit لـ React وAngular وVue وReact Native، إضافة لحزم مجتمعية لـ Kotlin وGo وJava وRust وSwift وDart.