copilotkit-agui

Implement AG-UI protocol backends that stream typed agent events over SSE to frontends.

Updated May 9, 2026
One-click install
npx skills add https://github.com/23wj1a0541/L.E.N.S --skill copilotkit-agui-23wj1a0541
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: copilotkit-agui
Source: https://github.com/23wj1a0541/L.E.N.S/tree/main/.cursor/skills/copilotkit-agui
Command: npx skills add https://github.com/23wj1a0541/L.E.N.S --skill copilotkit-agui-23wj1a0541

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires @ag-ui/core, @ag-ui/client, @ag-ui/encoder, rxjs, and includes references (resource) components.

What problem does it solve? Building a custom agent backend that communicates with a CopilotKit frontend requires correctly implementing the AG-UI event protocol, and mistakes in event ordering, SSE encoding, or state synchronization cause silent streaming failures that are hard to debug. ## Core Features & Use Cases - Complete Event Reference: Covers all AG-UI event families including lifecycle, text messages, tool calls, state snapshots/deltas, reasoning, and activity events with full schemas. - Backend Implementation Guide: Step-by-step patterns for extending AbstractAgent, exposing HTTP SSE endpoints with EventEncoder, and handling tool call round-trips. - Client SDK Reference: Documents HttpAgent, subscribers, middleware, and event application logic for debugging why events do not reach the frontend. - Use Case: You are building a custom agent server in TypeScript and the frontend never renders streamed text. Use this Skill to verify your event ordering (RUN_STARTED first, TEXT_MESSAGE triads, RUN_FINISHED last) and SSE wire format. ## Quick Start Use the copilotkit-agui skill to help me build an Express endpoint that streams AG-UI events for a simple echo agent.

Frequently Asked Questions about copilotkit-agui

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I build an AG-UI agent backend in TypeScript?▼

Extend AbstractAgent and implement run() to return an RxJS Observable of events, or create an HTTP endpoint that accepts RunAgentInput and writes SSE-encoded events using EventEncoder from @ag-ui/encoder. Always emit RUN_STARTED first and RUN_FINISHED or RUN_ERROR last.

What is the correct AG-UI event ordering for streaming text?▼

Emit RUN_STARTED first, then TEXT_MESSAGE_START, one or more TEXT_MESSAGE_CONTENT events with non-empty deltas, TEXT_MESSAGE_END, and finally RUN_FINISHED. Alternatively, use TEXT_MESSAGE_CHUNK events which the client auto-expands into the full triad.

How do tool calls work between an AG-UI agent and the frontend?▼

The agent emits TOOL_CALL_START, TOOL_CALL_ARGS, and TOOL_CALL_END linked by toolCallId, then typically ends the run. The client executes the tool, adds the result as a tool-role message, and starts a new run where the agent reads the result from input.messages.

What is the difference between STATE_SNAPSHOT and STATE_DELTA in AG-UI?▼

STATE_SNAPSHOT replaces the entire client-side state with a complete object. STATE_DELTA applies incremental updates as RFC 6902 JSON Patch operations against existing state, which is more efficient for frequent small changes.

Why are my AG-UI events not reaching the frontend?▼

Common causes include missing SSE headers (Content-Type: text/event-stream), malformed data lines that fail Zod schema parsing, incorrect event ordering, or empty delta strings. Verify the wire format matches 'data: {JSON}\n\n' and events pass the client's verifyEvents check.

When should I not use the AG-UI protocol directly?▼

Do not implement AG-UI manually when working with CopilotKit React hooks, runtime setup, or existing framework integrations like LangGraph, Mastra, or CrewAI, since those already handle the protocol. Use it only for custom backends or new framework integrations.