Urgent.News

What's breaking now, across thousands of outlets.

AI

5 Mistakes That Make LLM Streaming Break on a Flaky Network

Your chat UI looks fine on the office Wi-Fi. Then someone joins from a train, the SSE connection drops mid-sentence, and either the answer restarts from scratch or the model keeps burning tokens while nobody is listening. Same feature, different network. I spent a stretch of time turning a "works in demos" stream into something that survives reconnects. The full working project (ASP.NET Core 10,…

The article titled "5 Mistakes That Make LLM Streaming Break on a Flaky Network" outlines common issues that arise when implementing live language model streaming over unreliable networks. Five key mistakes are identified and explained:

1. Tying generation to the HTTP request - Generating responses should be separated from the HTTP request. Starting generation in a registry and returning a 202 response with a stream ID allows generation to continue even if the subscriber disconnects. This prevents wasted computation when the connection is lost and the model restarts.

2. Lack of sequence IDs - Without unique sequence IDs, reconnecting causes the client to restart the entire generation process. Including an append-only stream log with sequence numbers enables clients to replay only the missed events after reconnecting.

3. Naming error events - Using "error" as an event name can cause confusion with the default EventSource error handler. The article recommends using a distinct "failed" event name with a user-friendly error message and an errorId for debugging.

4. Silent streams and lack of a stop button - Proxies and load balancers can leave SSE connections idle, leading to disconnections. Implementing heartbeats while work is in progress and providing a cancellation endpoint allows users to cancel the model generation and prevents unnecessary token usage.

5. Incomplete API implementation - The "quick stream" implementation provided is not suitable for production. The article lists several additional features and best practices for a robust streaming API, including sequence IDs, cancellation, heartbeats, owner authentication, sticky sessions, and the use of HTTP/2 or HTTP/3.

The article emphasizes that flaky networks are not an edge case and recommends implementing a complete resumable streaming solution before considering a project complete. The author provides the complete source code and detailed implementation in a separate package available to subscribers.

Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.

Read the original at dev.to →

More in AI

Route Once, Fail Over Among Equals: When NOT to Retry an LLM Call

Most LLM APIs I review have one IChatClient and a prayer. Hello goes to the same model as "why does this async code deadlock under load." When that provider returns 503 for twenty minutes, so does the…

  • Only fail over among models of equal quality or reliability.
  • Do not retry when provider returns 400, indicating malformed request.
  • Commit only once when streaming the first token to avoid half-answer.

TouchGrass: An AI Whose Success Is Measured by How Quickly You Stop Using It 🌱

This is a submission for the Hacktoberfest Open-Source AI Challenge Week 1: Touch Grass What I Built TouchGrass is an AI-powered application built for the Hacktoberfest ’26 Week 1 challenge, Touch…

  • TouchGrass AI encourages outdoor activities over device usage
  • Users customize mission details like activity, duration, and difficulty
  • Open-weight model ensures adaptable mission generation

Build an AI-powered extension that helps students learn more effectively

Build an AI-powered extension that helps students learn more effectively. Features to add AI Tutor — answers questions based on course content.

  • AI-powered extension enhances student learning experience
  • Features include AI Tutor, Smart Quiz Generator, and voice learning
  • Open-source models offer transparency and customization

More from Saturday 10 October →