Context
Systems with multiple tool providers.
Problem
Agents shouldn't need to know which backend serves which tool.
Solution
Implement a gateway:
- Single entry point: All tools through one interface
- Backend routing: Gateway routes to correct provider
- Protocol translation: Handle different formats
- Aggregated discovery: List all tools from all backends
- Single entry point: All tools through one interface
- Backend routing: Gateway routes to correct provider
- Protocol translation: Handle different formats
- Aggregated discovery: List all tools from all backends
Examples
Python
class ToolGateway:
"""Unified interface to multiple tool backends."""
def __init__(self, backends: list[ToolBackend]):
self.backends = backends
self.tool_index = self._build_index()
def list_tools(self) -> list[ToolInfo]:
"""List all available tools across backends."""
return [tool for backend in self.backends
for tool in backend.list_tools()]
def execute(self, tool_name: str, params: dict) -> Result:
"""Route tool call to appropriate backend."""
backend = self.tool_index.get(tool_name)
if not backend:
raise ToolNotFound(tool_name)
return backend.execute(tool_name, params) Considerations
- Handle backend failures gracefully
- Cache tool listings appropriately
- Monitor cross-backend latency