DEV Community

Deployed Lab
Deployed Lab

Posted on Originally published at deployedlab.dev

Your agent picked the wrong tool because your descriptions are twins

Your agent picked the wrong tool because your descriptions are twins

One Monday, a support lead at a made-up outdoor gear shop found refunds issued for customers the agent had never verified. The agent, Pine, had called lookup_order, then process_refund, and skipped get_customer entirely. Money went out to people nobody had confirmed.

The cause was not the model. It was two sentences. lookup_order was described as "get details for a customer request", and get_customer as "get customer details for a request". Both signs pointed both ways, and Claude picked the wrong one. When a customer asks for a refund, nothing in the request names a tool. The only routing information Claude gets is the tool list: names, descriptions, parameter schemas and the conversation. It never sees your code. It never sees your intent. If the right choice is not visible in that text, Claude guesses, and a guess at scale is a defect rate.

A description is a signpost, not a brochure

Think of each description as the label on a workshop drawer, or a signpost at a fork in the road. The label is all you read before you pull. A person can open the drawer and check. Claude commits to the call first. A vague label hurts its neighbours too, not just its own tool, because picks are comparisons, not lookups. Claude weighs every description against the request and takes the closest match. Close matches are where errors live.

Marketing copy makes this worse. "Powerful, seamless refunds" tells Claude nothing about when to pick the tool or what it needs. A good description carries five parts, and skipping one leaves a gap Claude fills with a guess:

  1. What it does, in one plain sentence. "Returns a verified customer ID for an email or phone number."
  2. When to use it. "Use first in any refund or order chat."
  3. When NOT to use it. "Do not use to get order details; use lookup_order." Naming the neighbour separates the tools, and this is the line people omit most, even though it does the most work.
  4. What each parameter means, with units and formats.
  5. What it returns. "Returns customer_id, name and verified flag." Claude plans its next step from this.

Names and units are routing signals too

Claude reads the whole definition, not just the description. Tool names should say action and object: get_customer, lookup_order. A name like fetch_data could mean anything. Parameter names do the same work: order_number beats id, because three tools here take three different IDs. And a parameter with no unit is a bug waiting for a large refund. An amount described only as a number invites a cents-versus-dollars error: 12900 can mean $129.00 in cents or $12,900 in dollars, and only one of those is a quiet day for the person in finance. Write the unit in the parameter description: "amount in US dollars, as a decimal, for example 129.00", "date as YYYY-MM-DD". Required versus optional should match reality too. Marking a guessable field required forces Claude to invent it or stall.

Overlap first, returns second

When two descriptions overlap, read them side by side, not one at a time. If two could honestly claim the same request, rewrite until each owns a distinct job and names the other as the alternative. There is a simple test: cover the tool names. If you cannot tell the descriptions apart, neither can Claude.

What a tool returns matters as much as what it does, because the return lands in the conversation and shapes the next pick. Pine's lookup_order returns about 40 fields, although only about 5 matter for returns: order number, item, total, delivery status and refund eligibility. The other 35 cost tokens on every later turn and bury the facts Claude needs, so the next pick gets worse, not just pricier. Trim the return to what the next step uses.

What a rewrite is worth

A rewrite is cheap, and the arithmetic makes the case. In the chapter's worked example, all rates made up, Pine's builder logged the first tool pick for a week, rewrote the four descriptions, and logged again. Before the rewrite, the wrong first pick happened on 11 percent of contacts. On 14,000 contacts a month, that is 1,540 mis-picks. After, 3 percent, or 420. That is 1,120 fewer mis-picks a month. Say 40 percent of mis-picks turn into a repeat contact: 448 repeat contacts avoided. At a made-up $6 per contact, about $2,688 a month, saved by rewriting four paragraphs.

A rewrite is still a claim until it is measured. Build a small test set before you ship: 20 to 30 real-style requests, each labelled with the correct first tool, including hard neighbours. "Where is my parcel?" is lookup_order, not get_customer. Compare mis-pick rates for old and new descriptions, and rerun the set whenever a tool is added or renamed. Tool lists drift in production: a tool gains a feature, its description does not, and picks quietly rot. Teams that treat descriptions as interface contracts, reviewed when the tool changes, avoid most of it.

So the next time your agent picks the wrong tool, resist the urge to blame the model or reach for a bigger one. Read the two competing descriptions side by side first. If they are twins, you found the bug, and it was written before the chat ever started.

The full interactive chapter is free at https://deployedlab.dev/lessons/cca-09-tool-descriptions, with a hands-on lab where three of Pine's descriptions are broken and you find out how. 79 chapters are free with no signup, and the full bundle is $5 a month or $39 a year at deployedlab.dev.

Top comments (0)