Skip to content

[Bug] MCP tools in multiple instances of one custom agent will conflict #687

@showpune

Description

@showpune

Describe the bug

If I start multiple custom agent instance for one custom agent with MCP server configured, the tools will be conflict

Affected version

0.0.365

Steps to reproduce the behavior

  1. Configure the the custom agent with below MCP tools configured
---
name: my-custom-agent-with-mcp
description: Custom agent description
tools: ['tool-a', 'tool-b', 'custom-mcp/tool-1']
mcp-servers:
  custom-mcp:
    type: 'local'
    command: 'some-command'
    args: ['--arg1', '--arg2']
    tools: ["*"]
    env:
      ENV_VAR_NAME: $
---

Prompt with suggestions for behavior and output
  1. Start the custom agent for multiple time with prompt

  2. The custom agent call be failed and you will get the error as below

2025-12-01T00:29:01.738Z [ERROR] {
  "status": 400,
  "headers": {},
  "requestID": "00000-7986efe2-4585-42cf-9214-b6da0a69d8fe",
  "error": {
    "message": "tools: Tool names must be unique.",
    "code": "invalid_request_body"
  },
  "code": "invalid_request_body",
  "request_id": "00000-7986efe2-4585-42cf-9214-b6da0a69d8fe",
  "ghRequestId": "1840:3022F0:28C1CEB:3B0F686:692CE14B",
  "name": "CAPIError",
  "message": "400 tools: Tool names must be unique.",
  "stack": "CAPIError: 400 tools: Tool names must be unique.\n    at t.fromAPIError (file:///opt/nvm/versions/node/v22.15.1/lib/node_modules/@github/copilot/index.js:1188:945)\n    at UXe.getCompletionWithTools (file:///opt/nvm/versions/node/v22.15.1/lib/node_modules/@github/copilot/index.js:1188:8567)\n    at process.processTicksAndRejections (node:internal/process/task_queues:105:5)\n    at async Ehe.getCompletionWithTools (file:///opt/nvm/versions/node/v22.15.1/lib/node_modules/@github/copilot/index.js:1193:1807)\n    at async Qhe.runCompletionWithTools (file:///opt/nvm/versions/node/v22.15.1/lib/node_modules/@github/copilot/index.js:1194:15376)\n    at async d (file:///opt/nvm/versions/node/v22.15.1/lib/node_modules/@github/copilot/index.js:1194:14479)\n    at async Qhe.agent (file:///opt/nvm/versions/node/v22.15.1/lib/node_modules/@github/copilot/index.js:1194:14692)\n    at async o (file:///opt/nvm/versions/node/v22.15.1/lib/node_modules/@github/copilot/index.js:1194:13106)\n    at async UXe.callTool (file:///opt/nvm/versions/node/v22.15.1/lib/node_modules/@github/copilot/index.js:1188:15306)\n    at async UXe.callTools (file:///opt/nvm/versions/node/v22.15.1/lib/node_modules/@github/copilot/index.js:1188:14629)"
}

Check the log and you will find the custom-mcp/tool-1 is sent twice in log 'Custom agent tools after filtering'

Expected behavior

For the second time to start the custom agent, the MCP should not be added again, or the duplicate tools should be removed

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions