fix(core): ensure subagents use qualified MCP tool names#20801
fix(core): ensure subagents use qualified MCP tool names#20801abhipatel12 merged 2 commits intomainfrom
Conversation
…nitialization crashes
Summary of ChangesHello, 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 that caused subagents to crash when attempting to use Model Context Protocol (MCP) tools. The core issue stemmed from an inconsistency in how MCP tool names were handled: the Highlights
Changelog
Activity
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 resolves a critical crash that occurred in subagents when using Model Context Protocol (MCP) tools. The root cause was a name mismatch, where the ToolRegistry provided short aliases for MCP tools while the LocalAgentExecutor expected fully qualified names. The fix is comprehensive: LocalAgentExecutor now automatically upgrades short names to their qualified form, and ToolRegistry has been updated to consistently return fully qualified names and deduplicate tool entries. These changes make the system more robust and align with the principle of least surprise. The implementation is clean, and the accompanying unit tests are thorough, correctly validating the new qualification and resolution logic. This is an excellent fix that improves both stability and developer experience.
|
Size Change: +852 B (0%) Total Size: 25.8 MB ℹ️ View Unchanged
|
Summary
This PR resolves a critical initialization crash in the
generalistsubagent and other dynamically configured agents when Model Context Protocol (MCP) tools are active.Details
The issue was caused by a mismatch between the
ToolRegistryand theLocalAgentExecutor:ToolRegistryoften exposes MCP tools using "short" aliases (e.g.,get_logs) for user convenience.LocalAgentExecutorenforces a strict requirement for fully qualified names (e.g.,Server__get_logs) in subagents to ensure safety and prevent tool name collisions.When the
generalistagent attempted to gather all available tools, it received short aliases from the registry, which then triggered a validation error in the executor.Changes:
ToolRegistry.getAllToolNames()andgetFunctionDeclarations()to consistently use fully qualified names for MCP tools.LocalAgentExecutorto automatically resolve and "upgrade" short MCP aliases to their qualified forms during subagent initialization.tool-registry.test.tsandlocal-executor.test.tsto verify the new qualification and resolution logic.Related Issues
Fixes the subagent crash reported during internal testing.
How to Validate
Can you try dispatching a generalist sub-agent to check my email?npm test -w @google/gemini-cli-core -- src/tools/tool-registry.test.ts src/agents/local-executor.test.tsPre-Merge Checklist