[BUG] Compacting throws an error
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?
Bug: /compact command fails with "Tool names must be unique" error
Description
The /compact slash command fails with an API error indicating duplicate tool names, despite having a minimal MCP server configuration.
Environment
- Claude Code version: 2.0.70
- Model: Opus 4.5 (claude-opus-4-5-20251101)
- OS: macOS (Darwin 25.1.0)
- Platform: darwin
- Node.js: 24.4.1+ (local)
Steps to Reproduce
- Start a Claude Code session in a project with MCP server configurations
- Have a conversation (even a simple greeting)
- Run /compact
Expected Behavior
Conversation should be compacted/summarized to reduce context usage.
Actual Behavior
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_011CWAdUXuj1K2ddgLpmxhmf"
}
Verified MCP Configuration
Project .mcp.json:
{
"mcpServers": {
"Neon": {
"command": "npx",
"args": ["-y", "mcp-remote", "https://mcp.neon.tech/mcp"]
}
}
}
Project .claude/settings.local.json:
{
"enableAllProjectMcpServers": false,
"enabledMcpjsonServers": ["Neon"]
}
User-level project config (~/.claude.json entry for this project):
{
"mcpServers": {
"figma-desktop": {
"type": "http",
"url": "http://127.0.0.1:3845/mcp"
}
},
"disabledMcpServers": []
}
Global ~/.claude.json:
{
"mcpServers": {}
}
MCP Tools in Permissions Allow List
Only Neon tools are in the permissions:
- mcp__Neon__describe_table_schema
- mcp__Neon__get_database_tables
- mcp__Neon__list_projects
- mcp__Neon__run_sql
- mcp__Neon__run_sql_transaction
Hooks Configuration
{
"hooks": {
"PreCompact": [{
"hooks": [{
"type": "command",
"command": "bash ~/.claude/hooks/pre-compact.sh"
}]
}],
"PreToolUse": [...],
"PostToolUse": [...],
"Notification": [...],
"Stop": [...],
"SubagentStop": [...]
}
}
Analysis
The error occurs despite:
- Only 2 MCP servers configured (Neon + figma-desktop)
- These servers have completely different tool namespaces
- No duplicate tool names in the permissions list
- disabledMcpServers is empty
This suggests the bug is internal to Claude Code's compact operation rather than a user configuration issue. Possible causes:
- Built-in tools being registered with duplicates during compaction
- Tool deduplication logic failing
- Some tools being registered multiple times during the compact API call construction
What Should Happen?
It should compact with no error being thrown.
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_011CWAdzsCBFgCkCnd2n4N6D"}
Steps to Reproduce
start Claude
type "hi"
/compact
getting the error.
Claude Model
Opus
Is this a regression?
Yes, this worked in a previous version
Last Working Version
_No response_
Claude Code Version
Claude code .68
Platform
Anthropic API
Operating System
macOS
Terminal/Shell
Terminal.app (macOS)
Additional Information
_No response_
This issue has 7 comments on GitHub. Read the full discussion on GitHub ↗