fix(core): prevent infinite loops with hard cap on consecutive same-name tool calls#25764
fix(core): prevent infinite loops with hard cap on consecutive same-name tool calls#25764noxymon wants to merge 7 commits intogoogle-gemini:mainfrom
Conversation
…oops (google-gemini#25671) - Added CONSECUTIVE_SAME_TOOL_NAME_THRESHOLD (50) and THINKING_TOOL_LOOP_THRESHOLD (15) to LoopDetectionService. - Enhanced loop detection to track consecutive calls to the same tool name even if arguments differ. - Updated LoopDetected event to carry specific loop details. - Improved UI alerting to display detailed information about the detected loop.
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
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 system's ability to detect and prevent infinite loops during tool calls by introducing new thresholds and tracking mechanisms. It specifically addresses cases where tool arguments might change, which previously bypassed simpler loop detection. The changes also improve the user experience by providing more detailed information when a loop is identified, allowing for better debugging and understanding of model behavior. 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. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request enhances loop detection by tracking consecutive calls to the same tool name even when arguments differ, which is particularly useful for identifying loops in 'thinking' tools. It updates the UI to display specific loop details and adds corresponding unit tests. Feedback suggests introducing a distinct telemetry event type for same-name tool calls to distinguish them from truly identical repetitions, ensuring more accurate data analysis.
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Summary
This PR implements a hard cap for consecutive calls to the same tool name to prevent infinite loops, especially in "thinking" tools where arguments (like thought numbers) change each time. It also enhances the loop detection event to carry more details to the UI.
Details
Related Issues
Fixes #25671
How to Validate
pm test -w @google/gemini-cli-core -- loopDetectionService.test.ts to verify the logic.
Pre-Merge Checklist