Skip to content

Cap Thinking Budget to prevent runaway thought loops#12416

Merged
abhipatel12 merged 2 commits into
mainfrom
abhipatel12/thinking-cap
Nov 3, 2025
Merged

Cap Thinking Budget to prevent runaway thought loops#12416
abhipatel12 merged 2 commits into
mainfrom
abhipatel12/thinking-cap

Conversation

@abhipatel12

Copy link
Copy Markdown
Contributor

Summary

Caps the thinking budget to prevent run-away thought loops.

Related Issues

Fixes # 976

Pre-Merge Checklist

  • Updated relevant documentation and README (if needed)
  • Added/updated tests (if needed)
  • Noted breaking changes (if any)
  • Validated on required platforms/methods:
    • MacOS
      • npm run
      • npx
      • Docker
      • Podman
      • Seatbelt

@abhipatel12 abhipatel12 requested a review from a team as a code owner October 31, 2025 22:33
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @abhipatel12, 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 introduces a crucial change to prevent potential runaway thought loops within the Codebase Investigator agent. It achieves this by setting a default maximum 'thinking budget' to 8192. This ensures that the agent operates within defined computational boundaries, leading to more stable and predictable performance, and mitigating scenarios where it might otherwise consume excessive resources or get stuck in infinite processing.

Highlights

  • Thinking Budget Default: The default value for the 'Thinking Budget' setting in the CLI configuration has been updated from -1 to 8192.
  • Core Thinking Mode Constant: The DEFAULT_THINKING_MODE constant in the core models has been changed from -1 to 8192, explicitly capping the thinking budget.
  • Preventing Runaway Loops: These changes collectively aim to prevent runaway thought loops in the Codebase Investigator agent by establishing a clear upper limit for its thinking budget.
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 aims to cap the thinking budget for the CodebaseInvestigatorAgent to prevent runaway thought loops by changing the default value from -1 (unlimited) to 8192. While the changes in the settings schema and the new constant are correct, the agent's definition itself still uses a hardcoded value of -1 for its thinking budget. This makes the change ineffective. My review includes a critical comment pointing this out with a suggestion on how to fix it.

Comment thread packages/core/src/config/models.ts
@github-actions

github-actions Bot commented Oct 31, 2025

Copy link
Copy Markdown

Size Change: +2 B (0%)

Total Size: 20.3 MB

ℹ️ View Unchanged
Filename Size Change
./bundle/gemini.js 20.3 MB +2 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

@abhipatel12 abhipatel12 requested a review from anj-s October 31, 2025 22:53
@abhipatel12 abhipatel12 added this pull request to the merge queue Nov 3, 2025
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Nov 3, 2025
@abhipatel12 abhipatel12 enabled auto-merge November 3, 2025 18:19
@abhipatel12 abhipatel12 force-pushed the abhipatel12/thinking-cap branch from 53d08b8 to aee7db5 Compare November 3, 2025 18:29
@abhipatel12 abhipatel12 added this pull request to the merge queue Nov 3, 2025
Merged via the queue into main with commit 59e0b10 Nov 3, 2025
22 checks passed
@abhipatel12 abhipatel12 deleted the abhipatel12/thinking-cap branch November 3, 2025 18:40
@abhipatel12

Copy link
Copy Markdown
Contributor Author

/patch preview

@github-actions

github-actions Bot commented Nov 3, 2025

Copy link
Copy Markdown

Patch workflow(s) dispatched successfully!

📋 Details:

  • Channels: preview
  • Commit: 59e0b10e6cf4d7cf3af652d95035be9ef9fb181a
  • Workflows Created: 1

🔗 Track Progress:

github-actions Bot pushed a commit that referenced this pull request Nov 3, 2025
# Conflicts:
#	docs/get-started/configuration.md
#	schemas/settings.schema.json
@github-actions

github-actions Bot commented Nov 3, 2025

Copy link
Copy Markdown

🚀 Patch PR Created!

📋 Patch Details:

📝 Next Steps:

  1. ⚠️ Resolve conflicts in the hotfix PR first: #12492
  2. Test your changes after resolving conflicts
  3. Once merged, the patch release will automatically trigger
  4. You'll receive updates here when the release completes

🔗 Track Progress:

thacio added a commit to thacio/auditaria that referenced this pull request Nov 4, 2025
danpalmer pushed a commit to danpalmer/gemini-cli that referenced this pull request Nov 29, 2025
@sripasg sripasg added the size/s A small PR label Jun 2, 2026
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.

3 participants