ai-core/ag-ui-protocol

Convert TanStack AI chat iterables into AG-UI compliant SSE or NDJSON streams.

3.0k|295|Updated Oct 8, 2025
One-click install
npx skills add https://github.com/TanStack/ai --skill ai-core-ag-ui-protocol
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: ai-core/ag-ui-protocol
Source: https://github.com/TanStack/ai/tree/main/packages/typescript/ai/skills/ai-core/ag-ui-protocol
Command: npx skills add https://github.com/TanStack/ai --skill ai-core-ag-ui-protocol

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill ensures backend streams for TanStack AI are delivered as AG-UI compliant events so adapters can render typed tool calls, state snapshots, and message flows without translating proprietary formats.

Core Features & Use Cases

  • SSE and NDJSON telemetry: Convert AsyncIterable chat streams into Server-Sent Events or newline-delimited JSON for web clients implementing AG-UI.
  • Typed event catalog: Document the full suite of StreamChunk types such as run lifecycle events, text deltas, tool call arguments, steps, state snapshots, and custom messages so frontends can react precisely.
  • Production readiness: Demonstrates header customization, abort handling, and error reporting to keep SSE/HTTP streams stable behind proxies and when tool failures occur.

Quick Start

Start by generating chat stream data with TanStack AI and wrapping it in the SSE helper so AG-UI clients receive typed StreamChunk events.

Frequently Asked Questions about ai-core/ag-ui-protocol

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

FAQPage Schema
How do I stream AI chat responses as Server-Sent Events for frontend clients?

To stream AI chat responses as Server-Sent Events, you wrap TanStack AI chat iterables in an SSE helper. This converts backend streams into AG-UI compliant typed events for web clients to consume directly over HTTP.

What is the difference between SSE and NDJSON for streaming AI chat events?

SSE (Server-Sent Events) and NDJSON (newline-delimited JSON) are both supported formats for streaming AI chat events. SSE maintains a persistent HTTP connection for real-time updates, while NDJSON sends structured JSON lines for simpler event parsing.

How do I handle tool call failures and aborts during HTTP event streaming?

Handle tool call failures and aborts during HTTP event streaming by utilizing built-in abort handling and RUN_ERROR reporting. These features ensure streams remain stable and properly report errors when tool failures occur.

How do I expose typed state snapshots and text deltas from my AI backend?

Expose typed state snapshots and text deltas by converting backend iterables into a typed StreamChunk event catalog. This documents full event suites including tool call arguments, steps, and custom messages for precise frontend reactions.

Can I use TanStack AI chat streams behind reverse proxies?

Yes, you can use TanStack AI chat streams behind reverse proxies. The streaming mechanism includes header customization and proxy-friendly diagnostics to keep SSE and HTTP streams stable in restricted network environments.

Why do my AG-UI frontend adapters fail to render tool calls from custom backend streams?

AG-UI adapters fail to render tool calls from custom streams because they expect compliant event formats. Converting your backend streams to the AG-UI typed StreamChunk catalog ensures proper synchronization of tool calls and state updates.