Repository navigation
fix: close a cut Gemini JSON array with an error; cut one WebSocket response, not the connection - #169
Merged
Conversation
…esponse, not the connection A passed-through Gemini stream without alt=sse that the tool wall or the output limit cut (or that broke) ended as a bare truncation. The relay now remembers whether the array was opened and had an element, and finishes it with a Gemini error element and the closing bracket, so the client gets a well-formed array ending in an error. On a Responses WebSocket the output limit counted the whole connection. It now restarts at every response.created; when one response goes over, the gateway sends a response.failed for that response id, drops the rest of that response's frames up to its completed/failed/incomplete, and keeps the connection open for the next request. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Merged
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.
Follow-up to #167, closing the two gaps it left.
alt=sse, passed through): when the tool wall or the output limit cuts the stream, or the upstream breaks, the relay now finishes the array with a Gemini error element ({"error":{...}}, message prefixed[ThinkWatch]) and], adding[or,as needed from what was already sent. The client gets a well-formed array. (Converted arrays were already closed by the converter; now asserted too.)response.created. When a response goes over, the gateway sendsresponse.failed(same shape as the SSE error frame,response.id= that response's id), drops that response's remaining frames through itsresponse.completed/failed/incomplete, and keeps the connection open. Observe mode records once per response.Tests:
conversion.rs(wall cut and output-limit cut both parse as a JSON array ending in an error),ws.rs(fake Responses upstream, two responses on one connection each cut with its ownresponse.failed).🤖 Generated with Claude Code