fix(tools): deduplicate tool names at API boundary for Vertex/Azure/Bedrock#18532
Closed
liuhao1024 wants to merge 1 commit into
Closed
fix(tools): deduplicate tool names at API boundary for Vertex/Azure/Bedrock#18532liuhao1024 wants to merge 1 commit into
liuhao1024 wants to merge 1 commit into
Conversation
…edrock Providers like Google Vertex, Azure, and Amazon Bedrock reject API requests with duplicate tool names (HTTP 400: 'Tool names must be unique'). The upstream injection paths in run_agent.py already dedup after PR NousResearch#17335, but two API-boundary functions pass tools through without checking: - agent/auxiliary_client.py: _build_call_kwargs() (all non-Anthropic providers in chat_completions mode) - agent/anthropic_adapter.py: convert_tools_to_anthropic() (Anthropic Messages API path) Add defensive dedup guards at both sites. Duplicates are dropped with a warning log, converting a hard 400 failure into a recoverable condition. This is intentionally conservative — the root-cause dedup in run_agent.py is the primary defense; these guards add resilience against future injection-path regressions. Includes 8 new tests covering unique passthrough, duplicate removal, empty/None edge cases. Closes NousResearch#18478
Collaborator
Contributor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Add defensive dedup guards at two API-boundary functions that pass tool schemas to providers without checking for duplicate names. Providers like Google Vertex, Azure, and Amazon Bedrock reject requests with duplicate tool names (HTTP 400:
Tool names must be unique).Root cause context: The upstream injection paths in
run_agent.pyalready dedup after PR #17335, but two last-mile functions pass tools through without any safety net:agent/auxiliary_client.py: _build_call_kwargs()— all non-Anthropic providers inchat_completionsmodeagent/anthropic_adapter.py: convert_tools_to_anthropic()— Anthropic Messages API pathIf any upstream injection path regresses (plugin re-registration, cache poisoning, context engine re-init), duplicates reach the API and produce silent 400 failures that exhaust the fallback chain.
Changes
agent/auxiliary_client.py_build_call_kwargs()beforekwargs["tools"] = toolsagent/anthropic_adapter.pyconvert_tools_to_anthropic()looptests/agent/test_auxiliary_client.pytests/agent/test_anthropic_adapter.pyDesign Decisions
logger.warning(), not raising errors. The root-cause dedup inrun_agent.pyis the primary defense; these guards convert a hard 400 failure into a recoverable condition.Test Plan
Related
run_agent.py)