Bug: Task tool fails with "tools: Tool names must be unique" error

Status Closed — duplicate
Maintainer reply None cached
Activity 15 comments · opened Oct 31, 2025 · closed Oct 31, 2025

Environment

  • Claude Code Version: Latest (as of 2025-10-31)
  • OS: macOS 25.0.0 (Darwin)
  • Node: 22+
  • Project Type: Next.js 16 application with MCP servers

Description

The Task tool consistently fails to launch subprocess agents with a 400 API error: "tools: Tool names must be unique". This occurs for all subagent types, including general-purpose, and happens during agent initialization before any execution begins.

Steps to Reproduce

  1. Invoke Task tool with subagent_type="general-purpose"
  2. Provide any valid prompt (e.g., "Create test files for API routes")
  3. Observe API Error 400 response

Actual Behavior

{
  "type": "error",
  "error": {
    "type": "invalid_request_error",
    "message": "tools: Tool names must be unique."
  }
}

Error appears immediately during agent initialization, before any task execution.

Expected Behavior

Task agent should initialize successfully and execute the provided prompt autonomously.

Test Cases Attempted

  • ❌ 4 parallel agents (single message, multiple Task invocations) - all failed
  • ❌ 1 sequential agent - failed
  • ❌ Agent with explicit model: "sonnet" parameter - failed
  • ❌ Different subagent types - all failed

Request IDs

  • req_011CUezFfa6UVuTcb13YUK1f
  • req_011CUezFeoxPTtpm1Ui1wbj7
  • req_011CUezFeapTWu9numGWTFmM
  • req_011CUezFemyUWAUnTVHhmoGG
  • req_011CUezHAwDVuXkegeUVzKmC

Investigation Results

  • ✅ Verified no duplicate tools in parent environment (49 unique tools)
  • ✅ Error is consistent across all invocation patterns
  • ✅ Not specific to parallel execution (single agent also fails)
  • ✅ Not model-specific (tried default and sonnet)
  • ✅ Occurs at API validation level (400 error from Anthropic)

Root Cause Hypothesis

The Task tool's implementation likely has a bug where it double-adds tools when creating subprocess agents:

  1. Inherits all parent tools from the main session
  2. Re-adds them from the agent type definition
  3. Results in duplicate tool names passed to the Anthropic API
  4. API validation rejects the request

Impact

  • Severity: Medium
  • Workaround Available: Yes (direct implementation without agents)
  • Blocked Feature: Parallel autonomous agent execution for large-scale tasks
  • User Impact: Reduced efficiency - tasks that could be parallelized across 4+ agents must be done sequentially

Active MCP Servers

  • GitHub MCP (26 tools: create_issue, create_pull_request, etc.)
  • Microsoft Learn MCP (3 tools: docs_search, code_sample_search, docs_fetch)
  • IDE MCP (2 tools: getDiagnostics, executeCode)

Use Case That Failed

Attempted to launch 4 parallel agents to create test coverage for 94 API routes:

  • Agent 1: Entitlements routes (4 routes)
  • Agent 2: Patient cycle management (21 routes)
  • Agent 3: Clinic admin routes (33 routes)
  • Agent 4: Mobile app & AI routes (33 routes)

All agents failed immediately with the duplicate tools error.

Suggested Fix

Add validation in the Task tool implementation to:

  1. Deduplicate tools before passing to Anthropic API
  2. Provide clear error messages if duplicates are detected
  3. Consider tool namespacing for subagents to prevent conflicts

View original on GitHub ↗

15 Comments

csizo · 10 months ago

i am facing exactly the same issue.

AnsKM · 10 months ago

I'm also facing this exact same issue, and it's frustrating because now I need to process everything sequentially instead of launching agents in parallel. I hope this gets fixed soon...

jtippett · 10 months ago

Exactly the same issue here too, v2.0.30

03-CiprianoG · 10 months ago

Same issue here, v2.0.30

psychcook · 10 months ago

Same issue here, all MCP's are disabled but error still occurs, v2.0.30.

patrickpanknin · 10 months ago

Same here: all general-purpose agents or custom sub-agents do not work.

nudou350 · 10 months ago

same here!

christopher-czaban · 10 months ago

Exactly the same issue here.

  • Restarted several times with new session, doesn't help
  • Reset of internet connection doesn't help
  • Restarting without any MCP servers doesn't help
  • Turning thinking on/off doesn't help
  • New terminal session doesn't help
elithecho · 10 months ago

Found a hotfix, just downgrade for now.
Latest version is kinda broken

-> % cd ~/.claude/local
-> % npm i @anthropic-ai/claude-code@2.0.29

Update: claude doctor keeps auto upgrading back to the borked version

Update2: add this to your zshconfig, the echo is just a reminder until its fixed

export DISABLE_AUTOUPDATER=1
echo "FYI- Claude autoupdater disabled."
nickolay-kondratyev · 10 months ago

Suggestion for not allowing such things into production:

  • When you have you integration test scenarios, (which I presume includes core functionality like sub agent spawn). -> Add automated Monitoring of the logging for any errors that occurred and fail the tests if there are any errors.
SPAHI4 · 10 months ago

That's mind-bending that such a critical bug could happen literally in the middle of your code session because of auto-update for all the users. And no way to easily rollback an update.

nickolay-kondratyev · 10 months ago

Another suggestion: Add separate braveheart releases with auto updates. While having some named stable version, that majority of users can operate on.

nickolay-kondratyev · 10 months ago
That's mind-bending that such a critical bug could happen literally in the middle of your code session because of auto-update for all the users. And no way to easily rollback an update. - @SPAHI4

Add in your bash to disable auto updates (reference https://docs.claude.com/en/docs/claude-code/settings):

export DISABLE_AUTOUPDATER=1

Run the following to downgrade

npm i -g @anthropic-ai/claude-code@2.0.29
SPAHI4 · 10 months ago
> That's mind-bending that such a critical bug could happen literally in the middle of your code session because of auto-update for all the users. And no way to easily rollback an update. - @SPAHI4 Add in your bash to disable auto updates (reference https://docs.claude.com/en/docs/claude-code/settings): `` export DISABLE_AUTOUPDATER=1 ` Run the following to downgrade ` npm i -g @anthropic-ai/claude-code@2.0.29 ``

thanks! already done via CC itself :) after the previous comment

github-actions[bot] · 9 months ago

This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.