Anthropic rejects duplicate websearch tool names When LibreChat web search and…
- User
Anthropic rejects duplicate web_search tool names
When LibreChat web search and Anthropic-native web search are both enabled, expose one
web_searchtool and prefer LibreChat's definition. Do not affect unrelated tools or other providers.Interface
No new public interfaces are introduced.
- Assistant
Now let's look at the test file setup so I can add a regression test:
- Assistant
Now I'll add a regression test. Let me insert a new describe block after the GOOGLE_TOOL_CONFLICT test:
- Assistant
All 37 tests pass, including the 3 new ones. Now verify TypeScript and ESLint:
- Assistant
Both changes are clean. Summary of the fix:
Root cause
When both LibreChat web search and Anthropic-native web search are enabled, two tools named
web_searchreach the request:- LibreChat's — loaded as a structured LangChain tool via
loadTools(structuredTools) - Anthropic-native —
{ type: 'web_search_20250305', name: 'web_search' }pushed intooptions.toolsbygetLLMConfig(packages/api/src/endpoints/anthropic/llm.ts:298)
They were blindly concatenated in
initializeAgent(packages/api/src/agents/initialize.ts:868), and Anthropic's API rejects requests containing duplicate tool names.Changes
packages/api/src/agents/initialize.ts - LibreChat's — loaded as a structured LangChain tool via
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.