What problem does it solve? Building a real-time chat interface for an AI agent involves tricky problems: tokens arriving in bursts, dropped connections, flickering text, and users who want to stop generation mid-stream. This Skill provides production-tested patterns for wiring a Next.js frontend to an AI agent backend over SSE and WebSocket, with reconnection logic and UX feedback built in. ## Core Features & Use Cases - SSE Token Streaming: FastAPI StreamingResponse backend paired with a useSSEStream React hook featuring exponential back-off reconnection and typed chunk handling (token, tool_call, tool_result, done, error). - WebSocket Status Channels: Bidirectional agent status and sandbox lifecycle events with automatic reconnect and heartbeat handling. - Streaming UX Patterns: Thinking/streaming/done state machine, Stop Generation button via AbortController, scroll anchoring with jump-to-bottom, and offline detection banners. - Performance Checklist: Diagnoses common issues like flickering text, scroll jumps, Nginx buffering, and per-token markdown parsing. - Use Case: You are building a chat UI for a LangGraph agent and tokens appear in 30-second bursts instead of streaming smoothly — this Skill identifies the missing X-Accel-Buffering header and provides the corrected FastAPI and React code. ## Quick Start Ask the AI to set up SSE token streaming between your FastAPI agent backend and Next.js chat frontend with automatic reconnection and a stop-generation button.