Velamuvi AIAcademy

Lesson 5 of 9 · Doing It Well

Writing Good Tool Descriptions

Write tool descriptions LLMs understand: purpose, when to use it, what it returns, formats and examples, plus naming tools and arguments and automatic checks.

  • 5 min read
  • Intermediate
  • Reviewed
In this lesson you will learn
  • Explain why tool descriptions matter so much
  • Write descriptions that say what a tool does, when to use it and what it returns
  • Name tools and arguments clearly, with formats and examples
  • Check tool definitions automatically for common problems

The model only knows what you tell it

The model never sees your function's code. Everything it knows about a tool comes from three things: the name, the description and the schema. Vague descriptions lead to tools being skipped, misused or called with wrong arguments.

What a strong description includes

  1. What it does, in plain words: “Search the help centre's articles by keywords.”
  2. When to use it, and when not: “Use for questions about how the product works, not for billing.”
  3. What it returns: “Returns up to 5 articles with title, URL and a short extract.”
  4. Argument details: formats, units and examples: “Date in YYYY-MM-DD”, “price in euros”, “e.g. 'reset password'”.
  5. Limits and side effects: “Sends an email immediately. Only use after the user confirms.”

Write it as you would explain the tool to a new colleague who has never seen your system.

Checking definitions automatically

Some problems are easy to catch in code before a model ever sees the tool. This checker flags short descriptions, missing return information, unclear argument names and undocumented date formats:

Try it yourselfPython
def lint_tool(tool):
    """Flag common problems in a tool definition before a model ever sees it."""
    problems = []
    desc = tool.get("description", "")
    if len(desc.split()) < 8:
        problems.append("description is too short to say what the tool does and when to use it")
    if "return" not in desc.lower():
        problems.append("description doesn't say what the tool returns")
    for name, spec in tool["input_schema"]["properties"].items():
        if len(name) <= 2:
            problems.append(f"argument '{name}' has an unclear name")
        if "description" not in spec and "enum" not in spec:
            problems.append(f"argument '{name}' has no description")
        if spec.get("type") == "string" and "date" in name and "YYYY" not in spec.get("description", ""):
            problems.append(f"argument '{name}' doesn't state its date format")
    return problems

weak = {
    "name": "search",
    "description": "Searches stuff.",
    "input_schema": {"type": "object", "properties": {
        "q": {"type": "string"},
        "from_date": {"type": "string", "description": "start date"},
    }},
}
strong = {
    "name": "search_support_articles",
    "description": ("Search the help centre's articles by keywords. Use this for questions about "
                    "how the product works. Returns up to 5 articles with title, URL and a short extract."),
    "input_schema": {"type": "object", "properties": {
        "query": {"type": "string", "description": "Keywords, e.g. 'reset password'"},
        "from_date": {"type": "string", "description": "Only articles updated since this date, YYYY-MM-DD"},
    }},
}

for tool in [weak, strong]:
    problems = lint_tool(tool)
    print(f"{tool['name']}: {len(problems)} problem(s)")
    for p in problems:
        print("   -", p)

The weak tool has five problems; the strong one has none. A check like this can run in your tests, so every new tool meets the same standard.

Names matter too

  • Use specific, action-style names: search_support_articles, not search or helper.
  • Group related tools with a prefix: orders_lookup, orders_refund, orders_cancel.
  • Use full words for arguments: query, from_date, max_price, not q, d1, mp.
  • Keep names consistent across tools: if one tool takes order_id, don't call it orderNumber in another.

Common mistakes

Practice exercise

Turn a weak tool description into one a model can use well.

Your solutionPython
tool = {
    "name": "get_invoice",
    "description": "Gets invoice.",
}

# Rewrite the description so it says (1) what the tool does, (2) when to use it,
# and (3) what it returns. These checks must all print True:
desc = tool["description"]
print(len(desc.split()) >= 12)
print("use" in desc.lower())
print("returns" in desc.lower())
Knowledge check

A model keeps choosing the wrong one of two similar tools. What should you try first?

Summary

  • The model knows a tool only through its name, description and schema.
  • Good descriptions say what it does, when to use it, what it returns, and give formats and examples.
  • Use specific, consistent names, grouped with prefixes.
  • Check definitions automatically, and test tool choice on real requests.

Next: validating the arguments a model sends.

Finished reading? Tick it off to track your progress.