Skip to content

fix(core): ensure loop detection respects session disable flag#12347

Merged
SandyTao520 merged 1 commit into
mainfrom
st/fix/loop-detection-priority
Oct 31, 2025
Merged

fix(core): ensure loop detection respects session disable flag#12347
SandyTao520 merged 1 commit into
mainfrom
st/fix/loop-detection-priority

Conversation

@SandyTao520

Copy link
Copy Markdown
Contributor

TLDR

Fixes an issue where loop detection would continue to report true even after being disabled for the session, if a loop had already been detected.

Dive Deeper

The addAndCheck method in LoopDetectionService was checking this.loopDetected || this.disabledForSession and returning this.loopDetected if it was true, ignoring the disabledForSession flag. The fix reorders these checks to prioritize disabledForSession.

Reviewer Test Plan

Run the newly added test case in packages/core/src/services/loopDetectionService.test.ts which specifically reproduces this scenario.

Testing Matrix

🍏 🪟 🐧
npm run
npx
Docker
Podman - -
Seatbelt - -

Linked issues / bugs

N/A

@SandyTao520 SandyTao520 requested a review from a team as a code owner October 31, 2025 05:53
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @SandyTao520, 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 an issue within the core LoopDetectionService where the system would continue to indicate a loop even after being explicitly disabled for the current session. The fix reorders conditional checks to ensure that the disabledForSession flag takes precedence, thereby preventing erroneous loop reports and improving the accuracy of the service's state management.

Highlights

  • Loop Detection Logic Fix: Corrected the LoopDetectionService to properly respect the disabledForSession flag, ensuring that loop detection stops reporting true even if a loop was previously detected.
  • Prioritized Session Disable Check: The addAndCheck method in LoopDetectionService now checks disabledForSession before loopDetected, preventing incorrect loop reports after the service has been disabled.
  • New Test Case: Added a new test to loopDetectionService.test.ts that specifically validates the fix, ensuring that loop reporting ceases once the service is disabled for the session.
Using Gemini Code Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

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 addresses a logic flaw in the loop detection service where disabling loop detection for a session did not take effect if a loop had already been detected. The fix correctly reorders the checks to prioritize the disabledForSession flag, ensuring that loop detection can be successfully disabled at any point during a session. The change is accompanied by a new test case that specifically validates this corrected behavior. The implementation is sound and effectively resolves the issue.

@github-actions

Copy link
Copy Markdown

Size Change: +44 B (0%)

Total Size: 20.3 MB

ℹ️ View Unchanged
Filename Size Change
./bundle/gemini.js 20.3 MB +44 B (0%)
./bundle/sandbox-macos-permissive-closed.sb 1.03 kB 0 B
./bundle/sandbox-macos-permissive-open.sb 890 B 0 B
./bundle/sandbox-macos-permissive-proxied.sb 1.31 kB 0 B
./bundle/sandbox-macos-restrictive-closed.sb 3.29 kB 0 B
./bundle/sandbox-macos-restrictive-open.sb 3.36 kB 0 B
./bundle/sandbox-macos-restrictive-proxied.sb 3.56 kB 0 B

compressed-size-action

@jacob314 jacob314 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm
thanks for fixing! I've been hitting this issue a lot tonight.

@anowardear062-svg

Copy link
Copy Markdown

Thanks for the update

@SandyTao520 SandyTao520 added this pull request to the merge queue Oct 31, 2025
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Oct 31, 2025
@SandyTao520 SandyTao520 added this pull request to the merge queue Oct 31, 2025
Merged via the queue into main with commit 11e1e98 Oct 31, 2025
27 of 28 checks passed
@SandyTao520 SandyTao520 deleted the st/fix/loop-detection-priority branch October 31, 2025 16:15
@SandyTao520

Copy link
Copy Markdown
Contributor Author

/patch preview

@github-actions

Copy link
Copy Markdown

Patch workflow(s) dispatched successfully!

📋 Details:

  • Channels: preview
  • Commit: 11e1e98022a403dad84c15b0acb10301f53ac457
  • Workflows Created: 1

🔗 Track Progress:

@github-actions

Copy link
Copy Markdown

🚀 Patch PR Created!

📋 Patch Details:

📝 Next Steps:

  1. Review and approve the hotfix PR: #12383
  2. Once merged, the patch release will automatically trigger
  3. You'll receive updates here when the release completes

🔗 Track Progress:

@github-actions

Copy link
Copy Markdown

🚀 Patch Release Started!

📋 Release Details:

  • Environment: prod
  • Channel: preview → publishing to npm tag preview
  • Version: v0.12.0-preview.7
  • Hotfix PR: Merged ✅
  • Release Branch: release/v0.12.0-preview.7-pr-12347

⏳ Status: The patch release is now running. You'll receive another update when it completes.

🔗 Track Progress:

@github-actions

Copy link
Copy Markdown

Patch Release Complete!

📦 Release Details:

🎉 Status: Your patch has been successfully released and published to npm!

📝 What's Available:

🔗 Links:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/s A small PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants