Skip to content

Fix Anthropic Streaming Responses#479

Merged
ericdallo merged 1 commit into
editor-code-assistant:masterfrom
bobrowadam:fix-anthropic-streaming-responses
May 30, 2026
Merged

Fix Anthropic Streaming Responses#479
ericdallo merged 1 commit into
editor-code-assistant:masterfrom
bobrowadam:fix-anthropic-streaming-responses

Conversation

@bobrowadam
Copy link
Copy Markdown
Contributor

Problem

Anthropic streaming responses arrive all at once at the end instead of
token-by-token. Anthropic gzip-compresses the SSE body and hato decompresses
it, but GZIPInputStream only emits bytes once a full deflate block arrives,
so the stream is buffered until the response is nearly complete.

Fix

Send accept-encoding: identity and set hato's
:decompress-body false so the event-stream stays uncompressed and can be read
line-by-line.

Tradeoff

SSE text is no longer gzipped, but for interactive use it's negligible and time-to-first-token improves.
Server-side chunk granularity is unchanged.

Anthropic gzip-compresses the streaming response by default. Decompression
buffers the SSE body until a full deflate block arrives, so the whole reply
effectively lands at the end instead of streaming incrementally.

Send "accept-encoding: identity" so the event stream stays uncompressed, and
set hato's :decompress-body false so the default middleware doesn't re-add
"gzip, deflate" or try to decompress. Together they let the SSE stream be read
line-by-line and surfaced token-by-token in the UI.
Copy link
Copy Markdown
Member

@ericdallo ericdallo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting, thanks for that!

@ericdallo ericdallo merged commit 222dbc1 into editor-code-assistant:master May 30, 2026
9 checks passed
@bobrowadam bobrowadam deleted the fix-anthropic-streaming-responses branch May 30, 2026 19:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants