Problem
Whenever a developer wants to connect a single AgentCore Runtime to more than one AgentCore Gateway, they will encounter a tool identifier collision.
By design, AgentCore Gateways automatically inject built-in infrastructure tools (such as the x_amz_bedrock_agentcore_search semantic search tool). If a developer merges tools from multiple gateways and passes them directly to the Agent constructor, the framework crashes with a ValueError: Tool name already exists.
While a prominent use case for this is building advanced multi-agent architectures (e.g., separating a "DomainSpecific" gateway from a "SharedUtility" gateway to achieve high cohesion), this issue fundamentally affects any implementation attempting to consume multiple gateways simultaneously.
Proposed Solution
I have already implemented a solution for this, and I will be submitting a Pull Request shortly to contribute it to the repository.
My PR will add a new sample under 01-features/07-centralize-and-govern-your-ai-infrastructure/01-gateway/04-advanced-concepts/multi-gateway-tool-deduplication/.
The sample contains:
- A comprehensive
README.md explaining the problem, the architectural context, and the exact error.
- A standalone
deduplicate.py script demonstrating how to cleanly deduplicate tools by name before Agent initialization, preserving the original object and deeply logging the discarded duplicates.
Problem
Whenever a developer wants to connect a single AgentCore Runtime to more than one AgentCore Gateway, they will encounter a tool identifier collision.
By design, AgentCore Gateways automatically inject built-in infrastructure tools (such as the
x_amz_bedrock_agentcore_searchsemantic search tool). If a developer merges tools from multiple gateways and passes them directly to theAgentconstructor, the framework crashes with aValueError: Tool name already exists.While a prominent use case for this is building advanced multi-agent architectures (e.g., separating a "DomainSpecific" gateway from a "SharedUtility" gateway to achieve high cohesion), this issue fundamentally affects any implementation attempting to consume multiple gateways simultaneously.
Proposed Solution
I have already implemented a solution for this, and I will be submitting a Pull Request shortly to contribute it to the repository.
My PR will add a new sample under
01-features/07-centralize-and-govern-your-ai-infrastructure/01-gateway/04-advanced-concepts/multi-gateway-tool-deduplication/.The sample contains:
README.mdexplaining the problem, the architectural context, and the exact error.deduplicate.pyscript demonstrating how to cleanly deduplicate tools by name before Agent initialization, preserving the original object and deeply logging the discarded duplicates.