forge-llm-streaming

Stream LLM responses to browser UIs via SSE with typed events and cancellation.

Updated Aug 23, 2026
One-click install
npx skills add https://github.com/f4rkh4d/forge-skill --skill forge-llm-streaming
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: forge-llm-streaming
Source: https://github.com/f4rkh4d/forge-skill/tree/main/skills/llm/forge-llm-streaming
Command: npx skills add https://github.com/f4rkh4d/forge-skill --skill forge-llm-streaming

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill prevents flicker, broken Unicode, slow time-to-first-token, and non-working stop buttons when streaming LLM output to a UI, by enforcing a correct producer/consumer streaming model with proper transport, decoding, cancellation, and mid-stream error handling.

Core Features & Use Cases

  • Transport-correct SSE streaming: Uses Server-Sent Events with the required headers to avoid proxy buffering and ensures each event is parseable on arrival.
  • Structured event protocol: Streams typed events (delta/tool calls/done/error) with sequence numbers so the client can reassemble state reliably.
  • Production-grade cancellation chain: Wires AbortController end-to-end (browser → server → upstream) so “stop” actually stops the LLM and prevents wasted tokens.
  • Unicode-safe incremental decoding: Uses streaming TextDecoder behavior to avoid corrupt characters when multi-byte tokens cross chunk boundaries.
  • Append-only UI rendering with backpressure discipline: Throttles re-renders, avoids full tree re-render per token, prevents auto-scroll yanks, and renders incrementally for responsiveness.
  • Mid-stream errors as stream events: Returns errors after the HTTP 200 as in-band events, then renders them inline rather than relying on HTTP status codes.

Quick Start

Ask your AI coding agent to implement an SSE-based streaming endpoint and a browser reader that decodes UTF-8 incrementally, appends deltas, renders at paragraph boundaries, and propagates cancellation via AbortController.

Frequently Asked Questions about forge-llm-streaming

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

FAQPage Schema
How do I implement SSE streaming for LLM responses without breaking Unicode characters?

SSE streaming for LLM responses requires incremental UTF-8 decoding using a streaming TextDecoder to prevent broken characters when multi-byte tokens cross chunk boundaries. This approach ensures correct parsing of each event on arrival without corrupting text.

Why does my LLM stop button fail to cancel token generation on the server?

LLM stop buttons fail when AbortController is not wired end-to-end from browser to server to upstream. A production-grade cancellation chain must propagate the abort signal to stop the LLM and prevent wasted tokens immediately.

What is the best way to handle mid-stream errors during LLM streaming after HTTP 200?

Mid-stream errors during LLM streaming should be handled as in-band SSE events after returning HTTP 200. The server sends typed error events within the stream, allowing the client to render them inline rather than relying on HTTP status codes.

How do I prevent UI flicker and auto-scroll yanks during incremental rendering of LLM tokens?

Preventing UI flicker during incremental rendering requires append-only updates with render throttling at paragraph boundaries. This backpressure discipline avoids full tree re-renders per token and stops auto-scroll yanks for smooth LLM output.

Do I need sequence numbers for streaming LLM tool calls to a browser UI?

Sequence numbers are needed for streaming LLM tool calls to ensure the browser client can reliably reassemble state from typed events. A structured event protocol with ordered sequences guarantees correct delta processing for tool-call visualizers.

What HTTP headers are required to avoid proxy buffering when streaming LLM output via SSE?

Avoiding proxy buffering when streaming LLM output via SSE requires specific transport-correct HTTP headers. These headers ensure each Server-Sent Event is parseable on arrival and prevents intermediaries from holding the stream buffer.