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
Now let's find where this
toolsreturn value gets merged with the agent's own tools list (LibreChat's web_search tool).Assistant
Now let's look at lines 828-848 more carefully and think about the fix - dedupe by tool name, preferring structuredTools (LibreChat's) over options.tools (native).
Assistant
Now let's implement the fix - deduplicate
options.toolsby name againststructuredTools, preferring structuredTools when there's a name collision.Assistant
No python3, let's use the
replacespecial command instead.Assistant
Good,
structuredToolsis an array of tools with.name(StructuredTool instances). Now let's typecheck this file.Assistant
These are pre-existing module resolution issues unrelated to our change (packages not built/linked). No new type errors from our edit. Let's build the packages to verify properly.
Assistant
Need to build data-provider first. Let's try building it.
Assistant
All existing tests pass. Now let's write a quick reproduction test to verify our fix behaves correctly - specifically for Anthropic with duplicate web_search tool names.
Assistant
Now let's write a quick temp test script to validate our fix using this pattern, then remove it.
Assistant
Test confirms the fix works. Now let's remove the temp test file and run the full existing test suite for this package to ensure nothing broke.
Assistant
All 29 test suites pass (742 tests). Now let's also check anthropic llm.ts test suite and run full api package tests to be extra safe.
Assistant
All good. Now let's run the full package test suite to check for wider regressions (may take a while, but let's try).
Assistant
Confirmed: these failures are pre-existing (require Redis), unrelated to our change. Let's use
test:cicommand which correctly excludes integration tests.Assistant
All non-integration tests pass (5144 passed, only skips which are pre-existing). Now let's check the git diff and clean up (e.g., package-lock.json / package.json changes I may have inadvertently introduced by running npm run build).
Assistant
These are unrelated side-effects from build/install steps. Let's revert them.
Assistant
Now let's also clean up the dist directories built for data-provider and data-schemas since they weren't part of original repo state (but they might be gitignored).
Assistant
Good, those are gitignored so they won't affect the submitted diff. Let's view the final diff.
Assistant
This is a clean, focused fix. Let's go through the checklist.
Assistant
All good. Let's review the checklist:
Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.