Skip to content

feat(core): implement tool name aliasing for backward compatibility#17974

Merged
SandyTao520 merged 7 commits intomainfrom
st/feat/tool-name-aliasing
Feb 3, 2026
Merged

feat(core): implement tool name aliasing for backward compatibility#17974
SandyTao520 merged 7 commits intomainfrom
st/feat/tool-name-aliasing

Conversation

@SandyTao520
Copy link
Contributor

@SandyTao520 SandyTao520 commented Jan 30, 2026

TLDR

This PR introduces a tool name aliasing infrastructure to support backward compatibility when tools are renamed. It allows tools to be resolved by their legacy names and ensures that existing security policies and skills continue to function seamlessly.

Dive Deeper

When renaming tools, we face three main challenges:

  1. Security Policies: User-defined policies in .toml files often reference specific tool names. A rename would invalidate these rules, causing the system to fall back to ASK_USER or DENY.
  2. Skills/Prompts: Existing skills or custom prompts might explicitly instruct the model to use an old tool name.
  3. Persistence: "Always Allow" preferences are stored by tool name.

This implementation addresses these by:

  • Adding a TOOL_LEGACY_ALIASES mapping in tool-names.ts.
  • Updating ToolRegistry to resolve tools via aliases if the primary name isn't found.
  • Updating PolicyEngine to check rules for both the current name and any known legacy aliases. This ensures that a policy for search_file_content still applies even if the tool is now called grep.
  • Updating isValidToolName to prevent initialization errors when legacy names are encountered in configuration.

Reviewer Test Plan

Reviewers can verify the aliasing logic by adding a temporary alias in tool-names.ts and checking if a policy for that alias is correctly applied.

  1. Add an alias: 'my_old_read': READ_FILE_TOOL_NAME.
  2. Create a policy: [[rule]] toolName = "my_old_read", decision = "deny", priority = 100.
  3. Try to use read_file. It should be denied.

Testing Matrix

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

Linked issues / bugs

#17263

@SandyTao520 SandyTao520 requested a review from a team as a code owner January 30, 2026 18:50
@gemini-cli
Copy link
Contributor

gemini-cli bot commented Jan 30, 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-cli
Copy link
Contributor

gemini-cli bot commented Jan 30, 2026

Hi there! Thank you for your contribution to Gemini CLI.

To improve our contribution process and better track changes, we now require all pull requests to be associated with an existing issue, as announced in our recent discussion and as detailed in our CONTRIBUTING.md.

This pull request is being closed because it is not currently linked to an issue. Once you have updated the description of this PR to link an issue (e.g., by adding Fixes #123 or Related to #123), it will be automatically reopened.

How to link an issue:
Add a keyword followed by the issue number (e.g., Fixes #123) in the description of your pull request. For more details on supported keywords and how linking works, please refer to the GitHub Documentation on linking pull requests to issues.

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

@gemini-cli gemini-cli bot closed this Jan 30, 2026
@gemini-code-assist
Copy link
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 implements a robust tool name aliasing system to ensure backward compatibility for renamed tools. The primary goal is to prevent disruptions to existing security policies, user-defined skills, and persistent settings by allowing the system to recognize and correctly map legacy tool names to their current counterparts. This change significantly improves the maintainability and evolution of the tool ecosystem without breaking existing user configurations.

Highlights

  • Tool Name Aliasing Infrastructure: Introduced a new TOOL_LEGACY_ALIASES mapping in tool-names.ts to define backward-compatible names for tools that have been renamed.
  • Policy Engine Updates: The PolicyEngine has been enhanced to evaluate security rules against both the current tool name and any associated legacy aliases, ensuring policies remain effective after tool renames.
  • Tool Registry Resolution: The ToolRegistry now includes logic to resolve tools by their legacy names if the primary current name is not found, improving discoverability and compatibility.
  • Validation of Legacy Names: The isValidToolName function has been updated to correctly validate legacy tool aliases, preventing initialization errors when these names are encountered in configurations.
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
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 introduces a tool aliasing mechanism for backward compatibility. Two critical issues were identified in the PolicyEngine related to how tool aliases are handled for policy application. The first is a security flaw where shell-specific security checks are bypassed when a shell tool is invoked via an alias, as the tool.name is not fully resolved before checks. The second is a logic error in alias resolution that could prevent policies from being correctly applied when multiple legacy aliases exist for a single tool. Both comments align with the rule that tool security policies are applied based on tool.name, emphasizing the need for accurate and comprehensive tool.name resolution.

@SandyTao520 SandyTao520 reopened this Jan 30, 2026
@github-actions
Copy link

github-actions bot commented Jan 30, 2026

Size Change: +1.2 kB (+0.01%)

Total Size: 23.6 MB

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

compressed-size-action

@gemini-cli
Copy link
Contributor

gemini-cli bot commented Jan 31, 2026

Hi there! Thank you for your contribution to Gemini CLI. We really appreciate the time and effort you've put into this pull request.

To keep our backlog manageable and ensure we're focusing on current priorities, we are closing pull requests that haven't seen maintainer activity for 30 days. Currently, the team is prioritizing work associated with 🔒 maintainer only or help wanted issues.

If you believe this change is still critical, please feel free to comment with updated details. Otherwise, we encourage contributors to focus on open issues labeled as help wanted. Thank you for your understanding!

@gemini-cli gemini-cli bot closed this Jan 31, 2026
@SandyTao520 SandyTao520 reopened this Feb 1, 2026
@SandyTao520 SandyTao520 enabled auto-merge February 2, 2026 21:14
@SandyTao520 SandyTao520 added this pull request to the merge queue Feb 3, 2026
Merged via the queue into main with commit 5e96373 Feb 3, 2026
26 checks passed
@SandyTao520 SandyTao520 deleted the st/feat/tool-name-aliasing branch February 3, 2026 00:50
yuvrajangadsingh pushed a commit to yuvrajangadsingh/gemini-cli that referenced this pull request Feb 4, 2026
sidwan02 pushed a commit to sidwan02/gemini-cli-gemma that referenced this pull request Feb 6, 2026
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