Sub topic 2
The parts of a tool definition: name, description, input schema
This chapter assumes you have called an LLM API before, can read JSON and short Python examples, and know the basic JSON Schema types (string, integer, object, array). It covers the three parts of a tool definition and what each one does for the model. Later chapters go deeper on each part.
What the model actually receives
A tool definition is a small JSON object that you send with each request. The model never sees your code. It sees only the definition, so the definition is the whole interface from the model's point of view.
The model reads the definitions and decides whether to call a tool. If it does, it writes a tool name and a JSON arguments object. Your application then runs the real function and sends the result back.
Each of the three parts of a definition has a different job:
| Part | Question it answers for the model | Failure when it is weak |
|---|---|---|
| Name | Which tool is this, and what family does it belong to? | The model confuses tools or ignores them |
| Description | What does it do, when should I use it, and when should I not? | The model picks the wrong tool or never picks it |
| Input schema | What arguments can I send, and in what shape? | The model sends malformed or invented arguments |
A complete definition
Here is a definition in the Anthropic-style layout. The schema field is called input_schema.
{
"name": "search_orders",
"description": "Search a customer's orders by status and date. Use this when the user does not give an order ID. If the user gives an order ID, use get_order instead. Returns up to `limit` orders, newest first, each with id, status, total, and created_at.",
"input_schema": {
"type": "object",
"properties": {
"customer_id": {
"type": "string",
"description": "Customer ID, for example 'cus_4821'. Ask the user if you do not know it."
},
"status": {
"type": "string",
"enum": ["pending", "shipped", "delivered", "cancelled"],
"description": "Only return orders with this status. Omit to include all statuses."
},
"created_after": {
"type": "string",
"description": "Only return orders created on or after this date, in YYYY-MM-DD format."
},
"limit": {
"type": "integer",
"minimum": 1,
"maximum": 50,
"description": "Maximum number of orders to return. Defaults to 10 if omitted."
}
},
"required": ["customer_id"]
}
}Read it as the model would. The name says the domain (orders) and the action (search). The description says when to use it, when to use a sibling tool instead, and what comes back. The schema lists four parameters, constrains two of them, and marks one as required.
The name
The name is the identifier the model writes when it calls the tool. Your code uses the same string to route the call to a function.
Most providers restrict names to letters, digits, underscores, and hyphens, with a length cap (often 64 characters). Check your provider's current limits.
Within those limits, good names have three traits:
- They are specific verb-and-noun pairs, such as
get_orderorsearch_orders. - They follow one convention across all your tools, for example
verb_nounin snake_case. - They describe the tool's job rather than your internal code, so
do_order_thingis worse thancancel_order.
The name is also a signal the model weighs early, before it reads long descriptions. A vague name starts the model off with a wrong or weak idea of the tool.
The description
The description is the most influential field. It is plain prose that the model reads to decide whether the tool fits the user's request.
A useful description answers four questions in a few sentences:
- What does the tool do?
- When should the model use it?
- When should the model not use it, and what should it use instead?
- What does it return?
In search_orders, the sentence "If the user gives an order ID, use get_order instead" draws a boundary. Without it, the model may call the search tool for a request that a direct lookup would answer better.
Descriptions that restate the name ("Searches orders") add nothing. Descriptions that run to several paragraphs cost tokens on every request, because the whole definition is sent each time. Aim for the shortest text that still states purpose and boundary.
The input schema
The input schema is a JSON Schema object that describes the arguments. The top level should be "type": "object". Its properties map each parameter name to a type and optional constraints.
These keywords do most of the work:
| Keyword | Effect | Example from `search_orders` |
|---|---|---|
| `type` | Sets the JSON type of the value | `"type": "integer"` for `limit` |
| `enum` | Restricts a value to a fixed list | The four values for `status` |
| `minimum` / `maximum` | Bounds a number | `limit` from 1 to 50 |
| `required` | Lists parameters the model must supply | `["customer_id"]` |
| `description` | Explains the parameter in prose | Format and default for `created_after` |
Each parameter has its own description, and that text matters as much as the tool-level one. It is where you state formats ("YYYY-MM-DD"), defaults ("Defaults to 10"), and what to do when the value is unknown ("Ask the user").
The schema narrows what the model is likely to send, but it does not guarantee valid input. Some providers enforce schemas strictly, and others treat them as guidance. Either way, your server must still check the arguments, which a later chapter covers.
A weak definition for contrast
Compare the definition above with this one.
{
"name": "do_order_thing",
"description": "Handles orders.",
"input_schema": {
"type": "object",
"properties": {
"data": { "type": "string" },
"mode": { "type": "string" }
}
}
}Every part fails. The name does not say which action it performs. The description gives no use and no boundary. The schema has two untyped free-text parameters, data and mode, with no required list. The model has to guess what to put in data and which strings mode accepts. It will guess differently across requests, and some of the guesses will be wrong.
Provider layouts differ in field names
The three parts exist everywhere, but the wrapper changes. Anthropic uses name, description, and input_schema. OpenAI-style APIs nest the same content in a function object and call the schema field parameters. Treat this as a rename. The design advice in this chapter applies to both. A later chapter covers differences in schema features.
Checklist for a first draft
Before you ship a definition, check each part:
- The name is a specific verb-and-noun pair that matches your other tools.
- The description states what the tool does, when to use it, when not to, and what it returns.
- Every parameter has a type, and a description when the type alone leaves room for guessing.
- Fixed choices use
enum, and numbers have bounds. - Only the parameters the tool cannot work without are in
required.
Exercise
A teammate writes a tool named process with the description "Processes the request" and one string parameter called input. Name the three parts of the definition and say one concrete change for each that would help the model.
Show answer
The parts are the name, the description, and the input schema. Name: rename process to a verb-and-noun pair that says the action, such as refund_order. Description: state what the tool does, when to use it, when to use a different tool, and what it returns, for example "Refund a delivered order. Use this only after the user confirms. Returns the refund id and amount." Input schema: replace the single free-text input with typed, described parameters such as order_id (string, format ord_1001) and reason (string with an enum), and list order_id under required.
Exercise
Why does the search_orders description mention get_order, and what could go wrong if it did not?
Show answer
It draws a boundary: use search_orders when no order ID is given and use get_order when one is. Without that sentence, the model could call the search tool for requests that name a specific order, which is slower and returns more data than needed. It could also call get_order with a made-up ID when the user gave none.