Yashotantra Academy logo
level 1
Curious · 0 XP
streak
0d
perfect
0
badges
0

100 XP to Apprentice

Tools · easy

3. Tool schemas that models call correctly

Naming, descriptions, and JSON Schema decide whether tool calling works.

1 min read3 questionsup to 50 XPtopic 3/14

Read in another language

AI translates the explanation and quiz text while preserving code and answer scoring.

A tool is a name, a description, and a JSON Schema for arguments. The model sees only those strings, so they are prompt engineering, not documentation.

Rules that measurably reduce failed calls:

- Verb-first names: `get_invoice`, not `invoice`. - Describe *when to use it and when not to*. - Mark required fields and use enums instead of free text. - Keep the registry small; above ~15 tools, group them behind a router tool.

ts
export const getInvoice = {
  type: "function",
  function: {
    name: "get_invoice",
    description:
      "Fetch one invoice by id. Use when the user names an invoice or asks about its status. " +
      "Do NOT use for lists or date-range searches — use search_invoices for that.",
    parameters: {
      type: "object",
      properties: {
        invoice_id: { type: "string", description: "Invoice id like INV-10231" },
        include: { type: "string", enum: ["summary", "line_items"], default: "summary" },
      },
      required: ["invoice_id"],
      additionalProperties: false,
    },
  },
} as const;

Always re-validate arguments server-side with Zod before executing: the model is a client, and clients lie.

Exercise: take a tool the model keeps misusing, rewrite only its description to say what it is *not* for, and re-measure. Description edits usually beat model upgrades.

How to study this topic

  1. 1. Read the explanation once end to end, skipping the code.
  2. 2. Re-read the code snippets and say out loud what each line does.
  3. 3. Answer the quiz without scrolling back — that is the real check.
  4. 4. Read every explanation, even for the answers you got right.

Scoring

  • · Up to 30 XP from quiz accuracy.
  • · +15 XP for a perfect first attempt.
  • · +5 XP while a 3-day streak is running.
  • · 75% or higher marks the topic complete.

Check your understanding

  1. 1. Why do tool descriptions belong to prompt engineering?

  2. 2. What should you do with the arguments a model produces?

  3. 3. A registry has 40 tools and selection accuracy collapses. Best first fix?

Badges

First light
Pass your first topic
Sharp shooter
3 perfect first-try quizzes
On a roll
Study 3 days in a row
Week warrior
Study 7 days in a row
Grinder
Earn 500 XP
Deep diver
Earn 1500 XP