fix(core,cli): propagate InvalidStreamError details to UI for specific empty response guidance - #28566
Conversation
…c empty response guidance
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 enhances the error handling and user feedback loop for the Gemini CLI. By propagating detailed error information from the core backend to the UI, the application can now provide actionable guidance to users when encountering specific stream issues, such as empty responses. Additionally, the change improves system robustness by enabling automatic retries for previously non-retryable empty response errors. Highlights
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 the 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 counterproductive. 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. Footnotes
|
|
📊 PR Size: size/XL
|
There was a problem hiding this comment.
Code Review
This pull request improves the handling of invalid stream events by adding detailed error type and message information to ServerGeminiInvalidStreamEvent. It implements a handleInvalidStreamEvent callback in the CLI to display user-friendly error messages and updates the backend to retry requests on empty response text (NO_RESPONSE_TEXT) errors. The review feedback suggests defensively accessing eventValue properties using optional chaining and trimming the message to prevent potential runtime crashes and handle whitespace-only strings.
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
|
Size Change: +14 kB (+0.04%) Total Size: 35.2 MB
ℹ️ View Unchanged
|
…id-stream-details-28351' into fix/propagate-invalid-stream-details-28351
|
Hey I'm the person who raised #28351. Thanks for raising a PR for it. But I'll reiterate a few important things:
As such I believe that this PR is not ready to land. |
|
Thanks for your comment and analysis! |
…id-stream-details-28351' into fix/propagate-invalid-stream-details-28351
…cate empty response messages Aligns the agentic non-interactive execution mode (nonInteractiveCliAgentSession.ts) with the standard non-interactive loop (nonInteractiveCli.ts) by introducing emitFinalResult(errorPayload) to properly output the 'INVALID_STREAM' error details and 'error' status in JSON/STREAM_JSON format outputs. Also deduplicates the user empty-text response warning string into a shared constant EMPTY_RESPONSE_COMPRESS_SUGGESTION defined in @google/gemini-cli-core.
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request improves the handling of InvalidStream events across both interactive and non-interactive CLI modes. It ensures that empty text responses suggest using /compress and that API errors are properly logged for telemetry. Additionally, it enables retries on NO_RESPONSE_TEXT stream errors and tracks distinct error types in telemetry metrics. The feedback recommends reusing the EMPTY_RESPONSE_COMPRESS_SUGGESTION constant in useGeminiStream.ts to avoid duplicate strings and maintain consistency.
Note: Security Review did not run due to the size of the PR.
SandyTao520
left a comment
There was a problem hiding this comment.
Two remaining P1 findings from the latest verification round.
SandyTao520
left a comment
There was a problem hiding this comment.
Verified the addressed review findings and latest CI. Looks good.
|
/patch |
|
🚀 [Step 1/4] Patch workflow(s) waiting for approval! 📋 Details:
⏳ Status: The patch creation workflow has been triggered and is waiting for deployment approval. Please visit the specific workflow links below and approve the runs. 🔗 Track Progress: |
|
🚀 [Step 2/4] Patch PR Created! 📋 Patch Details:
📝 Next Steps:
🔗 Track Progress: |
|
🚀 [Step 2/4] Patch PR Created! 📋 Patch Details:
📝 Next Steps:
🔗 Track Progress: |
|
🚀 [Step 3/4] Patch Release Waiting for Approval! 📋 Release Details:
⏳ Status: The patch release has been triggered and is waiting for deployment approval. Please visit the specific workflow run link below and approve the deployment. You'll receive another update when it completes. 🔗 Track Progress: |
|
🚀 [Step 3/4] Patch Release Waiting for Approval! 📋 Release Details:
⏳ Status: The patch release has been triggered and is waiting for deployment approval. Please visit the specific workflow run link below and approve the deployment. You'll receive another update when it completes. 🔗 Track Progress: |
|
✅ [Step 4/4] Patch Release Complete! 📦 Release Details:
🎉 Status: Your patch has been successfully released and published to npm! 📝 What's Available:
🔗 Links: |
|
✅ [Step 4/4] Patch Release Complete! 📦 Release Details:
🎉 Status: Your patch has been successfully released and published to npm! 📝 What's Available:
🔗 Links: |
|
The changes have addressed all my comments. Thanks for fixing this 👍 |
|
|
Summary
This PR propagates specific
InvalidStreamErrordetails (the errortypeandmessage) from the core backend layers up to the CLI UI hooks. This allows the CLI to display highly relevant and helpful troubleshooting suggestions—such as recommending the use of/compressto reduce context size when the model returns an empty text response.Details
Turn/geminiChat): Updated theServerGeminiInvalidStreamEventtype and theTurnrun logic to pass the specific errortypeandmessagevalues in the event'svaluepayload, instead of dropping this detail.useGeminiStream): ImplementedhandleInvalidStreamEventto check ifeventValue.typeis'NO_RESPONSE_TEXT', in which case we display a custom, friendly message recommending the use of/compress. Otherwise, we fall back to displaying the event's raw error message.packages/cli/src/nonInteractiveCli.test.tsmock events to include the newvaluemetadata.packages/core/src/agent/event-translator.test.tsto mock the correct payload structure.packages/core/src/core/turn.test.tsto expect the populatedvaluepayload onInvalidStreamevents.packages/core/src/core/geminiChat.test.tsto correctly mock/stub and run the mid-conversation stream retry flow when empty text responses are received.Related Issues
Addresses #28351 .
How to Validate
Run unit tests in the core and CLI packages to verify the new behavior:
Pre-Merge Checklist