Skip to content
All posts

· 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) beats list_customers plus get_customer plus list_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_issue and jira_create_issue are unambiguous; two tools called create_issue are 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, not user), 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 concise default and a detailed option 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 400 tells 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_refund doesn'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.

Anatomy of a tool callAnatomy of a tool call: the model reads a tool's contract (name, description, inputs, outputs, errors and hints), served to any client through an MCP server; each call is validated, passed through a permission gate, executed in a sandbox with a timeout and idempotency key, and its result is trimmed and shaped before going back into the model's context as data, never as instructions.readsservetool callresult goes back into context · treat it as data, never as instructions01modelsees names, descriptions,schemas and resultsnothing else02the contractnamesearch_ordersdoesFind orders by customer email or id.Newest first, at most 20 per page.inputemail? · order_id? · cursor?returnsid · status · total · next_cursoron error"No customer with that email. Try order_id instead."hintsread-only · idempotent03MCP serverwrite once, use from any clientyour agentCursorCopilotClaudetools · resources · promptsauth + scopes per client04validateschema · authrate limits05gateread-only: rundestructive: ask06executesandbox · timeoutidempotency key07shape resulttrim · paginateerrors that teach
Fig. 1 · A tool's contract, how a call runs, and what goes back to the model. Numbers match the walkthrough below.
  1. 01

    Model

    Sees names, descriptions, schemas and results, and nothing else. Every design choice below is about what lands in front of it.

  2. 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.

  3. 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.

  4. 04

    Validate

    Check the schema, the caller's permissions and rate limits before anything runs. Reject with a helpful error, not a stack trace.

  5. 05

    Gate

    Read-only calls run. Destructive ones wait for confirmation, with a clear summary of what will happen.

  6. 06

    Execute

    In a sandbox, with a timeout and an idempotency key, and logged with enough detail to replay.

  7. 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.

Discussion

feedback.

Rate the post, then start a thread on any concept. Disagreements are especially welcome. No sign-up needed.

Reader rating

–No ratings yet. Be the first.

How useful was this?

Start a thread

Loading the discussion…