ISSUE DESCRIPTION Anthropic rejects duplicate websearch tool names When LibreChat web…
- User
ISSUE DESCRIPTION
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.
ADDITIONAL ADVICE
Since you are given a git repository, you can use git commands to simplify your work. For example, if you made a mistake and want to revert your changes, you can use
git checkout <file>to restore the file to its original state. You can also reset all changes in the repository usinggit reset --hardcommand. Additionally, you can usegit stashandgit stash popto temporarily save your changes and restore them later. Finally, you can see the changes that you've made (which will be submitted when you callsubmit) usinggit statusorgit diffcommands. However you don't need to usegit addorgit commitbefore submitting your changes. In fact,submitonly submits currently unstaged changes because it usesgit diffto get the changes that need to be submitted.CHECKLIST
Before submitting your solution, please go over the following checklist and make sure you've done everything:
- If an error was reported in the issue description, I have successfully reproduced it.
- If an error was reported in the issue description, I have confirmed that my fix resolves the error.
- I have thought about edge cases and made sure my fix handles them as well.
- I have run existing tests in the repository that might have been affected by the change I made and confirmed that they pass. I want you to list every bullet from this checklist and write your reasoning for why you think you did it or didn't need to.
Repository has been uploaded and your shell is currently at the repository root. Time to solve the issue!
(Current directory: /LibreChat, current file: none) bash-$
- Assistant
I'll explore the repository structure and search for how web_search tools are defined and passed to Anthropic.
- Assistant
Let me search more specifically for web_search related code.
- Assistant
Hmm, empty results. Let me try differently.
- Assistant
I'll inspect Anthropic LLM tooling and how web_search tools are assembled.
- Assistant
I'll open the Anthropic LLM and agent tooling code next.
- Assistant
Let me read the rest of the file around the web_search handling.
- Assistant
I'll examine how agent tools are loaded and merged with Anthropic native tools.
- Assistant
Let me look at the git log or any recent changes related to this issue, and alsosearch for how tools are filtered/deduplicated.
- Assistant
Let me look at how tools are combined when sending to Anthropic - maybe in run.ts or initialize.ts or client.ts
- Assistant
Let me look at initialize.ts around tools handling and also search for where Anthropic tools from llmConfig get merged.
- Assistant
Let me look at howÓ llm tools get merged into agent tools, particularly around anthropic and web_search.
- Assistant
Looking at openai/config.ts since it imports Anthropic LLM config - maybe that's where tools get combined.
- Assistant
Let me look for where tools from LibreChat and tools from llmConfig get merged - possibly in agent client or run.
- Assistant
I'll inspect run.ts for how LLM and agent tools are merged.
- Assistant
I'll locate where LLM tools get attached to the agent run.
- Assistant
Let me look at how tools from getOpenAIélConfig are used in OpenAI initialize and passed to agent.
- Assistant
Let me look at the agent client more carefully - how tools from endpoint config get merged.
- Assistant
Let me look at how agent.tools get composed with the tools from llmConfig. Looking at run.ts line 917:
- Assistant
Need to open the anthropic llm file again.
- Assistant
So tools are returned separately. Let me see how they're used after getOpenAIConfig...
- Assistant
Let me look at ToolService and how agent tools get combined with options.tools from the endpoint LLM config.
- Assistant
I need to find where tools from the LLM config (native Anthropic web_search) get merged with the agent tools. Let me look at agents package Run.
- Assistant
Let me look at how tools are boundit from agent tools and also native tools from llm config in the agents package.
- Assistant
Hmm empty? Maybe the package structure is different.
- Assistant
Let me search in the cjs with correct pattern.
- Assistant
Let me look at graph binding / how toolspanel are combined. Also check git history or any related PRs/issues.
- Assistant
Looking at Graph.cjs around allTools composition shall help.
- Assistant
Let me look how getToolsForBinding works and if tools with native web_search get combined.
- Assistant
Let me see how tools from getOpenAIConfig get into agent.tools - looking at endpoints initialize and option.tools.
- Assistant
So getOpenAIConfig returns
{ tools, llmConfig, ... }. These tools need to get into the agent somehow. Let me look at agents initialize.js - Assistant
Let me look more carefully at the agent_service initialize or how getOptions is used.
- Assistant
I need to see where endpoint option tools appear. Looking at packages/api agents initialize.ts around setting llmConfig and tools from options.
- Assistant
Let me continue reading where tools are concat with options.tools
- Assistant
I found the merge point. Checking tests and
Tools.web_searchso we can prefer LibreChat'sweb_searchdefinition. - Assistant
I'll scan nearby comments and git history for prior web_search dedup work.
- Assistant
I'll inspect getToolsForBinding for event-driven mode to catch other duplicate paths.
- Assistant
I'll check how returned agent tools are finalised at the end of initializeAgent.
- Assistant
I'll confirm the Tools.web_search constant and apply the fix.
- Assistant
Implementing the dedup in
initialize.tsso Anthropic nativeweb_searchis dropped when LibreChat already provides it. - Assistant
I'll check initialize tests around provider tools and the GOOGLE_TOOL_CONFLICT case.
- Assistant
I'll inspect createMocks and add a temporary verification script.
- Assistant
Let me find createMocks definition.
- Assistant
I'll write a temporary verification script for the Anthropic web_search duplicate cases.
- Assistant
I'll put a temporary test next to the existing initialize tests and run it.
- Assistant
Also need to mock skills like the existing test. Let me check more mocks from initialize.test.ts
- Assistant
I'll rewrite the temp test to match existing style and run it with jest.
- Assistant
Need to build data-provider or check jest config for moduleNameMapper.
- Assistant
Hmm I'm in packages/api - need to go back.
- Assistant
Let me check if initialize.test works and if data-provider needs building.
- Assistant
dist is missing for data-provider. Let me build it, or check if the existing tests run somehow.
- Assistant
Need to build data-provider first.
- Assistant
Build seems done. Let's run the temp test.
- Assistant
Need to build data-schemas too. Or maybe all packages.
- Assistant
Good, packages built. Now run the temp test.
- Assistant
All four temp tests passed. Next I'll run the existing initialize tests.
- Assistant
All tests pass. Cleaning up the temporary test and verifying the final diff.
- Assistant
I'll remove leftover temp files and revert unrelated package changes.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
Identical first prompt
claude-sonnet-5Compare side by side →
claude-sonnet-5Compare side by side →
claude-sonnet-5Compare side by side →
claude-sonnet-5Compare side by side →
claude-sonnet-5Compare side by side →
Qwen/Qwen3.6-35B-A3BCompare side by side →
Qwen/Qwen3.6-35B-A3BCompare side by side →
Qwen/Qwen3.6-35B-A3BCompare side by side →
Qwen/Qwen3.6-35B-A3BCompare side by side →
Qwen/Qwen3.6-35B-A3BCompare side by side →
Qwen/Qwen3.6-27BCompare side by side →
Qwen/Qwen3.6-27BCompare side by side →