Build1 distinct publisher3 min readUpdated
A coalescing middleware in claude-code-router merged streaming deltas back into chunks, unblocking control messages that had queued behind six thousand of them.
The Engineer · Build desk

Compiled by The EngineerSomething wrong?How this is made
An approval prompt in Claude Code once sat for an hour because the CLI's own control messages were queued behind six thousand streaming deltas, produced one event per token, in front of a VS Code extension that could not burn them down fast enough [2]. The repair went into claude-code-router, a self-hosted proxy that lets the same CLI point at either the official Anthropic API or third-party providers [1], because of the three components implicated, it was the only one the author could change [6].
The other two addresses were closed. Provider granularity was the provider's [3]. The extension is closed source [4]. The router, by contrast, was his container, his compose file, his rules [5]. That framing set the target: the official Anthropic API already streams in merged chunks and the extension digests those fine, so the goal was never a faster extension but a stream shaped like the one the extension already handles [7].
The hard part is not merging. It is merging without changing what the stream means, since a stall costs an hour and a lying stream costs the session [8]. The rule the author settled on is narrow: merge consecutive content_block_delta events only when they carry string payloads for the same block index and the same delta type, text into text, thinking into thinking, partial JSON into partial JSON, and flush the moment any other event appears [9]. Same index matters because one assistant message interleaves blocks, and merging across an index change fuses two blocks that never existed [10]. content_block_start, content_block_stop, message_delta and message_stop carry protocol meaning, so they empty the window and pass through untouched, in order [11]. The middleware understands nothing about the conversation, which the author treats as the safety property rather than a limitation [12].
The tuning surface is one knob with exceptions. CCR_SSE_COALESCE_MS sets the window globally, and zero disables the middleware outright [13]. Per-type overrides followed, CCR_SSE_COALESCE_THINKING_MS, _TEXT_MS and _INPUT_JSON_MS, because thinking deltas can afford to wait and text is what a human watches appear [14]. A per-type value of zero or less falls back to the global instead of switching that type off, because a zero-width window has no timer to flush it and would strand data until the stream ended [15]. Keep-alive pings are dropped by default, restorable with CCR_SSE_DROP_PINGS=0, on the grounds that a ping arriving mid-thinking-run would flush the window exactly where the stream is densest [16].
Two transport beliefs break when you rewrite bodies. Content-length is removed, because a client honoring a stale header will truncate or hang and SSE travels chunked anyway [17]. For compression, the middleware requests accept-encoding: identity, and if a compressed response arrives regardless it bypasses itself and passes the stream through untouched [18]. And because the original bug was a slow reader backing up a pipe, eager buffering would simply move the balloon one floor up: the queue pauses when the downstream consumer signals stop and resumes when it signals go [19].
Watch the deployment half. Writing the middleware took an evening; getting it to actually run took five attempts [20]. Also watch the bypass path, since any provider that ignores the identity request returns you to the original stall.
Follow any of these and your For You feed starts watching them — no settings page required.
Ranked by verification strength, evidence, and original report placement.
Claude Code on the author's machine 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, observed through the VS Code extension over Remote-SSH.
A previous piece, Two Clocks, Neither Lying, worked out why an approval prompt once sat for an hour: one streaming event per token, an extension that could not burn them down fast enough, and the CLI's own control messages queued behind six thousand deltas.
The rule: merge consecutive content_block_delta events only when they carry string payloads for the same block index and the same delta type (text into text, thinking into thinking, partial JSON into partial JSON), and flush the moment any other event appears.
The same-index clause exists because one assistant message interleaves blocks (text, then a tool call, then more text) and block boundaries are how the client tells them apart; merging across an index change fuses two blocks into one that never existed.
content_block_start, content_block_stop, message_delta and message_stop all carry protocol meaning, so the window empties and those events pass through untouched, in order.
The fix was two problems in sequence, writing the merging middleware and then getting it to actually run; the first took an evening and the second took five attempts.
Evidence-backed comparisons of source perspectives and observed adoption signals. Read the methodology
Which Builder, Operator, and Investor concerns the observed source mix emphasized—not a truth score.
Evidence, demonstrated adoption, hype gap, incentives, and confidence are assessed independently, each on its own current evidence. How these are measured.
Detailed mechanism, no measurements or independent copy
The source is unusually specific about mechanism - the exact merge predicate, which events flush, the environment-variable surface, header and compression handling, backpressure behaviour, and four named failed deployment attempts - which makes the design falsifiable by anyone reading the protocol. But it is one author's first-person account with no logs, timings, repository link, test results or post-fix latency figures, and the cluster's second item is the same text republished on the same publisher rather than corroboration. Both copies are also truncated mid-sentence in attempt four.
One developer's own container
The only adoption evidence is the author's disclosure that the middleware runs in his personal self-hosted claude-code-router setup. No upstream contribution, package release, download or user count, and no other operator or organization is reported as running it.
Restrained framing, but the fix is asserted rather than measured
Rhetoric is deliberately modest: the author scopes the work to his own container, states that the middleware 'can't repeal' the stream's economics, and prefers declining work it cannot vouch for. The mild overstatement is evidential rather than promotional - the headline framing that control messages were unblocked rests on no post-fix timing, no test suite proving semantic preservation, and no second environment, while the prior hour-long stall is recalled from an earlier piece.
Personal build log, no disclosed commercial stake
The material is a developer's own account of tooling he built for himself, published on a community platform, and it links back to his earlier post in the same series - an audience and reputation incentive plus mild self-promotion of his own middleware. No vendor sponsorship, employer, product sale, funding or licensing interest is disclosed anywhere in the sources, and the piece is candid about failed attempts, which cuts against strong distortion.
Internally coherent single-source engineering account
Confidence is limited by structure rather than plausibility: the mechanism is coherent and consistent with how SSE and block-indexed delta streams work, but every claim traces to one author on one machine, the second cluster item is a duplicate of the first, there are no measurements, and the text is truncated before the working configuration is fully described.
build
A 12MB Go binary bets agent cost control is cache stickiness, not a dashboard1 distinct publisher
build
A session that read "finished" and "still executing" was a slow queue, not a dropped handshake1 distinct publisher
build
Your Multi-Key Failover Is The Most Expensive Line On Your Coding Agent Bill1 distinct publisher
science
OX Security says MCP command execution is a design choice, so server owners own the risk1 distinct publisher
Distinct publishers with included, body-backed reporting in this cluster.
dev.to
2 articles · August 15, 2026