FDE Times dataFDE jobs open 932▼14 Change in open roles over 7 days, like-for-like: roles from companies we started tracking this week are left outNew in 7 days 62Companies hiring 202Remote-friendly 24%Median US pay $201kTop hirer Databricks 92
中文VI

The newspaper of the Forward Deployed Engineer

Guides

When an agent calls the wrong tool, check the description you wrote

Anthropic ranks a detailed description as the most important factor in tool performance, and a logistics company's API shows how to rewrite one step by step.

ShareLinkedInFacebookX

In brief

  • A model picks a tool based only on its name, description and inputs, so the description is the most important thing you control.
  • Consolidate related endpoints into fewer tools, use names like acme_orders, and use order_id rather than order.
  • Errors and responses are prompts too: rewrite errors so the model can correct itself, and return only the data it actually needs.
Data-flow diagram: the tool definition (name, description, schema) is inserted into the model's prompt, highlighted in orange because that is where wrong tool calls usually begin. The model generates JSON arguments for the wrapper, which calls the client's API and returns to the model errors that hint at a fix, plus a trimmed response.
The model reads neither the client's code nor its Swagger. It sees only the tool definition inserted into the prompt, and reads back only what the wrapper returns. The graphic draws on the hypothetical Acme example in the article, synthesised from Anthropic's tool-use documentation and Hugging Face's Agents course.

Anthropic’s tool use documentation says a detailed description is by far the most important factor in whether a tool performs well. Before reaching for a different model or framework, then, look again at the few sentences you wrote yourself.

The reason is simple. According to Hugging Face’s Agents course, tool descriptions are inserted into the system prompt, so the model knows only what is written there. Paragon describes the same mechanism: the model chooses a tool based on the name, description and inputs attached to each one.

The client has an internal API, and you have to wrap it so an agent can use it. This guide works through a hypothetical example step by step, with a check after each step.

What will you build, and what do you need?

Take a logistics company called Acme as the client. It has three endpoints: look up an order by ID, find orders by phone number, and cancel an order. Your goal is for a customer-service agent to call the right endpoint with the right parameters when users ask questions in natural language.

Keep in mind how function calling works. The Prompting Guide describes it as a way to turn natural language into valid API calls, but the model only generates arguments as JSON; actually calling the API is your code’s job. You need to be comfortable with JSON Schema, have the client’s API documentation, and have a small wrapper layer sitting between the model and the API.

Step 1: See why the first draft fails

This is the kind of definition you often see when someone copies endpoint names straight in:

{
  "name": "get",
  "description": "Get order",
  "input_schema": {
    "type": "object",
    "properties": { "order": { "type": "string" } },
    "required": ["order"]
  }
}

The name “get” says nothing about what is fetched, or from which system. The “order” parameter could be an order ID, a whole order object or a sequence number. A two-word description says nothing about when to use the tool.

A post on Anthropic’s engineering blog recommends unambiguous parameter names, such as user_id instead of user; the same applies here, and order_id is far clearer than order.

Check: read the definition aloud to a colleague who has never seen Acme’s API. If they ask “what is order?”, the model will misread it the same way.

Step 2: Consolidate endpoints and prefix names with the service

Many people’s first instinct is one tool per endpoint. Anthropic’s documentation advises the opposite: consolidate related operations into fewer tools with an action parameter, because fewer, more capable tools leave the model less to deliberate over when choosing.

The same documentation recommends prefixing names with the service, as in github_list_prs or slack_send_message, so that selection stays clear as the tool library grows.

Applied to Acme, the three endpoints become a single tool called acme_orders, whose action takes one of three values: get, search or cancel. If the agent later gains tools for a CRM system, the acme_ prefix tells them apart at once.

Check: list every tool the agent currently has. If you have to read two of them closely to see how they differ, merge or rename them.

Step 3: Write the description as if briefing a new hire

Anthropic suggests writing a description the way you would explain the tool to someone new on the team, spelling out the context insiders take for granted. Its documentation lists what to include: what the tool does, when to use it and when not to, what each parameter means, and any caveats.

Aim for at least 3-4 sentences per tool, more if the tool is complex. Note that each JSON string must sit on a single line; for a line break inside a description, use the escape \n.

{
  "name": "acme_orders",
  "description": "Look up, search for or cancel delivery orders in the Acme system. Use action='get' when the user has given an order ID; use action='search' when you only have the recipient's phone number. Use action='cancel' only when the user clearly says they want to cancel, and only for orders that have not left the warehouse.\n\nDo not use this tool for questions about shipping rates or compensation claims. Order IDs take the form ORD- followed by 8 digits.",
  "input_schema": {
    "type": "object",
    "properties": {
      "action": { "type": "string", "enum": ["get", "search", "cancel"] },
      "order_id": { "type": "string", "description": "Order ID in the form ORD-12345678. Required for get and cancel." },
      "recipient_phone": { "type": "string", "description": "Recipient's phone number, digits only. Used with search." }
    },
    "required": ["action"]
  }
}

