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.
Part 1
Network Chunks Corrupted My Text and Crashed My JSON: Buffer Before You Parse
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.
Part 2
Dropped Tokens: Fixing Multi-Turn Agent Streams That Die Mid-Flight
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.
Part 3
200 Tokens a Second Locked Up My Browser: Client-Side Defense for Agent Streams
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.