feat(core): implement tool name aliasing for backward compatibility#17974
feat(core): implement tool name aliasing for backward compatibility#17974SandyTao520 merged 7 commits intomainfrom
Conversation
|
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! |
|
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 How to link an issue: Thank you for your understanding and for being a part of our community! |
Summary of ChangesHello @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
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. 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
|
There was a problem hiding this comment.
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.
|
Size Change: +1.2 kB (+0.01%) Total Size: 23.6 MB
ℹ️ View Unchanged
|
|
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! |
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:
.tomlfiles often reference specific tool names. A rename would invalidate these rules, causing the system to fall back toASK_USERorDENY.This implementation addresses these by:
TOOL_LEGACY_ALIASESmapping intool-names.ts.ToolRegistryto resolve tools via aliases if the primary name isn't found.PolicyEngineto check rules for both the current name and any known legacy aliases. This ensures that a policy forsearch_file_contentstill applies even if the tool is now calledgrep.isValidToolNameto 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.tsand checking if a policy for that alias is correctly applied.'my_old_read': READ_FILE_TOOL_NAME.[[rule]] toolName = "my_old_read", decision = "deny", priority = 100.read_file. It should be denied.Testing Matrix
Linked issues / bugs
#17263