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
I'll trace how web search tools are registered for Anthropic and where duplicate
web_searchnames can appear when both LibreChat and native search are enabled. - Assistant
Implementing deduplication in
initialize.tswhen merging provider tools, preferring LibreChat'sweb_searchdefinition. - Assistant
Adding tests for the deduplication behavior:
- Assistant
When both LibreChat web search and Anthropic’s native web search were enabled,
initializeAgentcould send two tools namedweb_search— LibreChat’s fromtoolDefinitions/structuredTools, and Anthropic’s{ type: 'web_search_20250305', name: 'web_search' }from provider options. Anthropic rejects that duplicate.The fix is in
packages/api/src/agents/initialize.ts, scoped to Anthropic only:isAnthropicNativeWebSearchTool— detects Anthropic’s native web search tool byname === 'web_search'and atypestarting withweb_search_.hasLibreChatWebSearchTool— checks whether LibreChat’sweb_searchis already loaded intoolDefinitionsorstructuredTools.- Before merging provider tools — if both are present on Anthropic, the native tool is filtered out so only LibreChat’s definition is exposed.
Other providers are unchanged. If only Anthropic-native web search is enabled (no LibreChat tool), it still works as before.
Tests cover:
- Event-driven mode (
toolDefinitionsonly) - Full tool instances ()
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.