Skip to content

fix: close a cut Gemini JSON array with an error; cut one WebSocket response, not the connection - #169

Merged
fylorn merged 1 commit into
mainfrom
fix/json-array-and-ws-limit
Sep 24, 2026
Merged

fylorn merged 1 commit into
mainfrom
fix/json-array-and-ws-limit

Conversation

@fylorn

@fylorn fylorn commented Sep 24, 2026

Copy link
Copy Markdown
Contributor

Follow-up to #167, closing the two gaps it left.

  • Gemini JSON-array streams (client without 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.)
  • WebSocket output limit per response: the meter restarts at each response.created. When a response goes over, the gateway sends response.failed (same shape as the SSE error frame, response.id = that response's id), drops that response's remaining frames through its response.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 own response.failed).

🤖 Generated with Claude Code

…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>
@fylorn
fylorn merged commit 2838f47 into main Sep 24, 2026
3 checks passed
@fylorn
fylorn deleted the fix/json-array-and-ws-limit branch September 24, 2026 08:18
@fylorn fylorn mentioned this pull request Sep 24, 2026
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.

1 participant