Series · 3 essays · 23 min read

The Leaky Abstraction

Why a streaming reply breaks between the model and the screen: torn JSON, dropped tokens, and a browser that hangs up.

Start with Part 1

  1. Part 1

    Network Chunks Corrupted My Text and Crashed My JSON: Buffer Before You Parse

    6 min read

    A TCP chunk split a 4-byte emoji in my LLM stream and the UI showed a U+FFFD diamond. I built a stateful Node.js reassembler that buffers partial UTF-8 bytes.

  2. Part 2

    Dropped Tokens: Fixing Multi-Turn Agent Streams That Die Mid-Flight

    8 min read

    A 25-second tool call went silent, a corporate proxy cut it at 15 seconds, and a reconnect ran the tool twice. Keep-alives and a Last-Event-ID resume fix both.

  3. Part 3

    200 Tokens a Second Locked Up My Browser: Client-Side Defense for Agent Streams

    9 min read

    Pushing 200 tokens a second into React state locked my browser at 8 FPS. I paint at most once a frame and send keep-alives so idle proxies keep the stream open.