Skip to content
TheChatArchiveThe Chat Archive
GLMz-ai/glm-5.2· unknownHugging 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. GLM Assistant

    Let me start by exploring the repository structure to understand the codebase.

  3. GLM Assistant

    Let me explore the repository structure first.

  4. GLM Assistant

    Let me search for web_search related code in the codebase.

  5. GLM Assistant

    Let me explore the Anthropic-specific code related to web search.

  6. GLM Assistant

    Now let me look at the Anthropic-specific LLM endpoint code where web search tools are defined.

  7. GLM Assistant

    Let me look at where the Anthropic LLM config tools are used/combined with LibreChat tools.

  8. GLM Assistant

    Now let me find where the Anthropic config tools get combined with LibreChat's agent tools.

  9. GLM Assistant

    Let me look at the LibreChat web_search tool definition.

  10. GLM Assistant

    Let me look at the spec files to understand the expected behavior and existing tests.

  11. GLM Assistant

    Let me look at the exact section in initialize.ts where tools get combined.

  12. GLM Assistant

    Let me check the Tools enum and how the LibreChat web_search structured tool is named.

  13. GLM Assistant

    Let me check the GenericTool type and how tool names are accessed.

  14. GLM Assistant

    Let me look at the existing initialize tests for the tool concatenation block.

  15. GLM Assistant

    These tests are about the loadTools call where agent.tools is passed in. Let me focus on the actual tool concatenation block at line 829-847. The tests here are with Providers.OPENAI (default provider in the helper). Let me check whether there are tests that exercise the concat block with options.tools (the provider-specific tools).

    Let me search for tests that pass options.tools (result from getOptions) containing the web_search native tool.

  16. GLM Assistant

    Let me look at the createMocks helper and the loadTools mock structure.

  17. GLM Assistant

    Let me look at how structuredTools is obtained from loadTools.

  18. GLM Assistant

    Let me verify how the LibreChat web_search structured tool is named when loaded.

  19. GLM Assistant

    Let me look at the structured tool creation for web_search in handleTools.js to confirm the tool name.

  20. GLM Assistant

    Let me look at createSearchTool to confirm the tool name.

  21. GLM Assistant

    Let me check createSearchTool in @librechat/agents to confirm the tool name is web_search.

  22. GLM Assistant

    Confirmed. Now let me look at the tools.spec.ts test around line 98 to understand how the concat is tested.

  23. GLM Assistant

    Now I understand the issue fully. Let me make the fix in initialize.ts. The fix should deduplicate the web_search tool for Anthropic only, preferring LibreChat's definition (in structuredTools).

  24. GLM Assistant

    Now let me make the edit:

  25. GLM Assistant

    Let me check how the native options.tools and toolDefinitions reach the final API request, to ensure I cover event-driven mode too.

  26. GLM Assistant

    Let me check the buildToolSet and how toolDefinitions + native tools combine in the agents library.

  27. GLM Assistant

    Let me look at how the agents library merges tools and toolDefinitions for the actual LLM request.

  28. GLM Assistant

    Hmm, no results. Let me check how the agents library handles the tools field and native tools. Let me look at the types.

  29. GLM Assistant

    Let me check whether in event-driven mode structuredTools is empty while toolDefinitions holds the LibreChat web_search.

  30. GLM Assistant

    Let me check how loadTools is configured (definitionsOnly mode) in the agents controller.

  31. GLM Assistant

    I need to handle the event-driven (default) path too, where structuredTools is empty but toolDefinitions holds LibreChat's web_search. Let me revise the fix to dedupe based on both.

  32. GLM Assistant

    Let me rewrite the block to handle both legacy and event-driven modes. I'll compute providerTools (filtered) for Anthropic before the branch logic, based on whether LibreChat's web_search is in structuredTools OR toolDefinitions.

    Let me replace lines 829-868.

  33. GLM Assistant

    Let me verify that the LibreChat web_search is included in toolDefinitions in event-driven mode.

  34. GLM Assistant

    Let me check that loadToolDefinitions includes the web_search definition.

  35. GLM Assistant

    Let me verify the LCTool type has a name field.

  36. GLM Assistant

    Now let me run the existing tests to make sure I didn't break anything. First, let me check the test setup.

  37. GLM Assistant

    I'm already in packages/api. Let me run from current dir.

  38. GLM Assistant

    The module 'librechat-data-provider' isn't resolved. Let me check the jest config and whether the data-provider package is built.

  39. GLM Assistant

    I'm in packages/api. Let me use correct paths. Let me check the root jest config and data-provider build status.

  40. GLM Assistant

    The root has no jest.config, but the package.json scripts at root mention jest. Wait, the root package.json has test script. But there's no jest.config at root? Let me re-check. Earlier cat package.json | grep jest showed jest scripts in... Actually that was the root package.json. But there's no jest.config at root. Let me check the root package.json more carefully — maybe jest config is inline.

    Actually wait, the earlier cat packages/api/package.json | grep -A20 '"scripts"' returned the api scripts (test, test:ci, etc.) — but I was IN packages/api so that was actually the root? No... let me re-check. Earlier output showed scripts with "test": "jest --coverage --watch --testPathIgnorePatterns..." which matches the api package.json. Hmm but I ran cat packages/api/package.json while in /LibreChat root at that time. So that WAS the api package.json.

    So jest config for api is at packages/api. Let me find it.

  41. GLM Assistant

    The librechat-data-provider is a workspace package. Let me check if it's resolvable via node_modules.

  42. GLM Assistant

    The data-provider has no dist dir, so its main entry isn't resolvable. Let me check its package.json main field.

  43. GLM Assistant

    The data-provider needs to be built. Let me build the dependent packages.

  44. GLM Assistant

    Both packages are built now. Let me run the initialize test.

  45. GLM Assistant

    All initialize tests pass. Now let me run the Anthropic LLM spec and the tools/agents specs.

  46. GLM Assistant

    Both pass. Now let me write a temporary test script to reproduce the duplicate scenario and confirm my fix resolves it for both legacy and event-driven modes.

  47. GLM Assistant

    All temporary tests pass. Let me confirm the fix is needed by temporarily reverting and verifying the duplicate would occur without the fix.

  48. GLM Assistant

    Confirmed: without the fix, both legacy and event-driven tests fail (duplicate web_search present), and the fix resolves both. Let me check the unexpected package.json/package-lock.json modifications.

  49. GLM Assistant

    These package.json/package-lock.json changes are pre-existing environment artifacts (from install), unrelated to my fix. Let me revert them to keep the submission focused on the actual fix.

  50. GLM Assistant

    The diff now only contains my fix. Let me re-run the relevant tests to confirm everything still passes after the revert.

  51. GLM Assistant

    Now let me remove the temporary test file before submitting.

  52. GLM Assistant

    Only initialize.ts is modified. Let me do a final review of the change.

  53. GLM Assistant

    The change looks clean and minimal. Let me run the broader agents test suite to ensure nothing else broke.

  54. GLM Assistant

    All agents tests pass. Let me run a TypeScript type check on the package to ensure no type errors were introduced.

  55. GLM Assistant

    The errors shown are all pre-existing and unrelated to my change (about EModelEndpoint.custom/agents indexing in AppConfig, in config/endpoints/resources files — likely from the data-provider build version). Let me confirm my change introduced no type errors specifically in initialize.ts.

  56. GLM Assistant

    No type errors in initialize.ts. The pre-existing errors are in unrelated files (config/endpoints/resources) and exist independent of my change.

    Let me do a final verification of the complete diff and git status.

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