Fix #366: Add "Tool names must be unique" error rule#367
Conversation
Add new default error rule to match the Claude Code error when MCP servers have duplicate tool names. This is a non-retryable validation error that should not trigger provider failover. Pattern: "Tool names must be unique" Category: validation_error Priority: 89 (same as other tool validation errors) Closes #366 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Summary of ChangesHello @ding113, 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 specific issue where duplicate tool names from MCP servers lead to a 'Tool names must be unique' validation error in Claude Code. The primary goal is to enhance error handling by adding a new default error rule. This rule ensures that such client-side configuration problems are correctly identified and communicated with a clear, localized message, thereby preventing the system from attempting futile retries or initiating provider failovers. 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 new error rule to handle the "Tool names must be unique" validation error from the Claude API. This is a valuable addition that prevents unnecessary retries on a non-retryable client-side error. The implementation is clean and consistent with the existing error rule definitions. I have one suggestion to make the pattern matching slightly more specific to enhance its robustness.
| }, | ||
| // Issue #366: Tool names must be unique (MCP server configuration error) | ||
| { | ||
| pattern: "Tool names must be unique", |
There was a problem hiding this comment.
To improve the specificity of the match and reduce the risk of false positives with other potential error messages, consider making the pattern more precise. The error message in the PR description is tools: Tool names must be unique.. Including the tools: prefix in the pattern will create a more targeted match.
| pattern: "Tool names must be unique", | |
| pattern: "tools: Tool names must be unique", |
🧪 测试结果
总体结果: ✅ 所有测试通过 |
There was a problem hiding this comment.
Code Review Summary
No significant issues identified in this PR. The change adds a new error rule for "Tool names must be unique" validation error, following established patterns in the codebase.
PR Size: XS
- Lines changed: 18 additions, 0 deletions
- Files changed: 1
Review Analysis
The new error rule:
- ✅ Uses appropriate
matchType: "contains"for static string matching - ✅ Priority 89 is consistent with other tool validation errors
- ✅
overrideResponsestructure correctly follows theClaudeErrorResponseinterface - ✅ Comment accurately references the upstream issue (#366)
- ✅ Category
validation_erroris appropriate for this type of client error - ✅ Will be correctly inserted via
syncDefaultErrorRules()for new deployments
Review Coverage
- Logic and correctness - Clean
- Security (OWASP Top 10) - Clean
- Error handling - Clean
- Type safety - Clean
- Documentation accuracy - Clean
- Test coverage - Adequate (covered by existing integration tests)
- Code clarity - Good
Automated review by Claude AI
There was a problem hiding this comment.
Code Review Summary
No significant issues identified in this PR. The change adds a new error rule for "Tool names must be unique" validation error, following established patterns in the codebase.
PR Size: XS
- Lines changed: 18 additions, 0 deletions
- Files changed: 1
Review Analysis
The new error rule:
- ✅ Uses appropriate
matchType: "contains"for static string matching - ✅ Priority 89 is consistent with other tool validation errors
- ✅
overrideResponsestructure correctly follows theClaudeErrorResponseinterface - ✅ Comment accurately references the upstream issue (#366)
- ✅ Category
validation_erroris appropriate for this type of client error - ✅ Will be correctly inserted via
syncDefaultErrorRules()for new deployments
Review Coverage
- Logic and correctness - Clean
- Security (OWASP Top 10) - Clean
- Error handling - Clean
- Type safety - Clean
- Documentation accuracy - Clean
- Test coverage - Adequate (covered by existing integration tests)
- Code clarity - Good
Automated review by Claude AI
Summary
Problem
Fixes #366
When Claude Code encounters duplicate tool names from MCP servers, it returns:
{"type":"error","error":{"type":"invalid_request_error", "message":"tools: Tool names must be unique."}, "request_id":"req_011CW9cz13pCHJv2SC8NPCaq"}This is a validation error that should not trigger retry or provider switching.
Related Issues:
Solution
Added a new entry to
DEFAULT_ERROR_RULESinsrc/repository/error-rules.ts:Tool names must be uniquecontainsvalidation_errorChanges
Core Changes
src/repository/error-rules.ts: Added new error rule for tool name uniqueness validation (+18 lines)Testing
syncDefaultErrorRules()or restart withAUTO_MIGRATE=trueto syncChecklist
Description enhanced by Claude AI