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
Investigating how LibreChat and Anthropic web search tools are registered and merged so we can deduplicate
web_searchwhile preferring LibreChat's definition. - Assistant
Implementing deduplication: adding a helper to identify Anthropic's native
web_searchtool, then filtering it during tool merge when LibreChat's definition is already loaded. - Assistant
Adding tests for the deduplication behavior:
- Assistant
When both LibreChat web search and Anthropic’s native web search are enabled, the agent initializer was sending two tools named
web_search, which Anthropic rejects.Changes:
-
packages/api/src/endpoints/anthropic/helpers.ts— AddedisAnthropicNativeWebSearchTool()to identify Anthropic’s server-side tool (type: 'web_search_20250305', etc.) vs LibreChat’sweb_search. -
packages/api/src/agents/initialize.ts— Before merging provider tools with agent tools, if the provider is Anthropic and LibreChat’sweb_searchis already loaded (instructuredToolsortoolDefinitions), Anthropic’s nativeweb_searchis filtered out. LibreChat’s definition is kept. -
Tests — Three cases in
initialize.test.ts:- Event-driven mode (definitions only): native tool dropped
- Full tools mode: merged list has one
web_search(LibreChat’s) - Native-only: Anthropic native kept when LibreChat web search isn’t loaded
Other providers and unrelated tools are unchanged. No new public interfaces.
-
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.