copilot-cli icon indicating copy to clipboard operation
copilot-cli copied to clipboard

Model call failed: {"message":"tools: Tool names must be unique.","code":"invalid_request_body"}

Open doggy8088 opened this issue 2 months ago • 3 comments

Describe the bug

Start from today. The error keeps appearing.

 Welcome to GitHub Copilot CLI
 Version 0.0.353 · Commit f8fd3e3

 Copilot can write, test and debug code right from your terminal. Describe a task to get started or enter ? for help. Copilot uses
  AI, check for mistakes.

 ● Logged in with gh as user: doggy8088

 ● Configured MCP servers: Context7, chrome-devtools

 ● Connected to GitHub MCP Server

 > hi

 ✗ Model call failed: {"message":"tools: Tool names must be unique.","code":"invalid_request_body"} (Request ID:
   EBA2:1C5BEE:2291FC:27985E:6908E7A8)

 ✗ Model call failed: {"message":"tools: Tool names must be unique.","code":"invalid_request_body"} (Request ID:
   EBA2:1C5BEE:22AD20:27B7E0:6908E7A9)
Image

Affected version

0.0.353 Commit: f8fd3e3

Steps to reproduce the behavior

  1. Run copilot --allow-all-tools --allow-all-path
  2. Type hi

Expected behavior

I expected to run without error.

Additional context

I tried to remove ~/.copilot/mcp-config.json file. The error still happen.

I suspect the problem is caused by the GitHub MCP Server. But, even I disabled GitHub MCP Server. The error still exist.

Image

Logs:

2025-11-03T17:46:39.155Z [ERROR] {
  "stack": "CAPIError: 400 tools: Tool names must be unique.\n    at t.fromAPIError (file:///home/will/.nvm/versions/node/v22.16.0/lib/node_modules/@github/copilot/index.js:1905:898)\n    at J1e.getCompletionWithTools (file:///home/will/.nvm/versions/node/v22.16.0/lib/node_modules/@github/copilot/index.js:1905:5284)\n    at process.processTicksAndRejections (node:internal/process/task_queues:105:5)\n    at async Ude.getCompletionWithTools (file:///home/will/.nvm/versions/node/v22.16.0/lib/node_modules/@github/copilot/index.js:1906:1431)\n    at async Bil (file:///home/will/.nvm/versions/node/v22.16.0/lib/node_modules/@github/copilot/index.js:2456:573)\n    at async t.getCompletionWithTools (file:///home/will/.nvm/versions/node/v22.16.0/lib/node_modules/@github/copilot/index.js:2460:58389)\n    at async z7n (file:///home/will/.nvm/versions/node/v22.16.0/lib/node_modules/@github/copilot/index.js:2486:19713)\n    at async epl (file:///home/will/.nvm/versions/node/v22.16.0/lib/node_modules/@github/copilot/index.js:2486:16987)",
  "message": "400 tools: Tool names must be unique.",
  "status": 400,
  "headers": {},
  "requestID": "00000-b3d6972e-aa67-4600-9393-c0ded6b0bc62",
  "error": {
    "message": "tools: Tool names must be unique.",
    "code": "invalid_request_body"
  },
  "code": "invalid_request_body",
  "request_id": "00000-b3d6972e-aa67-4600-9393-c0ded6b0bc62",
  "ghRequestId": "EBB2:CA1DD:28404A:2E68C1:6908EA7D",
  "name": "CAPIError"
}

After removing the .github/agents/ folder, everything is working correctly now. I believe the error message could be improved.

doggy8088 avatar Nov 03 '25 17:11 doggy8088

I have a .github/agents/通靈模式.agent.md file in my working tree. The content of the file below:

---
name: 通靈模式
description: '協助開發者瞭解整個專案的現況與專案架構。'
tools: ['changes', 'codebase', 'fetch', 'search', 'searchResults', 'usages']
---
You are a helpful assistant providing insights on the current status and architecture of the project.

Answer only in zh-tw

I tried to remove this file or rename this file are all able to run Copilot CLI correctly. I don't know what's the issue of this file. Why this custom agent cause entire Copilot CLI failed?

By thy way, I also have another agent files. The others are all okay!

❯ tree -a .github/agents/
.github/agents/
├── CSharpExpert.agent.md
├── SQL 大師模式 (Read-Only).agent.md
├── SQL 大師模式.agent.md
├── 架構模式.agent.md
└── 通靈模式.agent.md

I don't know why this is happening.

doggy8088 avatar Nov 03 '25 18:11 doggy8088

I don't know why this is happening.

I suspect the issue here is that we recently added some code that normalizes the ids (which is based on the name property) of custom agents so that characters outside of the range [A-Za-z0-9_-] are replaced with just an -. This obviously does not work great in the case of the names you have here, since both the 架構模式.agent.md and 通靈模式.agent.md custom agents are likely to both end up being named something like ---- after this normalization process. That appears to be what is happening here.

We will go make changes to the normalization process, but in the mean time to work around this issue, you could consider adding a few ASCII letters to the end of these two tool names which differ between the two. That should make it so we don't generate identitcal tool names after noramlization in this case.

I'm guessing that the problem is 架構模式.agent.md's name is likely 架構模式 and that it's conflicting with 通靈模式.agent.md's name after normalization.

ellismg avatar Nov 03 '25 23:11 ellismg

I'm guessing that the problem is 架構模式.agent.md's name is likely 架構模式 and that it's conflicting with 通靈模式.agent.md's name after normalization.

I think what you said makes a lot of sense, it is very likely caused by that, thanks for the clarification!

doggy8088 avatar Nov 04 '25 03:11 doggy8088

As an FYI @doggy8088, I made some changes to our normalization strategy that should address this issue (I validated that I was able to reproduce your issue with two custom agents with different names in unicode but the same number of characters). They will be in 0.0.355, which hasn't been released yet (hopefully soon!), but you can see the changes in the pre-release version via npm install -g @github/copilot@prerelease.

ellismg avatar Nov 06 '25 17:11 ellismg