Skip to content
TheChatArchiveThe Chat Archive
Claudeclaude-sonnet-5· anthropicHugging Face ibragim-bad/swe_rebench_07_2026_trajectories

ISSUE DESCRIPTION Anthropic rejects duplicate websearch tool names When LibreChat web…

  1. 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_search tool 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 using git reset --hard command. Additionally, you can use git stash and git stash pop to temporarily save your changes and restore them later. Finally, you can see the changes that you've made (which will be submitted when you call submit) using git status or git diff commands. However you don't need to use git add or git commit before submitting your changes. In fact, submit only submits currently unstaged changes because it uses git diff to 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-$

  2. Claude Assistant

    Let me use proper syntax with line numbers not in list form.

  3. Claude Assistant

    python3 not available, use node instead.

  4. Claude Assistant

    Good, formatting is correct. Now let's check for TypeScript compile errors and run related tests.

  5. Claude Assistant

    No errors reported for initialize.ts now. Let's check full output count for remaining errors to ensure none are new/related.

  6. Claude Assistant

    All good, no compile errors. Now let's run relevant test suites.

  7. Claude Assistant

    All existing tests pass. Now let's write a temporary test script to reproduce the scenario and verify the fix.

  8. Claude Assistant

    Now let's write a temporary test script to verify the dedup logic works.

  9. Claude Assistant

    The test passes with the fix. Let's verify the fix actually matters by temporarily reverting and confirming test failure.

  10. Claude Assistant

    Confirmed the bug reproduces without the fix, and the fix resolves it. Restore the fix.

  11. Claude Assistant

    These changes are unrelated environment artifacts from earlier npm operations, not from my edits. Let's revert them to keep the diff clean.

  12. Claude Assistant

    Now remove the temporary test file since we shouldn't add new tests to the repo, and clean up dist build artifacts if any were created.

  13. Claude Assistant

    Good, those are gitignored so they don't affect the diff. Now let's run the full test suite for the agents initialize module and any anthropic-related tests to be thorough.

  14. Claude Assistant

    All 742 tests pass (4 skipped intentionally). Let's also run anthropic endpoint tests and full api package test suite for safety.

  15. Claude Assistant

    All pass. Let's run the entire api package test suite once more for final confirmation.

  16. Claude Assistant

    Confirmed: these failures are pre-existing due to missing Redis server, unrelated to our change. Our fix is verified. Let's do a final review of the diff.

  17. Claude Assistant

    This is a clean, minimal, targeted fix. Now let's review the checklist.

  18. Claude Assistant

    Checklist Review

    • If an error was reported in the issue description, I have successfully reproduced it. Yes. I traced the code path: getLLMConfig in packages/api/src/endpoints/anthropic/llm.ts pushes a native { type: 'web_search_20250305', name: 'web_search' } tool onto options.tools when Anthropic-native web search (enableWebSearch) is on. Separately, LibreChat's own web-search plugin (from @librechat/agents's createSearchTool, via handleTools.js) also produces a structured tool named web_search. In packages/api/src/agents/initialize.ts, these were being concatenated unconditionally for the ANTHROPIC (and OPENAI/AZURE) providers, producing two tools both named web_search in the final tool list sent to the model — which Anthropic's API rejects. I wrote a temporary Jest test simulating this exact scenario (Anthropic provider, LibreChat web_search structured tool + Anthropic-native web_search tool both present) and confirmed, by stashing my fix, that the test failed with webSearchCount === 2 before the fix — reproducing the reported bug.

    • If an error was reported in the issue description, I have confirmed that my fix resolves the error. Yes. After applying the fix, the same temporary test passed with exactly one web_search tool in the result, and it was the LibreChat-authored tool object (verified via toContain(librechatWebSearchTool)), confirming LibreChat's definition is preferred as required by the issue. The temporary test file was removed afterward per instructions not to add tests to the repo.

    • I have thought about edge cases and made sure my fix handles them as well. Yes:

      • The dedup only removes provider-native tools whose name collides with an existing structured tool's name; unrelated tools (different names) are untouched.
      • Tools without a name property (e.g., OpenAI's native { type: 'web_search' } object — which lacks a name field) are unaffected since the filter only compares by name, and Google/Vertex are excluded entirely from this branch (handled by the separate GOOGLE_TOOL_CONFLICT branch above, untouched by my change).
      • If structuredTools doesn't contain a web_search-named tool (i.e., only Anthropic-native search is enabled, not LibreChat's), the provider-native tool is preserved as before — no regression for that case.
      • The fix is generic (name-based dedup) rather than hardcoded to the literal string 'web_search', so it generalizes to any future provider-native/plugin-name collision without special-casing.
    • I have run existing tests in the repository that might have been affected by the change I made and confirmed that they pass. Yes. Ran src/agents/__tests__/initialize.test.ts (34/34 pass), the entire src/agents test directory (742 passed, 4 intentionally skipped), and src/endpoints/anthropic tests (91/91 pass). Also ran the full packages/api test suite; the only failures were pre-existing Redis/cache integration tests requiring a live Redis server (confirmed these fail identically with the fix reverted, i.e., unrelated to this change). Also confirmed tsc --noEmit shows no new type errors introduced by the change.

Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.