The order ID format, the “not yet left the warehouse” rule and the exclusion of claims are all invented for this example. At a real client you have to draw such rules out of people, and they usually live in the operations team’s heads rather than in the API documentation.

Check: does the description contain a sentence that begins “Do not use…”?

Step 4: Add examples for inputs that are hard to format

For tools with complex or format-sensitive inputs, Anthropic’s API has an optional input_examples field. Each example must be valid against the input_schema; an invalid one returns a 400 error. Examples also cost extra prompt tokens, so use them only when a format is genuinely often filled in wrongly. The snippet below is simplified:

"input_examples": [
  { "action": "get", "order_id": "ORD-20481234" },
  { "action": "search", "recipient_phone": "0901234567" }
]

Check: send the request. If you get a 400 error, an example probably does not match the schema, for instance a wrong field name or an action value outside the enum.

Step 5: Responses and errors are prompts too

Whatever the API returns goes back into the model’s context. Anthropic’s engineering blog recommends that tools return only high-value information, and suggests pagination, filtering and truncation for large payloads. The same post points out that error messages can be rewritten to say exactly what needs fixing, helping the model adjust on its next call.

The wrapper below is simplified. It separates two different failures: an ID in the wrong format (caught in the wrapper, before any API call) and an ID in the right format that does not exist (the API returns 404).

import re

# Simplified: wrapper between the model and the client's API
ORDER_ID_PATTERN = re.compile(r"^ORD-\d{8}$")

def run_acme_orders(args):
    if args["action"] in ("get", "cancel"):
        order_id = args.get("order_id", "")
        if not ORDER_ID_PATTERN.match(order_id):
            return ("order_id has the wrong format: it must be ORD- + 8 digits, "
                    "for example ORD-20481234. Ask the user for the order ID again.")
    resp = call_customer_api(args)  # your HTTP function
    if resp.status == 404:
        return ("No order was found, although the ID has the right format.\n\n"
                "If the user has the recipient's phone number, "
                "call again with action='search'.")
    order = resp.json()
    return {"order_id": order["id"], "status": order["status"],
            "eta": order["eta"]}  # drop internal fields the model does not need

Compared with a bare “404 Not Found” string, each message here points the model down a different path: a malformed ID means asking again, a missing one means switching to a phone-number search. Trimming the response to three fields spares the model from wading through dozens of internal ones.

Check: make two test calls, one with a malformed ID and one with a well-formed ID that does not exist. The model’s next call should differ between the two cases, rather than retrying the same bad ID.

Step 6: Don’t trust your gut, run an eval

Anthropic notes that even small refinements to a description can improve results dramatically. That cuts both ways: changing one sentence can make things better, but it can also break a case that was working.

The practical approach is to draft about 20 questions taken from the client’s customer-service logs. For each, record the correct tool, action and arguments in advance. Every time you edit a description, rerun the whole set and count the correct answers.

Traps to avoid

A common mistake is generating tools automatically from OpenAPI and leaving them as they are. That leads straight to what Anthropic’s documentation warns against: dozens of tools, one per endpoint, with descriptions copied from developer comments and too short for the model to tell them apart. Another is leaving parameters named id, user or data with no format specified.

Nor should you return the API’s raw JSON, errors included, and then wonder why the model keeps repeating the same wrong call.

What does this skill look like at a client site?

On site, the hard part is rarely JSON syntax. It is sitting with the operations team to extract answers to questions like “can an order be cancelled once it has left the warehouse?”, because those answers are precisely what goes into the “when not to use” sentence of a description.

If you are aiming for an FDE role, look for job descriptions that mention tool calling, agent integration or working directly with client APIs.

On your CV, don’t just write “integrated LLMs with internal APIs”. State how many endpoints you consolidated into how many tools, and how accuracy on your eval set changed after each round of description edits. A before-and-after number like that shows a recruiter you can do the work clients pay for.

The next time an agent calls the wrong API, hold off on switching models. Open the description and read it as a new hire would on their first day.

Was this article useful?

Use with your AI assistantAsk Claude ↗Ask ChatGPT ↗
5 sources
Read next on the roadmap · Stage 3: Applied AIIn Vietnamese call-center transcription, the model is the easy partPhoWhisper transcribes and WhisperX separates speakers, but the real errors come from 8kHz files, people talking over each other and the code that joins the two.