Sub topic 9
Choosing how many tools and how much each does
This chapter assumes you have read the earlier chapters on the parts of a tool definition. It also assumes you can read JSON Schema and short Python examples. The question here is how to divide your application's capabilities into tools: how many to expose, and how much each one should do.
Why granularity matters
The model sees every tool definition on every request. Each definition costs tokens and adds one more option to choose from. Each tool's schema also limits what the model can send. Your split therefore affects three things:
- Selection accuracy. More tools with similar jobs means more wrong picks.
- Argument accuracy. A schema that covers many behaviors is harder to fill in correctly.
- Control. You can only permit, confirm, or log at the level of a tool.
You can go wrong in either direction.
| Row | Too broad | Too narrow |
|---|---|---|
| Typical shape | One `manage_orders` tool with an `action` parameter | One tool per field or per endpoint |
| Schema | Many optional fields, each valid for only some actions | Tiny, clean schemas |
| Model's job | Pick valid field combinations | Pick among many near-identical tools, then chain calls |
| Description | Long, covers several behaviors | Short, but repeated across tools |
| Safety | Cannot allow reads and block writes | Fine control, but many definitions to maintain |
| Context cost | One large definition | Many definitions |
Too broad: the do-everything tool
Here is a tool that looks tidy but pushes the real design work onto the model:
{
"name": "manage_orders",
"description": "Look up, search, or cancel orders.",
"input_schema": {
"type": "object",
"properties": {
"action": { "type": "string", "enum": ["get", "search", "cancel"] },
"order_id": { "type": "string" },
"customer_id": { "type": "string" },
"status": { "type": "string" },
"reason": { "type": "string" }
},
"required": ["action"]
}
}The schema cannot say that order_id is required for get and cancel but meaningless for search. It cannot say that reason belongs only to cancel. Both rules end up in the description, where the model may ignore them. Your server then has to catch every invalid combination.
The tool also mixes a harmless read with a destructive write. If you want the user to confirm cancellations, or to run a read-only assistant, you have nothing to attach that rule to.
Split it by what the call does:
get_order(order_id)search_orders(customer_id, status, created_after, limit)cancel_order(order_id, reason)
Each schema now matches one job, and each required field is always required.
An action enum is not always wrong. If every action takes the same inputs, such as format set to csv, json, or xml, an enum is just a parameter. The warning sign is fields that are valid only for some values.
Too narrow: one tool per endpoint
Over-splitting is the opposite mistake. Suppose your backend has GET /orders/{id}/status, /total, /items, and /shipment. Exposing four tools forces the model to pick among them and often to call several in a row for one question. Every extra call is another round trip through the tool-calling loop, with its own latency, token cost, and chance of error.
Design tools around tasks the model needs to finish, not around your internal API. A user asking "where is my order?" needs status and shipment together. One tool can gather them:
def fetch_order(order_id: str) -> dict:
return {"id": order_id, "status": "shipped", "total": 42.5}
def fetch_shipment(order_id: str) -> dict:
return {"carrier": "UPS", "eta": "2026-12-02"}
def get_order(order_id: str) -> dict:
"""Task-shaped tool: one call returns what the model needs to answer."""
if not isinstance(order_id, str) or not order_id.startswith("ord_"):
return {
"is_error": True,
"message": f"Invalid order_id {order_id!r}. IDs look like 'ord_1001'.",
}
order = fetch_order(order_id)
shipment = fetch_shipment(order_id)
return {
"is_error": False,
"order": {
"id": order["id"],
"status": order["status"],
"total": order["total"],
"carrier": shipment["carrier"],
"eta": shipment["eta"],
},
}
print(get_order("ord_1001"))Your code makes two backend calls, and the model makes one tool call. Combining steps your code can do without the model's judgment is almost always a good trade.
Heuristics for drawing the lines
- One job per tool. If the one-sentence description needs "and" or "or" between different actions, consider splitting.
- Split when required inputs differ. If two behaviors need different required fields, a single schema cannot express that cleanly.
- Split by risk. Keep reads, reversible writes, and destructive actions in separate tools. You can then require confirmation or withhold permission per tool.
- Merge fixed sequences. If the model always calls B right after A with A's output, and no decision happens in between, fold them into one tool.
- Keep decision points visible. If the model should choose whether to continue, as with a search followed by a choice among results, keep the steps separate.
- Name tools by task. Choose names like
get_orderandsearch_ordersoverorder_endpoint_2.
The diagram turns these rules into a decision path.
How many tools is too many?
There is no universal limit. Selection accuracy tends to fall as the list grows, especially when tools overlap, and each definition adds to the context cost of every request. Treat any number you read elsewhere as a starting point and measure on your own prompts, as the testing chapter describes.
If a large set is unavoidable, there are three common options:
- Expose only the tools relevant to the current task or conversation stage.
- Give separate agents or sub-tasks their own small tool sets.
- Group related capabilities behind a retrieval step that loads definitions on demand, if your platform supports it.
Fewer visible tools also shrink the attack surface when a prompt injection tries to push the model toward a tool it should not use.
Edge cases
- Variants of one task. If two tools differ only by a filter (
search_pending_ordersandsearch_shipped_orders), merge them and use an enum onstatus, as insearch_orders. - Cross-field rules. JSON Schema can express "if X then Y is required" with
oneOforif/then, but providers differ in how much of it they accept. Prefer separate tools when a rule depends on such features. - Wide results. A merged tool can return too much data. Return the fields the model needs and offer a
limit, rather than dumping every backend field. - Partial failure. A merged tool that calls two backends can fail on one. Return what succeeded and say what failed, so the model can continue.
Exercise
A support assistant has four tools: get_ticket_status(ticket_id), get_ticket_assignee(ticket_id), get_ticket_priority(ticket_id), and close_ticket(ticket_id, resolution). The model usually calls the first three together. How would you redesign the set, and why?
Show answer
Merge the three read tools into one get_ticket(ticket_id) that returns status, assignee, and priority, because they take the same input, are always called together, and need no decision between calls. Keep close_ticket separate, because it is a destructive write with a different required input (resolution) and may need confirmation or a separate permission. The result is two tools, each with one job.