Repository navigation
fix(antigravity): skip SSE comment keepalives for js-genai < 1.32 (Gemini CLI) - #9001
Open
chengjingtao wants to merge 1 commit into
Open
chengjingtao wants to merge 1 commit into
chengjingtao wants to merge 1 commit into
Conversation
Contributor
|
All contributors have signed the CLA. ✅ |
Author
|
I have read the CLA Document and I hereby sign the CLA |
…mini CLI)
js-genai before 1.32.0 parses the stream with
/^\s*data: (.*)(?:\n\n|\r\r|\r\n\r\n)/ anchored at the head of its
buffer, so the first ":\n\n" keepalive blocks every later event and the
stream fails with "Incomplete JSON segment at the end". Gemini CLI (up to
0.70.0) pins js-genai 1.30.0 and sends it in X-Goog-Api-Client
("google-genai-sdk/1.30.0 gl-node/..."), so long native Gemini streams
fail for every Gemini CLI user (Wei-Shaw#8941). js-genai 1.32.0 (c9c1359) splits
the buffer at each delimiter and drops non-data events, so newer Node
clients keep the keepalive.
Treat gl-node clients with google-genai-sdk < 1.32 like go-genai and
python-genai. The old "js-genai tolerates comments" test case used 1.9.0,
which also stalls; it now expects the skip.
Fixes Wei-Shaw#8941
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
chengjingtao
force-pushed
the
fix/gemini-sse-comments-old-js-genai
branch
from
November 21, 2026 12:23
a3f52fa to
bff0f15
Compare
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
Fixes #8941.
On the Antigravity native Gemini stream, the
":\n\n"idle keepalive is already skipped for go-genai and python-genai (#7278). js-genai before 1.32.0 has the same problem:processStreamResponsematches/^\s*data: (.*)(?:\n\n|\r\r|\r\n\r\n)/only at the head of its buffer.Incomplete JSON segment at the end.Gemini CLI pins js-genai 1.30.0 (still the case in v0.70.0,
packages/core/package.json). Any long generation with an upstream pause of ≥stream_keepalive_intervalfails after the CLI's retries.Gemini CLI's
User-AgentisGeminiCLI/..., but it sends the SDK inX-Goog-Api-Client, e.g.google-genai-sdk/1.30.0 gl-node/v24.22.3.downstreamRejectsSSECommentsalready reads that header.js-genai 1.32.0 (c9c1359) splits the buffer at each delimiter and drops non-
data:events. It handles the keepalive, so newer Node clients keep it.Change
geminiClientRejectsSSECommentsalso returns true forgl-node/clients whosegoogle-genai-sdk/version is below 1.32. If the version can't be parsed, the keepalive is kept, which is the current behavior."js-genai tolerates comments"usedgoogle-genai-sdk/1.9.0 gl-node/..., but 1.9.0 also stalls (see the replay in [Bug] Antigravity Gemini native stream: ":\n\n" keepalive comments break Gemini CLI stream parsing ("Incomplete JSON segment at the end") #8941), so it now expects the skip.Matching on the SDK version rather than the Gemini CLI
User-Agentalso covers direct Node users of old js-genai, as suggested in #8941.Verification
go test -tags=unit ./internal/service/ -count=1: okgo vet -tags=unit ./internal/service/: cleangolangci-lintwas not run locally; left to CI.":\n\n"frames. Replaying it through the real Gemini CLI bundle reproducedIncomplete JSON segment at the end, and the same bytes with only the comment frames removed parsed cleanly.AI-assisted implementation; reviewed and verified locally.