Skip to content

fix(antigravity): skip SSE comment keepalives for js-genai < 1.32 (Gemini CLI) - #9001

Open
chengjingtao wants to merge 1 commit into
Wei-Shaw:mainfrom
chengjingtao:fix/gemini-sse-comments-old-js-genai
Open

chengjingtao wants to merge 1 commit into
Wei-Shaw:mainfrom
chengjingtao:fix/gemini-sse-comments-old-js-genai

Conversation

@chengjingtao

Copy link
Copy Markdown

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:

  • Its processStreamResponse matches /^\s*data: (.*)(?:\n\n|\r\r|\r\n\r\n)/ only at the head of its buffer.
  • The first comment frame therefore blocks every later event.
  • The stream then fails at EOF with 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_interval fails after the CLI's retries.

Gemini CLI's User-Agent is GeminiCLI/..., but it sends the SDK in X-Goog-Api-Client, e.g. google-genai-sdk/1.30.0 gl-node/v24.22.3. downstreamRejectsSSEComments already 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

Matching on the SDK version rather than the Gemini CLI User-Agent also covers direct Node users of old js-genai, as suggested in #8941.

Verification

AI-assisted implementation; reviewed and verified locally.

@github-actions

github-actions Bot commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

All contributors have signed the CLA. ✅
Posted by the CLA Assistant Lite bot.

@chengjingtao

Copy link
Copy Markdown
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
chengjingtao force-pushed the fix/gemini-sse-comments-old-js-genai branch from a3f52fa to bff0f15 Compare November 21, 2026 12:23
github-actions Bot added a commit that referenced this pull request Nov 21, 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.

[Bug] Antigravity Gemini native stream: ":\n\n" keepalive comments break Gemini CLI stream parsing ("Incomplete JSON segment at the end")

1 participant