Sub topic 6
Describing each parameter so the model fills it correctly
This chapter assumes you can read JSON Schema (string, integer, object, array), have called an LLM API with tools before, and can read short Python examples. It focuses on one part of a tool definition: the description field on each parameter.
Why parameter descriptions matter
The model never sees your code. It sees the tool name, the tool description, and the schema. When it decides what to put in each argument, the parameter description is the main place it learns what the value means.
A type such as "type": "string" tells the model only that the value is text. It does not say whether the text is an ID, a date, a search phrase, or a sentence for the user. The model guesses, and the guesses vary between runs and between models.
Compare the two tool definitions from this tutorial. The weak one has parameters named data and mode, each typed as a string with no description. The model has to invent what goes in them. The strong one, search_orders, tells the model the shape and meaning of every value.
What a good parameter description contains
A useful description answers some or all of these questions. Not every parameter needs every answer. Add each one when a wrong guess is plausible.
- What the value is. Say "Customer ID", not "ID".
- The format. Give the exact pattern, such as
YYYY-MM-DD. - An example. Show one realistic value, such as
'cus_4821'. - What to do if the value is unknown. For example, "Ask the user if you do not know it."
- What omitting it means. For an optional parameter, state the default or the effect of leaving it out.
- Units and limits when they are not obvious, such as cents versus dollars, or an inclusive date boundary.
Here is the definition from the topic's first example again. Look at how each description covers a different question.
{
"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"]
}
}The table below maps each parameter to what its description does.
| Parameter | What the description tells the model |
|---|---|
| `customer_id` | What the value is, a concrete example, and what to do when it is missing |
| `status` | The effect of the filter and what omitting it means |
| `created_after` | The format, and that the boundary is inclusive ("on or after") |
| `limit` | The meaning, the default, with the range left to the schema |
Notice that the limit description does not repeat "between 1 and 50". The minimum and maximum keywords already say that. Repeating constraints in prose is harmless but adds tokens, and the two copies can drift apart when someone edits only one.
Do not restate what the schema already says
Descriptions and schema keywords do different jobs. Put hard rules in the schema and put meaning in the description.
- Use
enumfor a closed list of values. The description then explains what the filter does, not which values exist. - Use
minimum,maximum,minLength, andpatternfor limits the validator can check. - Use the description for things a schema cannot express: what the value represents, where to get it, and what happens when it is omitted.
A description such as "A string" for a string-typed parameter adds nothing. Either say something the schema does not, or leave the description out only when the name and type are truly self-evident, such as a boolean named include_archived.
Behavior guidance: where the value comes from
Models often fail because they do not know whether to invent a value, ask the user, or call another tool. The parameter description is a good place to say which.
{
"customer_id": {
"type": "string",
"description": "Customer ID, for example 'cus_4821'. Never guess this. If the user has not given it, ask them for it."
}
}A related pattern points to another tool as the source of a value:
{
"order_id": {
"type": "string",
"description": "Order ID, for example 'ord_1001'. If you only have a description of the order, call search_orders to find the ID first."
}
}This ties the parameter to the tool-selection guidance from earlier chapters. The model can build a chain of calls without you writing the chain.
Formats the model gets wrong
Some formats cause repeated trouble. State them explicitly.
- Dates and times. Say
YYYY-MM-DDor "ISO 8601 with timezone, for example 2026-03-01T09:30:00Z". Without this, the model may send "last Tuesday" or "03/01/2026". If the model needs to turn "last month" into a date, it also needs to know today's date, which usually belongs in the system prompt. - Money. Say whether amounts are in dollars or in the smallest unit (cents), and name the currency field if there is one.
- Identifiers. Show the prefix and shape, such as
ord_1001. The model will often copy a pattern it has been shown. - Lists. For arrays, say what each item is and whether order matters.
- Free text. For a search query, say whether to send keywords or a full sentence.
{
"amount_cents": {
"type": "integer",
"minimum": 1,
"description": "Refund amount in cents, not dollars. For example, 1250 means $12.50."
}
}A weak description and its repair
Here is a vague parameter, followed by a repaired one.
{
"date": {
"type": "string",
"description": "The date."
}
}This leaves several questions open. Which date? What format? Is it a start, an end, or an exact match? Is it required?
{
"created_after": {
"type": "string",
"description": "Only return orders created on or after this date, in YYYY-MM-DD format. Omit to search all dates."
}
}The fix does three things. The name now says which date it is. The description gives the format and the boundary. It also says what happens if the parameter is left out.
The server must still check the value
A description is a request, not a guarantee. The model can send "cus 4821", a date in the wrong format, or an ID it made up. Treat every argument as untrusted input and check it on the server. A later chapter covers validation in full. The point here is that good descriptions reduce errors but do not remove them.
The topic's third example shows the pattern. The tool checks the ID and returns a message that tells the model what to do next.
ORDERS = {
"ord_1001": {"id": "ord_1001", "status": "shipped", "total": 42.5},
}
def get_order(order_id: str) -> dict:
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'. "
"If you do not have an ID, call search_orders first."
),
}
order = ORDERS.get(order_id)
if order is None:
return {
"is_error": True,
"message": f"No order found with id {order_id!r}. Check the ID with the user or use search_orders.",
}
return {"is_error": False, "order": order}The error message repeats the format from the parameter description ("IDs look like 'ord_1001'"). That repetition is useful here. The description helps the model get it right the first time, and the error message helps it correct itself on the second.
Common mistakes
| Mistake | Effect | Fix |
|---|---|---|
| No description on a string parameter | Model guesses the meaning and format | Add what, format, and an example |
| Description restates the type ("A string") | Wastes tokens, no help | Say what the value represents |
| Format given only in the tool description | Model skips it when filling the parameter | Put the format on the parameter itself |
| No guidance on unknown values | Model invents an ID or date | Say "ask the user" or name the tool that finds it |
| Optional parameter with no default stated | Model fills it needlessly or leaves it out wrongly | State what omitting it does |
| Very long parameter descriptions | Cost grows on every request | Keep each to one or two sentences |
Keep descriptions short
Every description is sent with every request that includes the tool. A paragraph per parameter across ten tools adds up. Aim for one or two sentences. If a parameter needs more, check whether the tool is trying to do too much, or whether the extra rules belong in an enum or a second tool.
Checklist
Before shipping a tool, read each parameter as if you had never seen your own API. For each one, ask:
- Could I tell what this value is without seeing the code?
- Do I know the exact format and see an example when one helps?
- Do I know what to do if I do not have it?
- If it is optional, do I know what leaving it out means?
- Is every rule that a validator can check also in the schema?
If a question has no answer in the schema or description, the model is guessing. Add the missing line and test it, as the evaluation chapter later shows.
Exercise
A tool create_refund has a parameter amount with type number and the description "The amount." Users report that refunds for $12.50 sometimes arrive as $1250.00. Rewrite the parameter definition so this stops happening, and name the two pieces of information the new description must include.
Show answer
Change the parameter to an integer in the smallest currency unit and say so. For example: "amountcents": {"type": "integer", "minimum": 1, "description": "Refund amount in cents, not dollars. For example, 1250 means $12.50."}. The description must state the unit (cents versus dollars) and give a worked example of the conversion. Renaming to amountcents also helps, because the name itself carries the unit. The server should still reject amounts above the original order total.
Exercise
The parameter order_id on get_order often receives invented values like "12345" when the user only said "my last order". Which two additions to the parameter description would reduce this, and where should the check for a bad value live?
Show answer
Add the ID format with an example ("Order ID, for example 'ord1001'") and a source instruction ("If you only have a description of the order, call searchorders to find the ID first. Never guess."). The check for a bad value must live on the server, in getorder, which returns an error such as "Invalid orderid '12345'. IDs look like 'ord1001'. If you do not have an ID, call searchorders first." The description lowers the error rate, and the server check catches what remains.