Sub topic 9
Choosing how many tools and how much each does
This chapter assumes you know the tool-calling loop and the parts of a tool definition (name, description, input schema). It covers how to decide where one tool ends and the next begins.
Two ways to get granularity wrong
Granularity is how much work one tool does. There are two failure modes.
A tool that is too broad hides several jobs behind one name. Usually it has a mode or action parameter, and which other parameters apply depends on its value:
{
"name": "manage_orders",
"description": "Gets, searches, cancels, or refunds orders.",
"input_schema": {
"type": "object",
"properties": {
"action": { "type": "string", "enum": ["get", "search", "cancel", "refund"] },
"order_id": { "type": "string" },
"customer_id": { "type": "string" },
"status": { "type": "string" },
"amount": { "type": "number" }
},
"required": ["action"]
}
}JSON Schema cannot easily say "amount only matters for refund". The model has to guess which fields go with which action. You also cannot grant or restrict permissions per action, because a single tool covers a read and a destructive write.
A tool that is too narrow forces the model to chain many calls for one task. Each call is another round trip, and each step is another chance to pick the wrong tool or pass a stale value. Three tools called get_order_status, get_order_total, and get_order_date should be one get_order.
A working rule: one tool per intent
Give each tool one intent that the model can name in a sentence, such as "look up one order by ID" or "search orders by filters". This is the split used earlier in the tutorial with get_order and search_orders. Each tool has a small schema, and each description can state when to use it.
| Signal | Action |
|---|---|
| Parameters only apply in some modes | Split into separate tools |
| Read and write operations share a tool | Split, so you can gate the write |
| Tools are always called back to back with the same inputs | Merge, or have the server do the chaining |
| Tools differ only by one filter value | Merge and use an enum parameter |
| Tool needs a parameter the model cannot know yet | Keep a separate lookup tool |
How many tools is too many
Every definition is sent with each request, so more tools means more tokens and more candidates to confuse. Selection accuracy tends to fall as the list grows, and the exact number depends on the model and on how distinct the tools are. Treat a few dozen similar tools as a warning sign. If you reach that point, expose only the tools relevant to the current task or user role, rather than everything you have built.
Exercise
A tool files takes action ("read", "write", "delete") plus path and content. content is only used by "write". Name two problems with this design and describe a better one.
Show answer
The model must guess that content belongs only to "write", and read and delete cannot be permissioned separately from write. Split it into read_file(path), write_file(path, content), and delete_file(path), so each schema is accurate and you can require approval for the destructive tools.