Skip to content
mentoor

Topic 1 of 5 · 4 min read

Writing tool names, descriptions and input schemas

Goal: Write a tool definition whose name, description and input schema let the model pick it at the right time and fill its arguments correctly.

A tool definition is the only documentation the model ever sees for your function, so the name, the description and the schema are the whole interface. The model does not read your code. It reads three things and guesses from them.

Check yourself · 1 of 3

What does the model use to decide which tool to call?

Choose one answer

Why it matters

When a tool is picked at the wrong time, or called with a made-up argument, the cause is nearly always the definition. Fixing it costs a few lines. Fixing it in the application code costs much more.

How to write one

  1. Name it for the action and the object. get_order_status beats orders or helper2. Use the same naming style across all tools.
  2. Describe when to use it, and when not to. Say what it returns and what it cannot do. Two tools that sound alike need a sentence each that separates them.
  3. Give every argument a type and a description. Use enum for closed sets, required for what must be present, and a format hint (such as an ISO date) when the shape matters.
  4. Keep the schema small. A tool with twelve optional fields invites wrong guesses. Split it, or drop what the model cannot know.
  5. Do not ask the model for what you already have. The user id comes from your session, not from the model.

All main providers (Claude, OpenAI, Gemini) take the arguments as JSON Schema, so one schema style works everywhere.

Before and after

Weak:

{
  "name": "search",
  "description": "Searches things",
  "input_schema": {
    "type": "object",
    "properties": { "q": { "type": "string" }, "t": { "type": "string" } }
  }
}

Better:

{
  "name": "search_orders",
  "description": "Find a customer's past orders by status or date range. Returns up to 20 orders with id, status and total. Does not return refunds; use get_refund for those.",
  "input_schema": {
    "type": "object",
    "properties": {
      "status": { "type": "string", "enum": ["pending", "shipped", "delivered", "cancelled"], "description": "Order status to filter by" },
      "since": { "type": "string", "description": "Earliest order date, ISO 8601, for example 2026-11-01" }
    },
    "required": ["status"]
  }
}

What goes wrong

  • Vague names and descriptions. The model picks by a loose match and calls the wrong tool.
  • Free-text arguments for closed sets. The model writes "Shipped!" and your code expects "shipped".
  • Overlapping tools. Two tools that both "look up customers" split the calls at random.
  • Trusting the schema as validation. The schema guides the model but does not guarantee valid input. Validate on your side too.

Examples

Separating two similar tools

A support bot has get_customer and search_customers. Calls keep landing on the wrong one. The fix is two descriptions: "Fetch one customer by exact id. Use when the user gives an id." and "Find customers by name or email. Returns up to 10 matches. Use when you do not have an id." No code changed, and wrong picks dropped.

Closing an argument with an enum

A set_priority tool took priority as a free string and received "urgent", "High" and "P1" in one week. Declaring "enum": ["low", "normal", "high"] and describing what each means made every call valid.

Key points

  • The name, description and input schema are all the model knows about your tool.
  • A good description says what the tool does, what it returns and when to use a different tool.
  • Use enum, required and format hints so arguments arrive in a shape your code accepts.
  • Keep each tool narrow; overlapping or sprawling tools cause wrong picks and wrong arguments.
  • The schema guides the model but never replaces validation in your own code.

Common mistakes

  • Naming a tool with a short or generic word like run or data and writing no description.
  • Leaving out required, so the model omits a field your code needs.
  • Asking the model for values the application already knows, such as the signed-in user id.
  • Assuming the schema rejects bad input, and skipping server-side validation.

Check yourself · 2 of 3

An argument can only be one of four fixed status values. Which schema choice helps the model most?

Choose one answer

Check yourself · 3 of 3

Two tools, get_customer and search_customers, are called at random. What is the best first fix?

Choose one answer

Practice items, not counted towards your mastery.

Start here

More for this topic