← All writing

Agents· December 22, 2025 · 11 min

Designing Tools for LLMs: A Field Guide From Production Agents

Tool ergonomics, not model choice, is the dominant lever for agent quality. Every production agent I have shipped proved it the hard way.

Agents Do Not Fail Because Models Are Dumb

The most common debugging session I have with teams building agents goes like this. Engineer: "Claude keeps calling the wrong tool, can we switch to GPT?" Me: "Show me your tool definitions." Five minutes later we have renamed query_db to search_customers, removed three redundant parameters, and the agent works. No model change.

After shipping a handful of production agent systems — customer support triage, internal devops copilots, an agent that drives a data pipeline — I am convinced tool design is the single biggest lever on agent quality. The model gets the headlines. The tool schemas decide whether your agent ships.

Name Tools Like Functions A Human Would Write

The model has read more code than any human alive. It has a strong prior about what a function named search_customers does and a much weaker one about query_db. Use that prior.

Bad:

{ name: "execute", params: { type: "search", entity: "customer", q: "acme" } }
{ name: "query_db", params: { sql: "..." } }
{ name: "do_action", params: { action: "refund", id: 123 } }

Good:

{ name: "search_customers", params: { query: "acme" } }
{ name: "get_order", params: { order_id: "ord_abc123" } }
{ name: "issue_refund", params: { order_id: "ord_abc123", amount_cents: 4900 } }

The bad versions are dispatchers — the model has to learn your dispatch rules from the description. The good versions are functions — the model already knows roughly what they do from the name alone.

A rule I enforce on every code review: if your tool name is a noun, a generic verb (execute, run, do), or contains the word handler, rename it.

Parameter Schemas Are User Interfaces

Every parameter is friction. The model has to decide what to put there, often with incomplete information. Each additional parameter roughly doubles the surface area for bad calls.

The worst offender I see is string-typed enums:

// Don't do this
{
  status: z.string(), // "open" | "closed" | "pending" | "in_progress" | "in-progress" | "InProgress"
}

The model will guess. Sometimes correctly. Often with a typo or a synonym you did not consider. Use proper enums:

{
  status: z.enum(["open", "closed", "pending", "in_progress"]),
}

Anthropic's tool-use docs will literally surface the enum values to the model. Same with OpenAI's function calling. You get free correctness from the schema.

The other rule: prefer one semantically rich parameter over three weakly correlated ones.

// Bad — model has to decide which filters to set
search_orders({
  customer_id?: string,
  customer_name?: string,
  customer_email?: string,
  order_id?: string,
})

// Better — one parameter, model can put anything reasonable in it
search_orders({
  query: string, // matches order ID, customer name, email, or company
  limit?: number,
})

The fewer decisions the model has to make about how to call the tool, the more compute it spends on what to do with the result.

Tool Descriptions Are Prompts. Treat Them That Way.

I have seen tool descriptions like "Search the database." That description does roughly nothing. A good description:

  • States what the tool does in one sentence
  • Mentions when to use it vs. similar tools
  • Includes 1–2 example calls in natural language
  • Calls out edge cases or footguns
const searchOrders = {
  name: "search_orders",
  description: `Search recent orders by customer name, email, company, or order ID.

Use this when the user asks about orders by a human identifier ("orders from Acme")
or when they have an order ID. For listing all orders by a known customer_id, use
list_customer_orders instead — it is faster and returns more fields.

Examples:
  search_orders({ query: "acme@example.com" })
  search_orders({ query: "ORD-2024-9981" })

Returns up to 20 matching orders sorted by created_at desc. If more results exist,
the response includes a next_cursor.`,
  // ... schema
};

That description is doing more work than your system prompt. The model reads tool descriptions during reasoning every single turn. Spend time on them.

A specific anecdote: on one agent, we had search_orders and list_customer_orders colliding. The model called the slow one 70% of the time. We added one sentence — "use list_customer_orders when you already know the customer_id" — and the ratio inverted. No model change, no schema change.

Errors Versus Empty Results Are Not The Same Thing

Models respond differently to thrown errors and to structured "I found nothing" responses. Both have their place.

  • Throw an error when the call was malformed, the system is unhealthy, or the operation is impossible (permission denied, resource not found by ID). The model should rethink its approach.
  • Return empty results when the query was valid but matched nothing. The model should refine the query, not abandon the tool.
// "Customer ord_xyz not found" — throw. The ID was wrong.
throw new ToolError("Order ord_xyz not found", { code: "NOT_FOUND" });

// "No orders matching 'acme' in the last 30 days" — return.
return { orders: [], next_cursor: null, note: "No orders matched in the last 30 days. Try a broader date range or different query." };

I once watched an agent loop forever calling search_customers with slight variations because the tool threw a 404-style error on empty results. Switching to structured empty responses with a hint string fixed the loop in one deploy.

One Tool, One Verb — Until It Is Not

The standard advice is "one tool per verb." create_order, cancel_order, refund_order. This is right most of the time. The model picks more accurately when the verb is in the name.

But there is a real exception. When a workflow requires 4–6 sequential tool calls to do anything useful, the model spends its turns on plumbing instead of reasoning. For example, a deployment agent that needs to:

  1. Look up the service
  2. Check current version
  3. Diff against target
  4. Run the migration
  5. Switch traffic
  6. Verify health

