Fix OpenAI SSE relaying for Droid custom models#315
Open
amanshresthaa wants to merge 1 commit intoautomazeio:mainfrom
Open
Fix OpenAI SSE relaying for Droid custom models#315amanshresthaa wants to merge 1 commit intoautomazeio:mainfrom
amanshresthaa wants to merge 1 commit intoautomazeio:mainfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
event:/data:frames and Data-slice edge casesRoot Cause
Droid custom OpenAI models could fail through VibeProxy with OpenAI OAuth because VibeProxy forwarded backend OpenAI Responses streams too literally. In practice the client could receive partial SSE fragments such as
event: response.createdwithout the matchingdata:payload in the same message boundary, which caused Droid to fail withJSON Parse error: Unexpected EOF.A second issue showed up while fixing this: some backend responses arrived with
Transfer-Encoding: chunked, so the proxy needed to decode chunked bodies before reframing SSE. There were also Data index handling edge cases that could trap when working with sliced buffers.Changelog
ResponsesSSEFramerto buffer and merge fragmented OpenAI SSE framesHTTPChunkedDecoderto decode chunked event-stream bodies before reframingHTTPResponseRelayto rewrite SSE response headers and normalize response forwardingThinkingProxythrough the relay instead of forwarding raw chunks/v1/chat/completionsand/v1/responsesstreaming behavior consistent for Droid and similar clientsImplementation Details
New relay path
ThinkingProxy.receiveResponsenow carries the request path into a response relaystreamNextChunkforwards backend chunks throughHTTPResponseRelayforwardRelayedResponseChunksandsendResponseChunksserialize rewritten chunks back to the clientSSE framing
event:frames until the matchingdata:line arrivesChunked decoding
Transfer-Encoding: chunkedon event-stream responsesConnection: closeSafety / regression handling
Testing
swift buildcurlverification for/v1/chat/completionsstreaming through VibeProxycurlverification for/v1/responsesstreaming through VibeProxyevent:anddata:were emitted together after the fixdroid exec --model custom:gpt-5.4(xhigh) ...against the patched app, verified end-to-end successManual Verification Notes
Before the fix, Droid reproducibly failed on the proxy path with split SSE fragments and
Unexpected EOFparsing errors.After the fix:
/v1/chat/completionsstreams returned clean SSE data through the proxy/v1/responsesstreams returned combinedevent:+data:frames instead of standalone event fragments