[Bug] /compact fails with "Tool names must be unique" even after disabling all MCP servers (v2.0.70)

Status Fixed / completed
Maintainer reply None cached
Activity 5 comments · opened Dec 16, 2025 · closed Dec 17, 2025

Preflight Checklist

  • [x] I have searched existing issues and this hasn't been reported yet
  • [x] This is a single bug report (please file separate reports for different bugs)
  • [x] I am using the latest version of Claude Code

What's Wrong?

The /compact command fails with API Error 400: "tools: Tool names must be unique"
immediately after starting a new session.

This error persists even after:

  • Disabling all MCP servers via /mcp disable
  • Fresh session with minimal conversation

The bug was reportedly fixed in v2.0.31, but it has regressed in v2.0.70.

What Should Happen?

/compact should successfully compact the conversation without API errors,
regardless of MCP server status or custom agent/command configurations.

Error Messages/Logs

> /compact
    ⎿  Error: Error during compaction: Error: API Error: 400
       {"type":"error","error":{"type":"invalid_request_error",
       "message":"tools: Tool names must be unique."},
       "request_id":"req_011CW9cz13pCHJv2SC8NPCaq"}

  After disabling MCP:
  > /mcp disable
    ⎿  Disabled 3 MCP server(s)

  > /compact
    ⎿  Error: Error during compaction: Error: API Error: 400
       {"type":"error","error":{"type":"invalid_request_error",
       "message":"tools: Tool names must be unique."},
       "request_id":"req_011CW9cz13pCHJv2SC8NPCaq"}

Steps to Reproduce

  1. Start Claude Code v2.0.70
  2. Have custom agents (20) and slash commands (56) configured in ~/.claude/
  3. Run any command (even simple greeting like "hello")
  4. Execute /compact
  5. Error occurs: "tools: Tool names must be unique"

Alternative test:

  1. Run /mcp disable to disable all MCP servers (3 servers disabled)
  2. Run /compact
  3. Same error still occurs

Claude Model

Opus

Is this a regression?

Yes, this worked in a previous version

Last Working Version

2.0.70

Claude Code Version

  • Claude Code version: 2.0.70

Platform

Anthropic API

Operating System

Windows

Terminal/Shell

VS Code integrated terminal

Additional Information

  • This appears to be a regression. The same issue was fixed in v2.0.31 (Issue #10668)
  • The error occurs even with 0 MCP servers active
  • Custom slash commands follow a pattern: /command and /sc:command (e.g., /analyze and /sc:analyze)
  • Custom agents are defined in ~/.claude/agents/*.md files
  • Possibly related to tool deduplication logic during compaction subprocess

Related issues:

  • #10668 (original fix in v2.0.31)
  • #10697 (duplicate)
  • #10761 (similar recent report)

View original on GitHub ↗

5 Comments

github-actions[bot] · 8 months ago

Found 3 possible duplicate issues:

  1. https://github.com/anthropics/claude-code/issues/14111
  2. https://github.com/anthropics/claude-code/issues/10668
  3. https://github.com/anthropics/claude-code/issues/10697

This issue will be automatically closed as a duplicate in 3 days.

  • If your issue is a duplicate, please close it and 👍 the existing issue instead
  • To prevent auto-closure, add a comment or 👎 this comment

🤖 Generated with Claude Code

turkenh · 8 months ago

Just hit this and the following worked for me:

  • Exit claude code
  • Restart with claude --continue
  • Call /compact again.
BoMadsen · 8 months ago
Just hit this and the following worked for me: Exit claude code Restart with claude --continue * Call /compact again.

That almost worked for me, although I had to do a "/mcp disable" before the exit to get it to work.

bhosmer-ant · 8 months ago

Thanks for reporting - should be fixed in the next version.

github-actions[bot] · 8 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.