Responses to Claude: distinct tool names longer than 64 characters are truncated to the same name since v7.3.17 ("tools: Tool names must be unique")
Is it a request payload issue? [x] Yes, this is a request payload issue. I am using a client/cURL to send a request payload, but I received an unexpected error. [ ] No, it's another issue.
Describe the bug
On POST /v1/responses routed to a Claude credential, CLIProxyAPI truncates each tool name to 64 characters before it sends the request upstream. The truncation has no collision check and no reverse mapping. Two distinct tools whose names share the first 64 characters are sent with the same name, and Anthropic rejects the request:
tools: Tool names must be unique.This does not affect all Claude requests. It occurs only on the Responses to Claude conversion, and only when the final tool name is longer than 64 characters. Codex namespaced MCP tools (namespace__child) reach this length easily.
A single long tool name is also affected. The request succeeds, but the tool call returned to the client has the truncated name and no namespace, so the client cannot match it to the tool it declared.
Affected and working versions (official darwin_aarch64 release binaries, tested against a local mock upstream)
| Version | Two long namespaced tools | Two long flat tools | One long namespaced tool | /v1/messages with long names |
Short names |
|---|---|---|---|---|---|
| v7.3.13 | OK, 2 unique names, both round-trip | OK | OK, name and namespace restored | OK | OK |
| v7.3.16 | OK | OK | OK | OK | OK |
| v7.3.17 | 2 identical names sent | 2 identical names sent | Truncated name returned, no namespace | OK | OK |
| v8.0.3 | same as v7.3.17 | same | same | OK | OK |
| v8.0.4 | same as v7.3.17 | same | same | OK | OK |
The table shows the cloaked path (fingerprint-profile: claude-code-cli, cloak.mode: always). Without cloaking, v7.3.17 to v8.0.4 show the same collisions. Without cloaking, v7.3.13 and v7.3.16 send the full-length names upstream (see "Suggested direction"). An earlier run on v7.3.13, v8.0.3 and v8.0.4 with two model IDs (claude-opus-5-5, claude-sonnet-5-5) gave identical results for both.
Likely cause
Commit 75b854eb ("fix(translator): sanitize tool names for Claude and inject fallback schema for parameterless tools", 2026-09-24) added util.SanitizeClaudeFunctionName. That function replaces invalid characters and then cuts the name to 64 bytes. The Responses to Claude translator now calls it for tool definitions, tool_choice, and history tool_use names. GitHub compare shows that v7.3.16 does not contain this commit and v7.3.17 does. The binary results above agree.
At v8.0.4:
- Truncation:
internal/util/claude_tool_id.goL36-L48 - Call sites in the translator: L463 (history
tool_use), L617 (tool_choice), L1521 (function tools), L1543 (custom tools)
On the cloaked path, the executor's MCP alias pass runs after translation. The truncated names start with mcp__ and pass IsClaudeMCPToolName, so they are kept as-is instead of going to AllocateClaudeMCPToolAlias. In v7.3.16, the full names reach the allocator, which gives each tool a unique alias and restores the original name in the response.
The same calls are still present on dev at c8a2bfe8 (source inspection only).
Reproduction
Config (any Claude API key entry; the upstream can be a local capture server):
claude-api-key:
- api-key: "sk-ant-..."
base-url: "http://127.0.0.1:9999" # capture server, or omit for Anthropic
fingerprint-profile: "claude-code-cli" # optional; the bug occurs with or without it
cloak:
mode: "always"
models:
- name: "claude-sonnet-5-5"
alias: "claude-sonnet-5-5"Request. The two qualified names are 81 and 82 characters long, and their first 64 characters are the same:
curl -s http://127.0.0.1:8317/v1/responses \
-H "Authorization: Bearer <client-key>" -H "Content-Type: application/json" \
-d '{
"model": "claude-sonnet-5-5",
"input": "test",
"stream": false,
"tools": [{
"type": "namespace",
"name": "mcp__example_apps__acme_inventory_service",
"tools": [
{"type": "function", "name": "acme_inventory_service_get_item_prices",
"description": "synthetic", "parameters": {"type": "object", "properties": {}}},
{"type": "function", "name": "acme_inventory_service_get_item_metrics",
"description": "synthetic", "parameters": {"type": "object", "properties": {}}}
]
}]
}'Expected behavior
Each tool gets a distinct valid Claude name (at most 64 characters), and a tool call for either tool comes back to the client with its original name and namespace.
With cloaking on v7.3.16, the upstream tools[].name values were two different aliases of the form mcp__<alias>__<id>_mcp__example_apps__acme_inventory_serv, and both tools round-tripped.
Actual behavior (v7.3.17 to v8.0.4, with and without cloaking)
Upstream tools[].name:
mcp__example_apps__acme_inventory_service__acme_inventory_servic
mcp__example_apps__acme_inventory_service__acme_inventory_servicAnthropic rejects this with tools: Tool names must be unique. With only one of the two tools, the request succeeds, but the returned function_call has name: "mcp__example_apps__acme_inventory_service__acme_inventory_servic" and no namespace.
In one failing Codex request on v8.0.3 (37 top-level tools, including namespaces), 12 outgoing names were duplicated, with 57 excess entries. The largest group had 44 tools from one MCP namespace. I have not attached that log because it contains private data.
Workaround
Stay on v7.3.16 or earlier. The /v1/messages endpoint is not affected, but it is not a drop-in option for Responses clients such as Codex. I did not find a configuration-only workaround that keeps the Responses interface and all tool identities.
Suggested direction
A fix probably needs names that are valid, unique within the request, and reversible. The mapping must cover tool definitions, tool_choice, history tool_use, streaming and non-streaming responses, and later tool_result turns. Two things to avoid: removing "duplicate" tools (they are different operations), and only raising the length limit (Anthropic documents ^[a-zA-Z0-9_-]{1,64}$).
On the non-cloaked path, v7.3.16 sent the full 81 and 82 character names upstream. Per the Anthropic docs, that is also invalid, so reverting to v7.3.16 behavior alone does not fix that path. I can prepare a PR with regression tests if you agree on an approach.
Limits of this report
- The binary comparison used a local mock upstream. The mock rejects duplicate names and names that fail
^[a-zA-Z0-9_-]{1,64}$. The duplicate-name error from real Anthropic comes from production logs on v8.0.3 (Claude OAuth credential, Codex client). - The non-cloaked v7.3.16 result (names longer than 64 characters) was not tested against real Anthropic.
- I tested the binaries for v7.3.13, v7.3.16, v7.3.17, v8.0.3 and v8.0.4. I did not test v7.3.18 to v8.0.2 or
dev.
Related, but different causes
- #6175: MCP aliases in
tool_addition/tool_removalblocks (included in v8.0.4; does not fix this). - #4788, #4849: duplicate declarations from merging
toolsandadditional_toolsin the Chat Completions translator. - #4244: mentions the same 64-character truncation collision class for Antigravity, but did not address it.
- #4999: closed without merge; it has the same title as commit 75b854eb.
CLI Type
claude code (Claude OAuth in production; claude-api-key in the reproduction)
Model Name claude-opus-5-5 and claude-sonnet-5-5 (results do not depend on the model)
LLM Client
Codex (wire_api = "responses"); reproduced with cURL
OS Type
- OS: macOS (Apple Silicon)
- CLIProxyAPI: v8.0.3 and v8.0.4 affected; v7.3.16 not affected
Source: router-for-me/CLIProxyAPI