-
Notifications
You must be signed in to change notification settings - Fork 9.8k
fix: prevent infinite loop in prompt completion on error #14548
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Summary of ChangesHello @galz10, 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 resolves a significant bug in the CLI's background prompt completion mechanism. Previously, API errors would cause the system to enter an endless retry loop, leading to excessive resource consumption and API calls. The implemented solution prevents this by ensuring that the system no longer automatically retries completion requests after an error unless the user explicitly changes their input, thereby improving the stability and efficiency of the CLI. 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 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request correctly addresses a critical infinite loop bug in the prompt completion feature. The issue occurred when an API error would cause the component to continuously retry the request. The fix is simple and effective: by not clearing lastRequestedTextRef on an error, the hook now correctly remembers the last attempted text and avoids retrying until the user modifies the input. The change is well-explained in the pull request description and effectively resolves the reported issue.
|
Size Change: -45 B (0%) Total Size: 21.5 MB ℹ️ View Unchanged
|
Summary
Fixes a critical bug where the background prompt completion feature would enter an infinite retry loop when encountering an API error (such as "Quota Exceeded").
Details
The issue was caused by the
usePromptCompletionhook clearing its internal state (lastRequestedTextRef) whenever an API request failed. This was intended to allow retries, but instead caused the component to treat the existing user input as "new" during the next render cycle, triggering an immediate retry. This cycle would repeat indefinitely as long as the error persisted.The fix removes the logic that clears
lastRequestedTextRefon error. Now, the CLI remembers that it has already attempted completion for the current text, preventing automatic retries until the user actually modifies the input.Related Issues
Fixes #14477
How to Validate
enablePromptCompletion: true).Create a func).Pre-Merge Checklist