Sub topic 3
Choosing clear, consistent tool names
This chapter assumes you have called an LLM API with tools before, can read JSON, and know the basic JSON Schema types. A tool name is the first thing the model reads about a tool. It shows up in the tool list, and the model writes it back in every call. A good name tells the model what the tool does before it reads the description. A bad name forces the model to guess.
What a name does
The model sees your tool list as text. For each tool it reads the name, the description, and the schema. When it decides to call a tool, it produces the exact name as output. Your code then matches that string against your registry.
This gives a name three jobs:
- It is a label the model uses to pick between tools.
- It is an identifier your code must match exactly.
- It is a clue about related tools. Names that share a pattern look like a family.
The description does most of the work of explaining a tool. The name decides how quickly the model sorts the tool into the right group, and it breaks ties when two descriptions look alike.
Rules for the name string
Provider APIs limit which characters a name can contain. A common limit is letters, digits, underscores, and hyphens, up to 64 characters. Check your provider's current documentation, because limits differ. See the chapter on provider differences for more.
Following the common subset keeps your tools portable:
- Use
snake_case. Pick it once and keep it. - Use only ASCII letters, digits, and underscores.
- Keep the name under about 40 characters.
- Do not use spaces, dots, or slashes.
If you plan to expose tools through more than one provider, a name that works everywhere saves you a rename later.
Verb plus noun
Name a tool for the action it performs and the thing it acts on. The form verb_noun works well.
| Weak name | Better name | Why |
|---|---|---|
| `do_order_thing` | `search_orders` | The verb and the object are explicit. |
| `orders` | `get_order` | A bare noun does not say whether the tool reads or writes. |
| `process` | `cancel_order` | "Process" could mean anything. |
| `helper_1` | `calculate_shipping_cost` | A number says nothing about purpose. |
| `OrderManagerV2` | `update_order_address` | Vague manager names hide what the tool does. |
The weak example from the spine, do_order_thing, is a good lesson. It names no action and no clear object. The model has to learn from the description, and that description is just "Handles orders."
Pick verbs with a fixed meaning
Verbs are where most inconsistency starts. If get_, fetch_, find_, and lookup_ all appear in one tool set, the model cannot tell whether they differ. Choose one verb for each kind of operation and use it everywhere.
A simple convention:
| Verb | Meaning | Example |
|---|---|---|
| `get_` | Fetch one item by a known ID. | `get_order` |
| `search_` | Find many items by filters. | `search_orders` |
| `list_` | Return all items in a small, fixed set. | `list_warehouses` |
| `create_` | Make a new item. | `create_refund` |
| `update_` | Change an existing item. | `update_order_address` |
| `cancel_` or `delete_` | Remove or stop an item. | `cancel_order` |
This matches the example definitions in this tutorial. get_order takes an ID. search_orders takes filters and returns a list. The model can infer that from the names alone. Write the convention down for your team. It is cheap to enforce in code review.
Make side effects visible
Some tools only read data. Others change it, send money, or email a customer. Put that difference in the name. A reader (and the model) should see get_order and know it is safe, and see cancel_order and know it has consequences.
Names that signal risk help in two ways. The model is less likely to call a destructive tool by accident. Your own code can also apply policy by name pattern, for example asking for human approval before any tool starting with cancel_, delete_, or send_.
RISKY_PREFIXES = ("cancel_", "delete_", "send_", "refund_")
def needs_approval(tool_name: str) -> bool:
return tool_name.startswith(RISKY_PREFIXES)
for name in ["get_order", "search_orders", "cancel_order", "send_receipt"]:
print(name, "->", "ask a human" if needs_approval(name) else "run directly")This only works if your names are consistent. A tool called order_cleanup that deletes data would slip past the rule. That is another reason to prefer an explicit verb.
Keep related tools aligned
When you have several tools in one area, share a noun and vary the verb, or share a prefix for the service. Both patterns help the model group them.
get_order
search_orders
cancel_order
update_order_addressFor larger systems with tools from several services, a short service prefix prevents collisions:
orders_get
orders_search
billing_get_invoice
billing_create_refundPick one style per tool set. Mixing get_order with orders_search in the same list weakens the pattern. Also keep nouns consistent in number. In the example above, get_order returns one item and search_orders returns many, and the plural carries that meaning. Whatever rule you choose, apply it everywhere.
Names that cause trouble
Avoid these patterns:
- Vague verbs.
handle,process,manage, anddocarry no meaning. - Internal jargon.
svc_ord_qmakes sense to the person who wrote it. The model sees only the string. - Near-duplicates.
get_orderandget_order_detailslook like the same tool. If they differ, name the difference, for exampleget_order_summaryandget_order_line_items. - Names that overpromise. A tool called
get_customer_profilethat only returns an email address will be called for the wrong reasons. - Version suffixes.
search_orders_v2leaves the model to choose between two versions. Remove the old tool from the list instead. - Abbreviations. Write
calculate_shipping_cost, notcalc_ship_cst.
A name cannot carry boundaries. If two tools are close, the description has to say when to use each one. The chapter on keeping similar tools distinguishable covers that.
Changing a name safely
A name is part of your contract with the model and with your code. If you rename a tool, update the tool list, the dispatcher, and any saved test cases together. Stored conversations that contain old tool calls may refer to the old name, so check how your provider handles history that mentions a tool that no longer exists.
A quick check helps catch mismatches. Make your dispatcher fail loudly when it receives an unknown name, and return a message that lists the valid ones.
TOOLS = {
"get_order": lambda args: {"id": args["order_id"], "status": "shipped"},
"search_orders": lambda args: {"orders": []},
}
def dispatch(name: str, args: dict) -> dict:
handler = TOOLS.get(name)
if handler is None:
return {
"is_error": True,
"message": f"Unknown tool {name!r}. Available tools: {sorted(TOOLS)}.",
}
return {"is_error": False, "result": handler(args)}
print(dispatch("get_order", {"order_id": "ord_1001"}))
print(dispatch("fetch_order", {"order_id": "ord_1001"}))Models rarely invent a name when the tool list is in context, but it can happen after a rename or with a very long tool list. A clear error lets the model correct itself.
Choosing names: a process
- List every tool and write what it does in one sentence.
- Choose the verb from your fixed set that matches the sentence.
- Add the noun the tool acts on. Use the same word for the same thing across tools.
- Read the whole list as one block. Look for pairs that sound alike.
- Check that every name is within the character limits.
- Run your selection test cases (covered in the last chapter) and rename any tool the model confuses.
Summary
- Use
verb_nouninsnake_case, within provider character limits. - Give each verb one meaning across the whole tool set.
- Show side effects in the name so both the model and your policy code can see them.
- Keep related tools aligned and avoid near-duplicates, vague verbs, and version suffixes.
- Let descriptions carry boundaries, and use names to give the model a first, quick sort.
Exercise
A tool set contains get_order, fetch_orders, order_lookup, and process_order. The last one cancels an order. Rename them to follow the conventions in this chapter. State which tool takes an ID and which takes filters.
Show answer
Use get_order for the lookup by ID, search_orders for the filter-based tool (replacing fetch_orders), and cancel_order for the one that cancels (replacing process_order). order_lookup duplicates get_order, so remove it or merge it into get_order. get_order takes an ID. search_orders takes filters such as status and date. The verbs now each have one meaning, and cancel_order shows its side effect.
Exercise
Your policy code asks for human approval when a tool name starts with cancel_, delete_, or send_. A teammate adds a tool called order_cleanup that deletes old orders. What goes wrong, and what is the fix?
Show answer
The name does not start with a risky prefix, so needs_approval returns false and the tool runs without approval. The fix is to rename it with an explicit verb, for example delete_old_orders, so the prefix rule applies. Also keep server-side permission checks, because name rules alone are not a safety control.