fix(core): improve diagnostics for malformed streaming responses#22352
fix(core): improve diagnostics for malformed streaming responses#22352junaiddshaukat wants to merge 12 commits into
Conversation
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly enhances the diagnostic capabilities and robustness of the streaming pipeline. By introducing explicit warnings for malformed or incomplete streamed responses and refining the Server-Sent Events (SSE) parser's behavior, it makes it much easier to detect and debug issues in streaming interactions, ensuring more reliable operation without altering behavior for healthy streams. Highlights
Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request improves the robustness and diagnostics of the streaming pipeline by adding warnings for malformed or incomplete stream data and correctly handling streams that end without a final blank line. The changes are well-tested and improve debuggability. I have one suggestion regarding code duplication in the SSE parser to enhance maintainability and ensure error logging adheres to best practices.
|
Hi there! Thank you for your interest in contributing to Gemini CLI. To ensure we maintain high code quality and focus on our prioritized roadmap, we have updated our contribution policy (see Discussion #17383). We only guarantee review and consideration of pull requests for issues that are explicitly labeled as 'help wanted'. All other community pull requests are subject to closure after 14 days if they do not align with our current focus areas. For this reason, we strongly recommend that contributors only submit pull requests against issues explicitly labeled as 'help-wanted'. This pull request is being closed as it has been open for 14 days without a 'help wanted' designation. We encourage you to find and contribute to existing 'help wanted' issues in our backlog! Thank you for your understanding and for being part of our community! |
|
@junaiddshaukat, apologies for the bot closing this PR! We have reopened it. Please sync your branch to the latest |
Resolve conflict in packages/core/src/code_assist/server.ts by keeping the deduplicated yieldBufferedChunk helper introduced in this PR, which covers the same logic that upstream inlined.
|
@cocosheng-g i have resolved the merge confilcts. |
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request improves the robustness of the Gemini CLI by adding debug logging when skipping invalid streaming response chunks or events without a response body. It refactors the SSE chunk processing logic in CodeAssistServer to ensure proper handling of final data chunks and adds corresponding unit tests to verify these improvements across the core components.
|
Please fix test |
|
@cocosheng-g I have fixed CI tests, pleaes have a look now |
Summary
Improves robustness and diagnostics in the streaming pipeline by making malformed or incomplete streamed responses easier to detect and debug.
Details
This change makes three focused improvements in the core streaming path:
packages/core/src/core/turn.ts, stream events with no response body are no longer skipped silently. They now emit a warning and continue processing later chunks.packages/core/src/core/geminiChat.ts, invalid streaming response chunks are explicitly warned about before being skipped, making stream degradation easier to diagnose.packages/core/src/code_assist/server.ts, the SSE parser now flushes the final buffereddata:chunk even when the stream ends without a trailing blank line.This keeps behavior unchanged for healthy streams while improving debuggability and correctness for malformed / incomplete streaming scenarios.
Related Issues
Fixes #22351
How to Validate
Run the focused test suites:
npm test -w @google/gemini-cli-core -- src/core/turn.test.ts src/core/geminiChat.test.ts src/code_assist/server.test.tsConfirm the tests pass, including coverage for:
warning and skipping stream events without a response body
warning when invalid stream chunks are skipped before a valid completion
parsing a final SSE data chunk without a trailing blank line
Pre-Merge Checklist
Local Tests