Skip to content
TheChatArchiveThe Chat Archive
MiniMaxminimax/minimax-m3· 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. MiniMax Assistant

    I'll analyze the repository structure and understand the issue before making changes.

  3. MiniMax Assistant

    Let me look at the key files for Anthropic-specific web search handling:

  4. MiniMax Assistant

    Now let me look at the transform function or the place where tools are added to the Anthropic LLM:

  5. MiniMax Assistant

    Now let me look at where the tools are merged/processed in the larger flow:

  6. MiniMax Assistant

    Now let me look at the place where loading tools happens:

  7. MiniMax Assistant

    Let me look at how tools are loaded:

  8. MiniMax Assistant

    Let me look for where web_search is used in Anthropic flow:

  9. MiniMax Assistant

    Let me look at the ToolService.js to understand the web_search handling:

  10. MiniMax Assistant

    Now let me look at the Anthropic-specific LLM endpoint to see how the tools from LLM config get combined with the loaded tools:

  11. MiniMax Assistant

    Let me check exactly how the tools are merged into the LLM config for the Anthropic endpoint:

  12. MiniMax Assistant

    Let me look at the @librechat/agents package since it handles the LLM creation:

  13. MiniMax Assistant

    Let me look at the Anthropic message preparation to understand how tools are merged:

  14. MiniMax Assistant

    Let me look at the initialize.js for the agents endpoint:

  15. MiniMax Assistant

    Let me look at the agent initialize function to see how tools end up in the LLM config:

  16. MiniMax Assistant

    Now let's look at where the tools are finalized in the LLM config. Let me look at the Anthropic endpoint to find where the tools from LLM config (the tools we set in getLLMConfig) get integrated:

  17. MiniMax Assistant

    Let me look at the test file for the Anthropic LLM to understand the expected behavior:

  18. MiniMax Assistant

    Now I understand the test. Let me understand the issue completely. The problem is that when LibreChat's native web search tool is enabled (it's added to agent.tools as 'web_search'), and Anthropic's native web search is also enabled (via model_parameters.web_search), both create a tool with name: 'web_search', which Anthropic rejects.

    Let me find where the tools are merged:

  19. MiniMax Assistant

    Now let me look at the handleTools.js to understand how the LibreChat web_search tool is constructed:

  20. MiniMax Assistant

    Now let me check the Tools enum to understand its definition:

  21. MiniMax Assistant

    Now let's understand the actual flow more clearly. Let me look at the test file for the getLLMConfig to understand how the result is expected:

  22. MiniMax Assistant

    Now let me look at the test for "config.anthropic.spec.ts" which likely has the test for the endpoint:

  23. MiniMax Assistant

    Now let me look at the config.anthropic.ts:

  24. MiniMax Assistant

    Now let me look at the OpenAI llm.ts to see how OpenAI handles web_search:

  25. MiniMax Assistant

    Now I have a clearer picture. Let me check the agent's tools array - if both web_search (from agent.tools) and the anthropic-default web_search tool are active, they would produce duplicates.

    Let me look for how the tools are merged into the LLM config in the agent flow:

  26. MiniMax Assistant

    Let me look at the createRun to find tool merging:

  27. MiniMax Assistant

    Let me look at where the tools are added to the LLM invoke:

  28. MiniMax Assistant

    Let me look at the @librechat/agents anthropic.ts to see how web_search is handled:

  29. MiniMax Assistant

    Let me look at @librechat/agents index.ts to understand the architecture:

  30. MiniMax Assistant

    Let me look at the LibreChat createSearchTool to understand what name it returns:

  31. MiniMax Assistant

    Now I have a clearer picture. Both tools are named web_search:

    • LibreChat's createSearchTool returns a tool with name: 'web_search'
    • Anthropic's getLLMConfig adds { type: 'web_search_20250305', name: 'web_search' } when web_search is enabled

    Let me look at the issue more carefully. Let me trace the flow:

  32. MiniMax Assistant

    Now let me get the bigger picture by looking at the LibreChat agent's structure - how does the tool instantiate and end up conflicting?

    Let me look at the responses/types.ts to understand tool type:

  33. MiniMax Assistant

    Now let me look at the added.ts to understand how tools are added:

  34. MiniMax Assistant

    Now let me dig into the actual issue. The Anthropic LLM has been configured with web_search: true so it adds a tool { type: 'web_search_20250305', name: 'web_search' }. Then the agent loads the LibreChat web_search tool which is also named web_search.

    The fix should be in the agent's initialize.ts where it combines LibreChat's tools with the LLM-specific tools. Let me look at where the tools from the LLM config and the loaded tools are combined:

  35. MiniMax Assistant

    Now I see the issue. Let me trace options.tools flow. Let me look at where options.tools is set in the agent initialize flow:

  36. MiniMax Assistant

    Now let me look at the entire initialize flow - how the tools from LLM config (the web_search tool) end up being passed to initializeAgent:

  37. MiniMax Assistant

    Now let me look at where the tools from the LLM config are added back to the agent's tools list. I need to see if the LLM web_search tool is added to the agent's tools somewhere:

  38. MiniMax Assistant

    Let me look at the agent's run.ts to see how tools are passed:

  39. MiniMax Assistant

    Let me look at the initializeAgent flow where the tools are bundled. Looking at the agent's tools array initialized at line 829-846 of initialize.ts:

  40. MiniMax Assistant

    Now let me find where the options.tools come from. The options here is LoadAgentOptions or similar. Let me check more:

  41. MiniMax Assistant

    Let me look at the structure of options for initializeAgent:

  42. MiniMax Assistant

    Now I see. The options.tools come from getOptions which calls getProviderConfig. Let me look at what getOptions returns:

  43. MiniMax Assistant

    Let me look at the InitializeResultBase type:

  44. MiniMax Assistant

    So options.tools comes from the Anthropic initialize which returns tools: [{ type: 'web_search_20250305', name: 'web_search' }].

    Now I need to understand the full flow. Let me look at how the agent's tools are set:

  45. MiniMax Assistant

    Now let me look at how the agent's tools array (from agent.tools) is used. The agent's tools array contains 'web_search' (string), and the options.tools (from the LLM config) might contain { type: 'web_search_20250305', name: 'web_search' }. These are later passed to loadTools which converts the string 'web_search' to a tool named 'web_search'.

    Let me trace how options.tools (the LLM options) interacts with agent.tools (the string list):

  46. MiniMax Assistant

    Now let me look at what toolDefinitions (structuredTools) is set to:

  47. MiniMax Assistant

    OK now I understand the flow. Let me look at this:

    1. agent.tools is a list of strings like ['web_search', 'execute_code', ...]
    2. loadTools is called with these strings and returns structuredTools (the LibreChat's web_search tool etc.) and toolDefinitions
    3. options.tools comes from the LLM config (anthropic web_search tool from getLLMConfig)
    4. The agent's tools (line 829) is set to structuredTools if options.tools is empty, otherwise options.tools, otherwise structuredTools.concat(options.tools)

    So when both options.tools (LLM-specific) and structuredTools (LibreChat's tools) are present, they're concatenated. This is where the problem occurs.

    Let me look at the existing test to understand the expected behavior:

  48. MiniMax Assistant

    Now let me look at the initialize.test.ts file to see how the agent initialization is tested:

  49. MiniMax Assistant

    Now let me look at the test on line 745 which has agent.tools = ['web_search']:

  50. MiniMax Assistant

    Now let me look at where the tools from LLM config are concatenated. Looking at the initialize.ts file:

  51. MiniMax Assistant

    Now I see the issue clearly. When:

    • agent.provider === Providers.ANTHROPIC
    • options.tools (LLM) has [{ type: 'web_search_20250305', name: 'web_search' }]
    • structuredTools (LibreChat) has LibreChat's web_search tool

    Both will be concatenated, creating two web_search tools. This is the duplicate.

    Now let me think about the fix. The issue says:

    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.

    The fix should:

    1. Detect when both LibreChat's web_search AND Anthropic's web_search are enabled
    2. Only expose one of them (prefer LibreChat's)
    3. Not affect other providers or other tools

    Let me see where both options.tools and structuredTools are added together. The duplicated logic is at the tools = structuredTools.concat(options.tools) step.

    Let me look at the initialize.test.ts to see how the tools are tested:

  52. MiniMax Assistant

    Now let me look at the createMocks function in tests:

  53. MiniMax Assistant

    Now let me check the test file for the existing tests on the merge logic:

  54. MiniMax Assistant

    Let me look at how the tools get into the LLM when bindTools is called. Looking at the tools field initialization from the agent flow:

  55. MiniMax Assistant

    Now let me look at the agent's tools after initialize. It is passed to the Run.create as agent.tools. Let me look at the createRun to check how tools is used:

  56. MiniMax Assistant

    Let me look at this.tools in AgentContext:

  57. MiniMax Assistant

    So this.tools is set from the agent.tools from the initialize flow. Looking at the initialize.ts, the agent.tools is concatenated with options.tools (LLM-specific tools). So when both LibreChat's web_search AND Anthropic's web_search are present, both are in agent.tools, and they both get bound to the LLM, causing the duplicate.

    Now let me look at the actual problem. Looking at the merge logic:

  58. MiniMax Assistant

    So the issue is here. When:

    • agent.provider === Providers.ANTHROPIC
    • options.tools has { type: 'web_search_20250305', name: 'web_search' }
    • structuredTools has LibreChat's web_search tool (also named web_search)

    Both tools get concatenated.

    Now, the fix should be to deduplicate the tools by name, preferring LibreChat's tools over the LLM-provided tools. Let me look at the actual tool structure to understand:

  59. MiniMax Assistant

    Now let me look at the existing tests for the concat logic - what's the test verifying?

  60. MiniMax Assistant

    Now let me write a simple test to reproduce the issue first. Let me see how the test for the concat logic works:

  61. MiniMax Assistant

    Now let me write a script to reproduce the issue:

  62. MiniMax Assistant

    The issue is reproduced. Now let me think about the fix.

    The fix should be in initialize.ts where the tools are concatenated. The condition should:

    1. When both options.tools (LLM-specific tools) and structuredTools (LibreChat's tools) have the same name, prefer LibreChat's tool
    2. Only affect the ANTHROPIC provider (since that's the issue)
    3. Not affect other providers or other tools

    Let me also look at the toolDefinitions (event-driven mode), since that's another path where tools are exposed:

  63. MiniMax Assistant

    Now let me look at the types more carefully - LCTool is the tool definition:

  64. MiniMax Assistant

    Now I need to understand the structure of the tool. The options.tools items are tool definitions (like { type: 'web_search_20250305', name: 'web_search' }). The structuredTools are GenericTool instances (with name property).

    Both have a name property. So I can deduplicate by name.

    Let me look at the structuredTools to confirm this:

  65. MiniMax Assistant

    Good. Now let's look at the StructuredToolInterface to understand the structure:

  66. MiniMax Assistant

    Good. Both StructuredTool (LangChain) and BindToolsInput have a name property. So both can be deduplicated by name.

    Now let me look at the issue more carefully. The fix should be in initialize.ts and should:

    1. Detect when both LibreChat's web_search AND Anthropic's web_search are enabled
    2. Only expose one of them (prefer LibreChat's)
    3. Not affect other providers or other tools

    Let me design the fix:

  67. MiniMax Assistant

    Now let me think about the fix. Now let me look at the tools property type more carefully:

  68. MiniMax Assistant

    Now let me look at the tools types in initialize.ts. The options.tools is unknown[] based on the type definition:

  69. MiniMax Assistant

    Now let me also check the Tools enum:

  70. MiniMax Assistant

    Now I need to understand the structure of the options.tools better. The options.tools for the Anthropic endpoint returns:

    { type: 'web_search_20250305', name: 'web_search' }
    

    And the structuredTools for the LibreChat web search tool returns a DynamicStructuredTool with name: 'web_search'.

    Let me write the fix. The cleanest approach is to deduplicate by name in the concat:

  71. MiniMax Assistant

    Now let me think about the best place for the fix. Looking at the code:

    let tools: GenericTool[] = options.tools?.length
      ? (options.tools as GenericTool[])
      : (structuredTools ?? []);
    
    if (
      (agent.provider === Providers.OPENAI ||
        agent.provider === Providers.AZURE ||
        agent.provider === Providers.ANTHROPIC) &&
      options.tools?.length &&
      structuredTools?.length
    ) {
      tools = structuredTools.concat(options.tools as GenericTool[]);
    }
    

    The fix should:

    1. When concatenating, dedupe by name
    2. Prefer LibreChat's tools (in structuredTools)

    Let me write the fix:

  72. MiniMax Assistant

    Now let me also think about the toolDefinitions path - if the tool is in event-driven mode, the toolDefinitions are used:

  73. MiniMax Assistant

    Let me see how toolDefinitions and tools are related:

  74. MiniMax Assistant

    Now I see. In event-driven mode, both toolDefinitions (from loadTools) and tools (from options.tools) are used. The tools from options also need to be deduplicated. Let me look at the bindTools logic:

  75. MiniMax Assistant

    Let me look at the relevant code path more carefully:

  76. MiniMax Assistant

    I see—so in event-driven mode, both toolDefinitions (LibreChat's tools) and instanceTools (from this.tools, which is the concatenated tools array) get bound. So if both the LibreChat's web_search and the Anthropic's web_search are in the tools array, both will get bound.

    So the fix needs to:

    1. In the tools array (the LLM bind tools), deduplicate by name when concatenating
    2. The tools array is what's passed to bindTools()

    Let me also check that the fix doesn't affect other providers. The fix should be limited to the case where both LibreChat's tools and LLM-specific tools share the same name.

    Let me also think about this more carefully. Looking at the tools flow:

    1. agent.tools is a String[] (e.g., ['web_search'])
    2. loadTools converts these strings into structuredTools (which are tool instances like DynamicStructuredTool)
    3. loadTools also returns toolDefinitions (the LCTool schema for event-driven mode)
    4. options.tools from getLLMConfig returns provider-specific tools like { type: 'web_search_20250305', name: 'web_search' }

    The options.tools is the provider's native tool definitions (e.g., for Anthropic, the web_search_20250305 server tool). These are bound to the LLM directly.

    The structuredTools are the LibreChat-side tool instances (for direct execution).

    Both end up bound to the LLM (because the LLM needs to know about all available tools in its function-calling API). That's why duplicating the name causes the issue.

    Now let me write the fix. Let me first look at the relevant code one more time:

  77. MiniMax Assistant

    Now let me write the fix:

  78. MiniMax Assistant

    Now let me think about where to put the fix. The simplest fix is to dedupe by name in the tools array. Let me look at the issue once more:

    The issue is that when both LibreChat's web_search (string) and Anthropic's web_search (LLM config) are enabled, both get added as tools with name: 'web_search'. The fix should be to only expose one. Per the issue, prefer LibreChat's.

    Let me write the fix. Looking at the code:

  79. MiniMax Assistant

    Now I'll write the fix. The dedup should be done by name, preferring LibreChat's tools. Let me also check what options.tools looks like for both OpenAI and Anthropic:

  80. MiniMax Assistant

    So OpenAI's web_search tool is { type: 'web_search' } (no name). The Anthropic one is { type: 'web_search_20250305', name: 'web_search' }.

    For OpenAI, the tool has type: 'web_search' but no name. So the dedup needs to be careful here.

    Let me think about this more carefully. The issue says:

    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.

    So the fix should:

    1. Only apply when both LibreChat's web_search AND Anthropic's web_search are enabled
    2. Prefer LibreChat's definition
    3. Don't affect other tools or other providers

    Let me look at the type for OpenAI web_search tool:

  81. MiniMax Assistant

    The OpenAI version uses { type: 'web_search' } (no name). Hmm, let me check the OpenAI Responses API spec for this:

  82. MiniMax Assistant

    OK so the OpenAI web_search tool is recognized by its type field. The Anthropic one has both type and name.

    Now let me focus on the fix. The issue is that we have two tools with the same name (LibreChat's web_search and Anthropic's web_search). For the Anthropic endpoint, we need to deduplicate.

    Looking at the existing code logic, the fix should be in the else if branch where the tools are concatenated. The fix should:

    1. Dedupe by name
    2. Prefer LibreChat's tools (from structuredTools)
    3. Only apply to the specific case where names match

    Let me also consider that options.tools for OpenAI is { type: 'web_search' } (no name, so no conflict). The conflict only happens with Anthropic's { type: 'web_search_20250305', name: 'web_search' }.

    Let me design the fix:

  83. MiniMax Assistant

    Wait, for OpenAI, we'd still have a duplicate because the OpenAI tool is { type: 'web_search' } (no name). But this is a separate test case. Let me think about this carefully.

    Actually, looking at the OpenAI test, the final list contains both with different name (calculator and web_search), and the LibreChat's web_search is the LibreChat's tool, and the OpenAI's web_search (no name but type) is also there. So OpenAI doesn't have a name conflict on the surface, but they could potentially conflict when bound to the LLM.

    Let me check the OpenAI Responses API spec for both:

  84. MiniMax Assistant

    OK so OpenAI's web search tool uses type: 'web_search_preview' | 'web_search_preview_2025_03_11' - no name. So OpenAI doesn't have a name conflict.

    Now let me focus on the actual fix. The issue specifically says:

    Anthropic rejects duplicate web_search tool names

    So the fix should specifically deduplicate when both LibreChat's web_search and Anthropic's web_search are present. Let me look at the existing dedup logic - if any, from agent.tools:

  85. MiniMax Assistant

    Let me look at the unionPrimeAllowedTools to see how it does dedup:

  86. MiniMax Assistant

    Good. Now let me write the fix:

  87. MiniMax Assistant

    All test cases pass. Now let me also think about the OpenAI scenario. Although the issue says it only affects Anthropic, the dedup logic should be safe for OpenAI too because tools without a name field won't be filtered out.

    Let me now write the actual fix:

  88. MiniMax Assistant

    Now let me apply the fix:

  89. MiniMax Assistant

    Let me verify the change was applied correctly:

  90. MiniMax Assistant

    Now let me also verify that the existing tests still pass. Let me look at the existing tests for this specific code:

  91. MiniMax Assistant

    These errors are about the modules not being built. Let me build the data-provider first:

  92. MiniMax Assistant

    Now let me try the tsc again:

  93. MiniMax Assistant

    I need to build data-schemas first:

  94. MiniMax Assistant

    No TypeScript errors. Let me now run the existing tests to make sure they still pass:

  95. MiniMax Assistant

    All existing tests pass. Now let me also write a test for the new fix to confirm it works. But wait, the instructions say I shouldn't modify existing tests or add new tests. Let me think about this.

    Actually, the instructions say:

    However UNDER NO CIRCUMSTANCES should you modify existing tests or add new tests to the repository.

    So I should not add new tests. Let me instead create a temporary script to verify the fix works:

  96. MiniMax Assistant

    All test cases pass. Now let me check the typescript opens more carefully. Let me also check if there are tests that exercise the exact concat logic:

  97. MiniMax Assistant

    Let me run all the tests in the agents folder to ensure my fix doesn't break anything:

  98. MiniMax Assistant

    All tests pass. Let me also run the Anthropic endpoint tests:

  99. MiniMax Assistant

    All Anthropic tests pass. Let me also run the openai config tests:

  100. MiniMax Assistant

    All tests pass. Let me also run the entire test suite for the api package to be safe:

  101. MiniMax Assistant

    Let me check if these failures are caused by my fix or pre-existing:

  102. MiniMax Assistant

    These failures look like infrastructure issues (Redis, MongoDB) - not related to my fix. Let me confirm by running tests on git stash:

  103. MiniMax Assistant

    Yes, the failures are pre-existing - they exist even without my fix. Let me restore my fix:

  104. MiniMax Assistant

    Wait, there are modifications to package.json and package-lock.json too. Let me check what changed:

  105. MiniMax Assistant

    Now let me confirm the fix is still in place:

  106. MiniMax Assistant

    The fix is in place. Now let me re-run the tests to make sure they still pass:

  107. MiniMax Assistant

    All 343 tests pass. Let me also verify that the type compiles cleanly:

  108. MiniMax Assistant

    Let me also check the linting:

  109. MiniMax Assistant

    No lint errors. Now let me also think about whether the fix might miss any edge cases:

    1. Anthropic with two web_search tools: ✅ Fixed
    2. Anthropic with only LibreChat web_search (no LLM config): ✅ options.tools is empty, so mergedOptionsTools is empty, tools = structuredTools only
    3. Anthropic with only LLM web_search (no LibreChat): ✅ structuredTools is empty, lcToolNames is empty set, mergedOptionsTools = options.tools, tools = options.tools
    4. OpenAI with web_search (no name): ✅ Filter handles tools without name correctly
    5. Provider with tools that have no name: ✅ Filter handles them correctly
    6. Provider with multiple conflicting tools: ✅ Filter removes all conflicting ones
    7. Provider with mixed tools (some named, some not): ✅ Filter handles correctly

    Let me also write a test case to verify the actual fix works in the context of the test mocks:

  110. MiniMax Assistant

    The TS enum doesn't run directly. Let me simplify my test:

  111. MiniMax Assistant

    The fix works as expected. Now let me also think about what happens elsewhere. Let me look at the related code in @librechat/agents that might also need updating:

  112. MiniMax Assistant

    Good - no other places in the agents package do this concat. The fix is minimal and localized.

    Let me also think about whether the fix might affect the toolDefinitions array. Looking at the code:

    The toolDefinitions is used only via loadTools (which uses agent.tools as input), not from options.tools. The options.tools is only added to the agent.tools (i.e., tools array) via the concat at line 846.

    So the fix only needs to be in the tools array, not in toolDefinitions.

    Let me also check how the bindTools process works to make sure the fix doesn't break anything:

  113. MiniMax Assistant

    Good. The tools array (which is fixed) is what's used for binding.

    Now let me also make sure my fix doesn't break the case where options.tools could be Array<unknown>:

    Looking at the code:

    let tools: GenericTool[] = options.tools?.length
      ? (options.tools as GenericTool[])
      : (structuredTools ?? []);
    

    The options.tools is typed as unknown[] in InitializeResultBase. So the cast as GenericTool[] is already happening. My fix correctly handles this with as unknown[].

    Let me also verify the test runs successfully one more time:

  114. MiniMax Assistant

    Now let me also do a check to ensure the fix is minimal and clean:

  115. MiniMax Assistant

    The fix is clean and minimal. Let me also verify by checking the final state of the file:

  116. MiniMax Assistant

    Now let me cleanup my temporary files:

  117. MiniMax Assistant

    Let me also do a final validation by running the broader test suite once more:

  118. MiniMax Assistant

    All 516 tests pass. Let me also do the final TypeScript check:

  119. MiniMax Assistant

    Now let me also lint the modified file:

  120. MiniMax Assistant

    All checks pass. Let me also verify the fix doesn't change anything in the final test for the related tests:

  121. MiniMax Assistant

    All tests pass. Let me also check the test file for the agent initialize to see the test for the existing concat logic:

  122. MiniMax Assistant

    The existing tests for the GOOGLE_TOOL_CONFLICT logic still work. My fix is backward-compatible.

    Now let me check the final diff:

  123. MiniMax Assistant

    Only the file I intended to modify is changed. Let me view the final diff:

  124. MiniMax Assistant

    The fix is clean and minimal. Let me now go through the checklist:

    Checklist:

    1. If an error was reported in the issue description, I have successfully reproduced it.

      • ✅ Yes. I created a reproduction script that confirmed the issue: when both LibreChat's web_search and Anthropic's web_search_20250305 are enabled, both tools get concatenated with name: 'web_search', causing the duplicate.
    2. If an error was reported in the issue description, I have confirmed that my fix resolves the error.

      • ✅ Yes. After applying the fix, the reproduction script shows only one web_search tool is now exposed (LibreChat's, which is preferred).
    3. I have thought about edge cases and made sure my fix handles them as well.

      • ✅ Yes. I verified:
        • Anthropic with both web_search: Only LibreChat's is exposed (preferred)
        • Anthropic with only LibreChat web_search: works (no changes)
        • Anthropic with only LLM web_search: works (no changes)
        • Anthropic with non-conflicting tools: works (no changes)
        • OpenAI tools without name: passes through correctly (no name collision)
        • Tools with various shapes: properly handled via runtime type guards
        • Tools with non-string names: properly handled
        • Null/undefined tools: properly handled
    4. I have run existing tests in the repository that might have been affected by the change I made and confirmed that they pass.

      • ✅ Yes. I ran:
        • src/agents/__tests__/initialize.test.ts (34 tests pass)
        • src/agents/__tests__/load.spec.ts (passes)
        • src/agents/__tests__/skills.test.ts (passes)
        • src/agents/__tests__/handlers.spec.ts (40 tests pass)
        • src/agents/discovery.spec.ts (passes)
        • src/endpoints/anthropic (91 tests pass)
        • src/endpoints/openai (218 tests pass)
        • Total: 516 tests pass
      • I also verified the previous failures (17 test suites, 78 tests) are pre-existing and not related to my fix.

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