· 9 min read · Aravind Baranitharan
tools for agents.
An agent is only as good as the tools it can call. How to design tools a model can actually use: names, descriptions, inputs, outputs, errors, permissions and MCP.
- AI agents
- Tool design
- MCP
- Architecture
Most agent failures I see aren't the model being dumb. They're the model being handed a tool it can't use well: a vague description, an input it has to guess, a 40,000-token response, or an error that says 500 and nothing else. Tools are a user interface, and the user is a model.
We've spent decades learning to design APIs for developers who read docs, keep state in their heads and retry thoughtfully. A model reads only what's in its context, sees each tool through a name, a paragraph and a schema, and will try whatever you allow. These are my notes on designing for that user. Every section is open for feedback at the bottom.
A tool is a contract the model reads
Everything the model knows about a tool comes from four things: its name, its description, its input schema, and the results and errors it has seen so far. There's no hover text, no Stack Overflow, no colleague to ask. If it isn't in the contract, it doesn't exist.
Fewer, task-shaped tools
The instinct is to wrap every API endpoint as a tool. That makes the model do the orchestration: list users, then get each user, then list their orders, then filter. Each step costs a call, tokens and a chance to go wrong.
- Shape tools around tasks, not endpoints.
find_customer_orders(email)beatslist_customersplusget_customerpluslist_orders. - Fewer tools, less confusion. Every tool definition costs tokens on every call, and similar tools get mixed up. If two tools overlap, merge them or make the difference obvious in the names.
- Namespace by service.
github_create_issueandjira_create_issueare unambiguous; two tools calledcreate_issueare not. - Load tools by phase. A planning step doesn't need the deploy tools. See context engineering.
Inputs and outputs
- Make inputs hard to get wrong. Enums instead of free strings, clear names (
user_email, notuser), sensible defaults, and validation that explains what was wrong. - Return what the next step needs, not everything you have. Human-readable fields first, IDs the model will need for follow-up calls, and nothing else by default.
- Paginate and cap. A list tool returns at most N items with a cursor. Never let one result flood the window.
- Offer a detail level. A
concisedefault and adetailedoption lets the model ask for more only when it needs it. - Prefer meaning over identifiers. A name and status the model can reason about beat an opaque UUID it can only copy.
Errors that teach
An error message is the model's only chance to recover, so treat it as instructions. Compare:
Error 400tells the model nothing. It will retry the same call, or guess.No customer found with email "jo@acme.io". Try search_customers with a partial name, or ask the user to confirm the email.tells it exactly what to do next.
Good errors say what went wrong, why, and what to try instead. They turn a dead end into a next step, and they're one of the cheapest reliability wins in agent work.
Permissions and side effects
- Classify every tool. Read-only, reversible write, or destructive. MCP lets a server mark tools with hints like read-only or destructive, so clients can decide what needs confirmation.
- Gate the dangerous ones. Deleting data, sending external messages, spending money and merging code should pause for a human, as in the governor from long-horizon tasks.
- Make writes idempotent. Agents retry. An idempotency key means a retried
create_refunddoesn't refund twice. - Least privilege. Scope credentials to what the agent needs, per user and per task.
- Tool results are untrusted input. A web page, email or ticket can contain text that looks like instructions. Simon Willison calls the dangerous combination the lethal trifecta: access to private data, exposure to untrusted content, and a way to send data out. Don't give one agent all three without a human in the loop.
Anatomy of a tool call
Here is what happens between the model deciding to call a tool and the result landing back in its context, and where each design decision lives.
- 01
Model
Sees names, descriptions, schemas and results, and nothing else. Every design choice below is about what lands in front of it.
- 02
The contract
Name, a description that says when to use it and what it returns, typed inputs, a lean output, errors that teach, and hints like read-only or idempotent.
- 03
MCP server
The Model Context Protocol lets you write tools once and use them from any client. In the Figma-to-code agent, a remote MCP server built with FastMCP exposed the generator as tools inside Cursor and GitHub Copilot, so people used it where they already worked.
- 04
Validate
Check the schema, the caller's permissions and rate limits before anything runs. Reject with a helpful error, not a stack trace.
- 05
Gate
Read-only calls run. Destructive ones wait for confirmation, with a clear summary of what will happen.
- 06
Execute
In a sandbox, with a timeout and an idempotency key, and logged with enough detail to replay.
- 07
Shape result
Trim, paginate and format before returning. The result goes back into context, so it is treated as data, never as instructions.
Test tools with the model
Unit tests tell you the tool works. They don't tell you the model can use it. For that:
- Run real tasks and read the transcripts. Where does the model hesitate, pick the wrong tool, or pass a bad argument? That's a description or schema problem.
- Track tool-level metrics: call errors, retries, wrong-tool rate, and tokens per result.
- Let a model critique the tools. Hand it the definitions and failed transcripts and ask what was confusing. It's often right.
- Re-run your [evals](/blog/evaluating-agents) after every tool change. A one-word change to a description can move success rates.
Open questions
- How many tools is too many before selection quality drops, and does tool search fix it?
- Should tools return prose or structure? Models read prose well; code and other tools prefer structure.
- Who owns tool descriptions: the team that owns the API, or the team that owns the agent?
- How do we make the lethal trifecta safe without making agents useless?
Rate the post, start a thread on any concept below, or share it with someone wrapping their whole API as tools. I'll update it as the discussion changes my mind.