AI Agents in Production · Lesson 3 of 14 · 2 min read · 6 min video
Designing reliable tools
Clear schemas, helpful errors and idempotent actions, so the model uses tools correctly.
📄 Download slides (PDF)The model never sees your code. It sees only each tool's name, description and parameters. Most "the agent did something dumb" bugs are really tool design bugs.
Write tools for a new colleague
Describe each tool as if explaining it to a smart new hire on day one:
- Name: a clear verb and noun:
find_order, notord_lkp - Description: what it does, when to use it, and when not to
- Parameters: typed, with formats and examples: "phone: 10-digit Indian mobile, no +91"
find_order = {
"name": "find_order",
"description": "Look up a customer's most recent orders by phone number. "
"Use this before answering any question about an order's status. "
"Do not use it to change an order.",
"parameters": {
"type": "object",
"properties": {
"phone": {"type": "string", "pattern": "^[6-9][0-9]{9}$",
"description": "10-digit mobile, e.g. 9876543210"}
},
"required": ["phone"],
},
}Errors the model can act on
When a tool fails, return a message that says what went wrong and what to do next, not a stack trace:
- Bad:
KeyError: 'phone' - Good:
No order found for 98765 43210. Ask the customer to confirm the number or share the order ID.
The model reads that and recovers. A stack trace just confuses it.
Make actions idempotent
An idempotent action gives the same result if it runs twice. Agents retry, networks drop and loops repeat, so this matters:
- Pass an idempotency key (like the task ID) with every payment, booking or email
- The server ignores a second request with the same key
That way a retry never charges a customer twice.
Fewer, sharper tools
Twenty overlapping tools confuse the model. Merge similar ones, remove unused ones, and keep each tool's results short: return the five fields the model needs, not the whole database row.
In one line
Good tools have clear names, honest descriptions, strict parameters, helpful errors and idempotent actions, because the description is all the model sees.
Share with a friend