skip to content

In a function-calling tool definition, which parts does the model actually see?

level: juniorimportance: must knowfreq 72%

answer

  1. three fields, all of them prompt
  2. your source code is invisible
  3. name, description, parameters schema
  4. JSON Schema object with required list
  5. if a human cannot choose, neither can the model

basics

~20 s

The model sees only three things: the tool's name, its natural-language description, and the JSON Schema describing its parameters. Implementation code, docstrings and internal comments never reach it, so everything it needs must live in those three fields.

solid answer

~50 s

A tool definition is three fields, and all three are prompt. The **name** is the short identifier the model emits when it decides to call the tool. The **description** is free text saying what the capability does, when to use it and when not to. The **parameters** are a JSON Schema object — typed properties, a `required` list, enums, nested objects — telling the model which arguments are legal and, under strict modes, constraining what it may emit. Nothing else travels: your function body, your README, your type annotations and your retry logic are invisible. That is why so many "the agent called the wrong tool" bugs turn out to be schema bugs. The working test is simple: if a competent human could not pick the right tool and fill its arguments from those three fields alone, neither can the model.

code

json · 18 lines
json
{
  "name": "file_claim",
  "description": "File a first notice of loss against an existing auto or property policy. Use only when the caller states that an incident has already occurred and supplies a policy number. Do not use to check the status of an existing claim, to quote coverage, or to edit policy details.",
  "input_schema": {
    "type": "object",
    "properties": {
      "policy_number": {
        "type": "string",
        "description": "Policy number exactly as printed on the policy document, for example AP-448120."
      },
      "claim_type": {
        "type": "string",
        "enum": ["auto_collision", "auto_theft", "property_fire", "property_water", "property_theft", "liability"]
      }
    },
    "required": ["policy_number", "claim_type"]
  }
}

go deeper

for a junior

Recall the three fields — name, description, parameters JSON Schema — and be able to write a small one from memory. Say plainly that the model never sees your implementation.

for a middle

Explain that the definition is serialized into context as prompt, that the schema root is a JSON Schema object with properties and a required list, and that per-field descriptions carry format and provenance hints.

for a senior

Show the debugging move: read the serialized definitions as the model reads them when a wrong-tool or wrong-argument bug appears, and treat the definition text as the first suspect rather than the loop.

for a principal

Own the standard: a house style for names, description structure and schema shape, so definitions written by different teams read consistently to the model and stay economical in the shared context budget.

## What a tool definition is When you let a model call tools, you send a list of tool definitions alongside the conversation. The runtime serializes those definitions into the model's context, usually near the front, before the messages. The model reads them like any other text, decides whether one applies, and if so emits a structured call naming the tool and supplying arguments. Your code executes the call and returns the result into the conversation. Each definition has three parts. Field names differ slightly across providers — the schema field is called `parameters` by some and `input_schema` by others — but the trio is universal, and it is what any interviewer means when they say "write me a tool schema". ## 1. The name A short machine identifier, conventionally `snake_case`, that the model reproduces verbatim when it calls the tool. It is also the first signal the model reads. `file_claim` tells a model far more than `handler_v2` or `doAction`. Names should be verb-plus-object and should not collide in meaning with another tool in the same list. A name is cheap in tokens and disproportionately influential in selection, so it earns real thought. ## 2. The description Free natural-language text. This is where the capability's purpose, its preconditions, and the situations in which it should *not* fire live. A one-liner such as "Files a claim" is technically a description and practically a bug: it says nothing about which kind of claim, what must be true before calling, or what the caller should do instead when the request is adjacent but different. The description is the single highest-leverage field in the definition, and it is prompt, not documentation. ## 3. The parameters schema A JSON Schema object, almost always `"type": "object"` at the root, with a `properties` map and a `required` array. Each property has a type (`string`, `number`, `boolean`, `array`, `object`), optionally an `enum` to pin it to a fixed value set, and optionally its own `description`. Properties may nest: an insurance first-notice-of-loss tool might carry an `incident` object containing `occurred_at` and a nested `location`. Per-field descriptions matter as much as the top-level one, because they are where you say what format a string takes and where an argument's value should come from. Under strict or structured-output modes the schema stops being advisory and becomes a hard constraint on decoding, so the emitted JSON is guaranteed to match its shape. Without such a mode the schema is strong guidance the model usually but not always honours, which is why your handler still validates. ## What the model never sees This is the part candidates get wrong. The model does not see: - your function body or its language-level types; - the docstring in your source (unless your framework explicitly copies it into the `description` field — many do, which is exactly why an unedited docstring often becomes a bad tool description); - the database the tool writes to, the permissions it holds, or the blast radius of calling it; - comments, tests, or the wiki page explaining the workflow. Everything the model needs in order to decide *whether* and *how* to call must be inside the three fields. A tool that is dangerous to call twice must say so in its description; the model has no other way to know. ## Why this framing matters in practice Because the definition is prompt, the standard debugging move for tool-use failures is to read the definition the way the model reads it — as text, with no surrounding knowledge. Print the serialized definitions and ask: from this text alone, is it unambiguous what this does, when it applies, and what every argument means? Most wrong-tool and wrong-argument failures resolve at that step, before anyone touches the agent loop. The corollary is cost. Because definitions are context, they are paid for on every request that carries them, and they compete for attention with the actual conversation. Definitions are therefore written with the economy of a prompt, not the completeness of API reference documentation: decision-relevant information in, encyclopaedic detail out.

  • Your framework auto-generates tool descriptions from Python docstrings. What is the risk?
    Docstrings are written for maintainers, so they explain implementation and omit exactly what the model needs: preconditions, when not to call, and where argument values come from. Auto-generation is a fine starting point but the generated text should be reviewed and rewritten as instruction. Treat generated definitions as drafts and check the serialized output the model actually receives.
  • Where do a tool's permissions and side effects belong in this picture?
    Enforcement belongs in your code — the model must never be the security boundary. But the model still needs to know a tool is destructive or irreversible so it can reason about ordering and ask before acting, and the only channel for that is the description. So you state it in the description and enforce it independently in the handler.

The tool definition is the job advert, not the employment contract. The model applies on the strength of the advert alone; everything you kept in the contract it never reads.

saying these in an interview costs you the question

  • Thinks the model can read the tool's implementation code
  • Believes the schema is validated only after execution
  • Names tools generically like run or process
  • Assumes a docstring makes an adequate tool description
  • Says tool definitions are sent once at session start

context