Six tool calls. Six round trips. The model can lose track of state in the middle. In this case, a mega-tool — deploy_service({ service, target_version, dry_run }) — that internally orchestrates the steps and returns a structured plan-and-result is the correct design.

The rule of thumb: if the model would always call tools A → B → C in that order and B's only input is A's output, fuse them. If A, B, and C are called independently for different purposes, keep them separate.

Destructive Actions Need Confirmation And Idempotency

Two patterns I now consider non-negotiable for any tool that mutates state.

Idempotency keys. Every mutating tool takes an idempotency_key parameter. The agent generates one (a UUID is fine) per logical operation. If the tool is called twice with the same key — because of a retry, a confused replanner, or a network hiccup — the second call is a no-op that returns the original result.

{
  name: "issue_refund",
  schema: z.object({
    order_id: z.string(),
    amount_cents: z.number().int().positive(),
    reason: z.string(),
    idempotency_key: z.string().uuid(),
  }),
}

Two-phase destructive actions. For anything truly destructive — deleting customer data, charging a card, deploying to prod — split the tool into prepare_X and commit_X. prepare_X returns a token and a human-readable summary. commit_X takes the token. The agent shows the summary to the user, gets confirmation, then commits.

prepare_account_deletion({ user_id }) → {
  confirmation_token: "tok_a8c91f",
  expires_at: "2025-12-22T18:00:00Z",
  summary: "Will delete user u_123, 47 orders, and 3 saved payment methods. Cannot be undone.",
}

commit_account_deletion({ confirmation_token: "tok_a8c91f" }) → { deleted: true }

This is annoying. It is also the difference between an agent you can let loose on production and a liability.

A Tool That Returns { success: true } Is A Bug

The single most common mistake I see: tools return minimal acknowledgments and force the agent to make follow-up calls to figure out what actually happened.

// Useless
update_order({ order_id, status: "shipped" }) → { success: true }

// Useful
update_order({ order_id, status: "shipped" }) → {
  order_id: "ord_abc123",
  previous_status: "processing",
  new_status: "shipped",
  updated_at: "2025-12-22T14:31:00Z",
  tracking_number: "1Z999...",
  customer_email_sent: true,
}

The model uses the response to decide what to do next and what to tell the user. Empty responses force speculation, and speculation is where hallucinations live. Cost of returning 6 extra fields: ~50 tokens. Cost of the model hallucinating that a tracking email was sent when it was not: a customer complaint.

Pagination Is Not Optional

Never return 500 rows to a model. Aside from the obvious context cost — 500 orders is easily 30k tokens — the model gets worse at long lists. It will summarize the first ten and forget about the rest.

Pick a sensible default page size, document it in the description, and return a cursor.

list_orders({ customer_id, limit: 20 }) → {
  orders: [ /* up to 20 */ ],
  next_cursor: "eyJpZCI6Im9yZF94eXoifQ==",
  has_more: true,
  total_count: 347,
}

total_count is useful for the model to decide whether to paginate further or to ask the user to narrow the query. Most of the time the right behavior is the latter.

Putting It Together

Here is a tool that follows every rule above:

import { z } from "zod";

export const searchOrders = {
  name: "search_orders",
  description: `Search recent orders by customer name, email, company, or order ID.

Use this when the user references orders by a human identifier. For listing
all orders for a known customer_id, prefer list_customer_orders.

Examples:
  search_orders({ query: "acme@example.com" })
  search_orders({ query: "ORD-2024-9981", limit: 5 })

Returns up to 20 matching orders sorted by created_at desc. Empty results
include a hint string explaining why.`,

  schema: z.object({
    query: z.string().min(1).describe(
      "Free-text search across order ID, customer name, email, company."
    ),
    status: z
      .enum(["any", "pending", "paid", "shipped", "refunded", "cancelled"])
      .default("any"),
    limit: z.number().int().min(1).max(50).default(20),
    cursor: z.string().optional(),
  }),

  async execute(input, ctx) {
    const results = await orderRepo.search({
      tenantId: ctx.tenantId,
      query: input.query,
      status: input.status === "any" ? undefined : input.status,
      limit: input.limit,
      cursor: input.cursor,
    });

    if (results.items.length === 0) {
      return {
        orders: [],
        next_cursor: null,
        has_more: false,
        total_count: 0,
        note: `No orders matched "${input.query}" with status=${input.status}. Try a broader query or status="any".`,
      };
    }

    return {
      orders: results.items.map(toAgentShape),
      next_cursor: results.nextCursor,
      has_more: results.hasMore,
      total_count: results.totalCount,
    };
  },
};

Every choice in there — the name, the description, the enum, the limit cap, the rich response, the hint string on empty — is doing work for the model.

The Mental Model

Tool design is API design, just with a worse client. The client cannot read your source, cannot ask follow-up questions before calling, has no IDE autocomplete, and might confuse two similar tools if their names differ by one word. Every affordance you would put in a good developer-facing SDK — descriptive names, tight types, useful errors, rich responses, pagination, idempotency — matters more here, not less.

If your agent is misbehaving, do not switch models. Open the tool definitions.