Repository navigation
fix(core): keep the unsent request when loop recovery starts before a turn - #29871
codewithfourtix wants to merge 1 commit into
Conversation
… turn When the loop check in processTurn reports a loop before the request is sent, _recoverFromLoop sent only the loop feedback and dropped the request. That request is usually the functionResponse of a tool that already ran, so GeminiChat closed the call as "Response was lost or interrupted." and the model lost the record of what the tool did. Send the unsent request parts first and the loop feedback after them, in one user turn. The loop check during streaming is not changed, because there the request was already sent. Fixes google-gemini#29815
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 addresses an issue where pending requests, specifically tool responses, were being discarded during loop recovery. By passing the unsent request into the recovery process, the system now ensures that the model retains the context of tool executions, preventing incorrect 'lost or interrupted' status 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/M
|
There was a problem hiding this comment.
Code Review
This pull request ensures that unsent requests, such as tool responses, are not dropped when a loop is detected before the request is sent. It updates the 'GeminiClient' to accept and prepend 'unsentRequest' parts to the loop feedback message, and adds a corresponding unit test to verify this behavior. I have no feedback to provide as there are no review comments.
|
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 only guarantee review and consideration of pull requests for issues that are explicitly labeled as 'help wanted'. This PR will be closed in 7 days if it remains without that designation. We encourage you to find and contribute to existing 'help wanted' issues in our backlog! Thank you for your understanding. |
|
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. |
Summary
When the loop check at the start of a turn reports a loop,
_recoverFromLoopsends only the loop feedback and drops the pending request. That request is usually thefunctionResponseof a tool that already ran, so the call is closed as"Response was lost or interrupted."and the model loses the record of what the tool did.Details
processTurnnow passes the unsent request to_recoverFromLoop, which sends the request parts first and the feedback text after them, in one user turn.isFunctionResponsematches a turn with anyfunctionResponsepart, socloseUnansweredToolCallsTurnno longer replaces the real result.The loop check during streaming is not changed, because there the request was already sent. I did not postpone the check while a tool response is pending: late in a prompt a response is almost always pending, so the check would almost never run.
Related Issues
Fixes #29815
How to Validate
npm test -w @google/gemini-cli-core -- src/core/client.test.ts. The new testshould keep an unsent tool response when the loop is found before the request is sentfails onmain, because the recovery request contains only the feedback text.--fake-responsesscript in LLM loop recovery discards the result of a tool that already ran and tells the model it was "lost or interrupted" #29815:step-29.txtis answered with its realfunctionResponse, followed by the loop feedback.Pre-Merge Checklist