Skip to content

fix(core): expand excludeTools with legacy aliases for renamed tools#18498

Merged
SandyTao520 merged 1 commit intomainfrom
st/fix/excludetools-alias-support
Feb 7, 2026
Merged

fix(core): expand excludeTools with legacy aliases for renamed tools#18498
SandyTao520 merged 1 commit intomainfrom
st/fix/excludetools-alias-support

Conversation

@SandyTao520
Copy link
Copy Markdown
Contributor

Summary

excludeTools did not respect legacy tool aliases, so excluding a tool by its old name (e.g. search_file_content) failed to exclude the renamed tool (grep_search).

Details

The alias system from #17974 was integrated into getTool() and the policy engine, but not into the excludeTools filtering in ToolRegistry. Added expandExcludeToolsWithAliases() that expands each entry in the exclude set via getToolAliases(), applied in both getActiveTools() and the isActiveTool() fallback path.

Related Issues

Follows up on #17974 and #18003.

How to Validate

  1. Add {"tools": {"exclude": ["search_file_content"]}} to .gemini/settings.json
  2. Start gemini — the grep_search tool should be excluded
  3. Run existing tests: npx vitest run packages/core/src/tools/tool-registry.test.ts

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
    • Windows
      • npm run
      • npx
      • Docker
    • Linux
      • npm run
      • npx
      • Docker

@SandyTao520 SandyTao520 requested a review from a team as a code owner February 7, 2026 00:40
@gemini-cli
Copy link
Copy Markdown
Contributor

gemini-cli bot commented Feb 7, 2026

Hi @SandyTao520, thank you so much for your contribution to Gemini CLI! We really appreciate the time and effort you've put into this.

We're making some updates to our contribution process to improve how we track and review changes. Please take a moment to review our recent discussion post: Improving Our Contribution Process & Introducing New Guidelines.

Key Update: Starting January 26, 2026, the Gemini CLI project will require all pull requests to be associated with an existing issue. Any pull requests not linked to an issue by that date will be automatically closed.

Thank you for your understanding and for being a part of our community!

@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 addresses a critical bug where the tool exclusion mechanism did not recognize legacy aliases, leading to unexpected tool availability. The core change involves enhancing the ToolRegistry to intelligently expand any provided exclusion list with all known aliases for each tool, thereby ensuring that tools are consistently excluded regardless of whether their current or legacy names are used in the configuration. This improves the robustness and predictability of tool management.

Highlights

  • Fix for Tool Exclusion with Legacy Aliases: Resolved an issue where excludeTools failed to properly exclude tools when their legacy aliases were provided, ensuring that tools like grep_search are correctly excluded even if search_file_content is specified.
  • Introduction of expandExcludeToolsWithAliases: A new private method, expandExcludeToolsWithAliases, has been added to ToolRegistry. This function takes a set of tool names to exclude and expands it to include all associated legacy aliases, ensuring comprehensive exclusion.
  • Integration into Tool Exclusion Logic: The getActiveTools() and isActiveTool() methods in ToolRegistry now utilize expandExcludeToolsWithAliases to process the excludeTools configuration, guaranteeing that both current and legacy names are considered during tool exclusion.
  • Enhanced Test Coverage: New test cases have been added to tool-registry.test.ts to specifically validate that tools are correctly excluded when their legacy aliases are present in the excludeTools list, along with tests for exclusion by current names.
  • Updated Mocking for tool-names.js: The test suite's mock for tool-names.js has been updated to include a functional getToolAliases method, which is crucial for accurately testing the new alias expansion logic.
Changelog
  • packages/core/src/tools/tool-registry.test.ts
    • Updated the mock for tool-names.js to include a comprehensive getToolAliases function, allowing for accurate alias resolution in tests.
    • Added new test cases to verify that tools are correctly excluded when their legacy aliases are specified in the excludeTools configuration.
    • Included a test case to confirm that tools are excluded when their current names are listed in excludeTools.
  • packages/core/src/tools/tool-registry.ts
    • Imported getToolAliases from tool-names.js to facilitate alias resolution within the ToolRegistry.
    • Implemented a new private method, expandExcludeToolsWithAliases, which processes a set of tool names and returns an expanded set including all associated aliases.
    • Modified getActiveTools() to use expandExcludeToolsWithAliases when retrieving the list of excluded tools from the configuration.
    • Updated isActiveTool() to also apply expandExcludeToolsWithAliases to the excludeTools set, ensuring consistent alias-aware exclusion checks.
Activity
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.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a 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 fixes an issue where legacy tool aliases were not respected by excludeTools. The changes in ToolRegistry to expand the exclusion list with aliases are logical. I've added one high-severity comment regarding a performance concern due to repeated computations, with a suggestion to implement caching using the existing LruCache dependency to avoid potential latency during tool execution.

@github-actions
Copy link
Copy Markdown

github-actions bot commented Feb 7, 2026

Size Change: +691 B (0%)

Total Size: 23.8 MB

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

@SandyTao520 SandyTao520 enabled auto-merge February 7, 2026 00:46
@SandyTao520 SandyTao520 added this pull request to the merge queue Feb 7, 2026
Merged via the queue into main with commit 19dc408 Feb 7, 2026
28 checks passed
@SandyTao520 SandyTao520 deleted the st/fix/excludetools-alias-support branch February 7, 2026 01:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants