# Designing tools that AI agents can actually use

A practical field guide to schemas, context budgets, recoverable side effects, and trace-based evaluation.

> How should you design tools that AI agents can actually use?

## Short answer

Design agent tools as **narrow, typed, text-described contracts** whose boundaries and failure modes are explicit, then protect irreversible actions with **idempotency and approval gates**. The model can only select and operate what the catalog makes inferable, so names, schemas, outputs, and errors are part of the interface. Measure the resulting loop on traces, not on endpoint uptime.

The durable test is behavioral: can a trace show the model choosing the right tool among near-duplicates, filling valid arguments, recovering from a structured error, and stopping before an unrecoverable side effect? A tool that passes unit tests but fails that loop is not agent-ready.

- **Core unit**: Typed, described tool contract
- **Main constraint**: Finite model attention
- **Safety pattern**: Idempotency plus approval

## A tool is a typed contract the model must infer from text

An agent never sees your code; it sees a name, a description, a parameter schema, and whatever the call returns. Treat that bundle as the real API contract. The name should encode the verb and object (`create_refund`, not `refund`), and the description should say when to use it, when not to, what units and limits apply, and what the result means. Parameters belong in a typed schema with enums, formats, required fields, and explicit ranges; a free-text `data` object forces the model to guess.

The failure mode is not theoretical. In large, domain-specific tool inventories, ambiguous descriptions and under-specified schemas drive tool mis-selection and wrong slot values; jointly optimizing instructions and per-tool schema wording improved overall success by 5–20% relative over strong baselines . MCP-style registries make this concrete: each tool is registered with a name, description, and input/output schema . Hidden conventions that a human teammate would learn from code review are invisible to the model.

Design the return value as part of the contract, too. A compact object with stable field names and a clear status beats a verbose HTML or log dump. For a refund tool, return `eligible`, `amount_cents`, `currency`, and `reason_code`, not a paragraph the model must parse. The trade-off is description length: too little context creates ambiguity, while a 500-word preamble consumes attention and can bury the constraint that matters.

> The model cannot infer what the schema does not say.

> Note: Schema wording is not a substitute for server-side validation.

## Design for attention scarcity, not an unlimited API surface

Tool selection is an attention problem before it is an API problem. Every tool name, description, and parameter consumes context; long catalogs also increase latency and cost and make similar tools compete for the same intent. The model must compare candidates under uncertainty, so a 60-tool global namespace with `get_user`, `fetch_user`, `lookup_customer`, and `find_account` invites mis-selection. Namespacing by domain—`billing.get_invoice`, `support.get_ticket`—adds a cheap disambiguation cue.

Progressive disclosure beats a giant catalog. Expose a small set of high-level discovery tools, then load detailed schemas only for the namespace the agent selects. MCP-style servers already separate tools, resources, and prompt templates, which lets you keep static reference material out of the tool list . Paginate list results and return continuation tokens instead of dumping thousands of rows. Budgets for model turns, executed calls, and tokens make the cost of a sprawling catalog visible during a run .

The boundary condition: meta-tools add indirection. A search-then-invoke loop costs an extra model turn and can fail if the search tool is weak. For a stable five-tool workflow, direct tools are simpler and more reliable. There is no universal tool-count threshold; the practical test is whether a trace shows the model choosing among near-duplicates or exhausting context. The finding that performance degrades as inventories grow large and domain-specific supports the direction, not a specific cutoff .

> A catalog is a UI for the model; every entry competes for attention.

> Note: No universal tool-count threshold is established; measure selection on your own traces.

## Make failure legible and side effects reversible

Failure handling is where most agent tools break. An unstructured 500 error tells the model nothing; a structured error should say `code`, `message`, `retryable`, the offending `field`, and a suggested next action. Separate validation failures (fix the argument), permission failures (do not retry), transient failures (retry with backoff), and indeterminate outcomes (a write may have happened). The last category is the dangerous one.

Idempotency makes retries safe. Give every write a stable key derived from the run and validated call, or let the caller supply a business key such as an order number. once-gate sits between the agent and MCP tools, claims each action, returns the stored result for a repeat, and refuses with `INDETERMINATE` when a call started but never finished, forcing human review . agent-runloop similarly pauses write tools for approval, checks authorization from trusted run context, and exposes a stable call id for idempotency .

Preview modes and approval gates reduce irreversible mistakes. A `preview_refund` call can show eligibility and exact amount before `submit_refund`; a threshold can require human approval above a set value. The trade-off is approval fatigue: gate too many low-risk reads and humans start rubber-stamping. Approval must be exact-content, not a generic “allow all.” The caveat is that idempotency keys only work if the server honors them consistently; a proxy can deduplicate, but the underlying system still needs a correct uniqueness constraint.

> A retry is only safe when the system can recognize the same action.

> Note: Approval is not a substitute for authorization; check permissions from trusted context before asking a human.

## Measure tool usability through traces, not endpoint uptime

Endpoint uptime says almost nothing about tool usability. The unit of quality is the model-tool loop: did the agent choose the right tool, fill valid arguments, execute without error, recover when it failed, and finish the task without unnecessary calls? A tool can be 99.9% available and still be unusable if its description collides with three neighbors.

Trace every model call and tool call, then label failures by cause. pyagenteval records each step and reports right-tool rate, valid-argument rate, execution success, retries, latency, and cost, with failure labels for tool errors, timeouts, rate limits, and truncated answers . That separation matters: “68% correct” and “100% correct, 32% blocked by rate limits” are different engineering problems. agent-runloop’s audit rows and per-execution version hashes support the same discipline: you can attribute a regression to a tool-schema change or a model change .

Build a held-out evaluation set from real traces, including near-duplicate tools, ambiguous requests, malformed arguments, and adversarial tool outputs. Replay it after every description or schema edit. The trade-off is overfitting: optimizing descriptions against a small benchmark can improve that benchmark while making the catalog brittle. Keep a fresh slice and inspect traces, not just aggregate scores. The strongest caveat is that no public benchmark establishes a universal target for tool-selection accuracy; your threshold should come from task risk and human review capacity.

> Tool quality is a property of the loop, not the endpoint.

> Note: Aggregate pass rates hide whether the agent selected the right tool for the right reason.

## Apply the model to a refund agent and mark its limits

Consider a refund agent. Its read tools should be narrow and safe: `get_order`, `get_customer`, and `list_refunds`, each returning only the fields needed for eligibility. The write surface should be one explicit tool, `create_refund`, with `order_id`, `amount_cents` bounded by the order total, a `reason_code` enum, and a required `idempotency_key`. Add `preview_refund` to show the exact effect before commitment. Route amounts below a threshold automatically; pause above it for exact-content human approval. Store the approval and the resulting refund id in an audit row . If a submission times out, return an indeterminate state and require a human release rather than retrying blindly .

This design works because it separates inference from authority. The model can read, propose, and explain; the system enforces permissions, bounds, idempotency, and approval from trusted context . Tool output should be delimited and labelled as data, with the original task restated, because a refund reason or customer note can contain prompt injection .

The limits matter. Atomic tools are the wrong abstraction when a task has a hard invariant spanning several calls—for example, “refund and restock only if the item is received.” A deterministic workflow or a higher-level tool with a transactional boundary is safer than hoping the model sequences primitives correctly. MCP servers improve discovery and reuse, but they are not a security boundary by themselves. And tool sprawl returns through the back door: every new convenience tool adds selection cost.

> Separate what the model may infer from what the system will allow.

> Note: The reference design is a pattern, not a compliance blueprint; refund rules vary by jurisdiction and payment processor.

## Common misconceptions

- **Myth:** More tools give the agent more capability. **Reality:** Beyond a point, each tool adds selection ambiguity and context cost; a smaller, well-namespaced catalog or progressive disclosure often performs better.
- **Myth:** A good description is just documentation. **Reality:** For an agent, description and schema are control surface; ambiguous wording changes which tool is called and which arguments are filled.
- **Myth:** Retries make writes reliable. **Reality:** Blind retries duplicate side effects; idempotency keys and indeterminate-outcome handling make retries safe.
- **Myth:** Human approval solves safety. **Reality:** Approval fatigue and prompt injection can defeat it; approvals must be exact-content and backed by trusted authorization.

## FAQ

### An agent with 40 tools keeps calling fetchcustomer when it needs billing history. Descriptions are one line each. What is the most likely design defect?

The catalog is forcing the model to infer distinctions that the names and descriptions do not state; selection ambiguity is a contract problem before it is a model problem.

### A chargecard call times out after the request was sent. The tool returns a generic timeout. What should the agent-facing response do?

A timeout after dispatch means the side effect may have happened. The safe response is to mark the outcome indeterminate and resolve it with idempotent lookup or human review.

### Which metric best captures whether an agent can use a tool catalog?

Uptime and latency measure the endpoint, not the model-tool loop. Selection, argument validity, recovery, and completion are properties of the interaction.

### What tool-count and description-length thresholds generalize across models and domains?

Teams need practical limits for catalog design, but current evidence is practitioner experience rather than controlled measurement.

### How should approval interfaces present exact content without causing fatigue?

Approval gates only work if humans actually inspect them, and the wrong interface can turn safety into a rubber stamp.

### Can agents reliably resolve indeterminate writes without human review?

Autonomous recovery would unlock more automation, but mistaken resolution can duplicate or lose money.

---

Delve Editorial · https://delve.prisflow.com/p/tool-design-for-agents
