Urgent.News

600+ sources. One page. See who else covered it.

Editions

Tech

Coalescing the Stream

Claude Code, on my box, doesn't talk to a model provider directly. It goes through claude-code-router (ccr) — a self-hosted proxy that lets the same CLI point at the official Anthropic API or at third-party providers — and I watch the whole thing through the VS Code extension over Remote-SSH. The previous piece, Two Clocks, Neither Lying , worked out why that path once let an approval prompt sit…

Claude Code does not communicate directly with a model provider. Instead, it utilizes the claude-code-router, a self-hosted proxy that allows the same CLI to point at either the official Anthropic API or third-party providers. The reporter observes the entire process through the VS Code extension over Remote-SSH. The previous article, Two Clocks, Neither Lying, explained why the previous path allowed an approval prompt to sit for an hour due to one streaming event per token, an extension struggling to process them quickly, and the CLI queuing control messages behind six thousand deltas.

This piece focuses on the solution, which involved two sequential steps: writing a middleware that merges streaming events back into chunks, and ensuring the middleware actually runs. The first step took an evening, while the second required five attempts. The middleware must merge consecutive content_block_delta events without altering the stream's meaning.

A successful merge only occurs when events share the same block index and delta type, and the window is flushed when any other event appears. The middleware does not understand the conversation; it only combines events that can be proved interchangeable. The window controls merging aggressiveness, with a global setting and per-type overrides to cater to different event types.

Keep-alive pings are dropped by default to prevent flushing the window at critical points in the stream. The middleware must merge only what it fully understands, declining the rest to avoid corruption. Two key transport truths must be maintained: the content-length header changes after merging, and compression must not be applied to merged bodies.

The original issue was a slow reader backing up a pipe, and a naive merger would just relocate the problem. The solution was to create a middleware that merges events without changing the stream's semantics, ensuring the downstream consumer only receives coherent data.

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 Tech

Two Clocks, Neither Lying

The night of August 14th, Claude Code was planning me a trip. An eight-day itinerary — not code, just travel planning — running in the VS Code extension against the remote box where my sessions live.

  • Two clocks displayed different information about session status
  • Session was both finished and unfinished due to rendering delay
  • Issue caused over an hour delay in showing approval notification

The Twenty-Hour Fuse

Two nights of debugging, one incident left to write about. The night of August 14th, a Claude Code session hung for an hour inside the VS Code extension, and I traced it to a per-token streaming stall…

  • Claude Code session froze for an hour on August 14th
  • Server instability caused by high load average of 38.7
  • Llama.cpp process consumed excessive memory and triggered IO storm

More from Saturday 15 August →