Tool Registry
~3 min read
Concept & How It Works
Why Does It Exist?
Hardcoding tools in every agent file doesn't scale. A registry enables dynamic registration, discovery, versioning, and permission control.
Real-World Analogy
A tool registry is a hardware store inventory system — every tool has a SKU, description, and location, and the clerk (agent) looks up what to fetch.
Visual Workflows
What is Tool Registry?
Example
Scenario
A registry holds 20 tools but the 'read-only analyst' agent only receives search_docs, run_sql_query (SELECT only), and generate_chart.
Solution
In Tool Calling & Function Calling, apply Tool Registry to this scenario: A registry holds 20 tools but the 'read-only analyst' agent only receives search_docs, run_sql_query (SELECT only), and generate_chart. Identify the inputs, run the technique, validate the output, and note one thing you would monitor in production.
Practice Task
Do this before moving to the next module — reading alone is not enough.
Open the Code Walkthrough below and run it locally. Change one parameter related to Tool Registry (e.g. model, temperature, top_k, or tool name), observe the difference in output, and write 2–3 sentences explaining what changed.
Code Walkthrough
Highlighted lines show where Tool Registry happens in the code.
1class ToolRegistry: # define a data structure or component2 def __init__(self): # define a reusable function3 self._tools = {} # key line for Tool Registry4 def register(self, name, schema, handler, roles=None): # define a reusable function5 self._tools[name] = {"schema": schema, "handler": handler, "roles": roles or ["*"]} # key line for Tool Registry6 def get_schemas(self, role="*"): # define a reusable function7 return [t["schema"] for t in self._tools.values() if role in t["roles"]] # return the result8 async def execute(self, name, args):9 return await self._tools[name]["handler"](**args) # return the resultCommands to Remember
Commands to Remember
client.chat.completions.create(..., tools=[...]) # pass tool schemas to APIjson.loads(response.choices[0].message.tool_calls[0].function.arguments) # parse tool argspip install pydantic # validate tool inputs with schemas
Common Mistakes
- Treating Tool Registry as a black box without evaluation
- Ignoring cost and latency in production
- Skipping error handling for tool registry
Cheat Sheet
Quick recap — the most important points from this module.
Cheat Sheet
quick ref- •Tool Registry
- •Tool Discovery
- •Handler
- •Role Filtering