Repository navigation
Description
Summary
When the authbridge-proxy reverse proxy re-frames a streaming (text/event-stream) response — which it does whenever a response-side StreamingResponder plugin (e.g. inference-parser) is active — it corrupts the stream in ways that break spec-compliant SSE clients such as the Anthropic SDK. A client reading the proxied stream decodes zero typed events, so an agent loop driving tools/structured-output over the proxied LLM never sees any content and stalls.
Root causes
-
SSE
event:lines are dropped.authlib/listener/internal/sseframesurfaces only thedata:payload (it skipsevent:/id:/retry:by design), and the streaming re-framer inauthlib/listener/reverseproxy/server.gore-emits onlydata: <payload>. Anthropic's SSE (and the Anthropic SDK's parser) type each event from theevent:line; without it the parser yields nothing.- Observed (raw bytes): upstream
event: message_start\ndata: {…}→ proxieddata: {…}(noevent:).
- Observed (raw bytes): upstream
-
Content-Encoding: gzipreturned over re-framed plaintext. The reverse proxy forwards the client'sAccept-Encoding: gzipto the backend, receives a gzipped body, but the re-framer emits plaintext while theContent-Encoding: gzipresponse header is preserved. A client that requested gzip (the Anthropic SDK does;wgetdoes not — which masks the bug) tries to gunzip plaintext and gets an empty/garbage stream. -
Non-
Authorizationinbound header mutations are dropped, and the backendHostis not rewritten (found in the same investigation). The reverse proxy only propagated anAuthorizationchange from the inbound pipeline to the forwarded request, silently dropping any other header a plugin set (e.g.x-api-key), and usedhttputil.NewSingleHostReverseProxywith noDirector, so the backend received the inboundHostrather than the target host — which Cloudflare-fronted backends (api.anthropic.com) reject.
Impact
Any SSE/streaming client behind the reverse proxy with a StreamingResponder plugin active — notably LLM agent loops proxying Anthropic — receives an empty event stream and cannot function. This blocked the RC1 AuthBridge egress PoC (harness→AB1→api.anthropic.com); the fixes are validated end-to-end there.
Fix
See the linked PR:
sseframe.Readercaptures theevent:field (LastEvent()); the re-framer emitsevent: <type>beforedata:.- The Director strips the client's
Accept-Encodingso Go's transport transparently decompresses (noContent-Encodingover plaintext). - The reverse proxy forwards the full inbound header diff to the backend, and the Director rewrites
Hostto the backend target.
Includes Go unit tests for each (sseframe event capture; reverse-proxy event: preservation, Accept-Encoding strip, full-header propagation, Host rewrite).
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity