New Tool Radar

AI Concepts

How to Define a Function Tool with a JSON Schema for an Agent

Define a function tool for an agent with a name, a description of when to use it, and a parameters schema.

Schematic illustration of define a function tool with a json schema for an agent: step one name the job, step two write the description, step three schema the parameters.

A function is a specific kind of tool, defined by a JSON Schema: a name that identifies it, a description that helps the model understand when to use it, and a parameters schema that specifies the expected inputs. The description is the most important part, because it is what the model reads when deciding whether to call the function at all.

Prerequisites

  • The job the function does, in one sentence.
  • The function’s inputs, with names and types.
  • The function calling guide open for the schema shape.

Steps

Step 1: Name the job

Give the function a plain verb-based name, such as lookup_order or get_book, that says what it does. The model sees the name first, so a vague name leads to wrong calls.

Step 2: Write the description

Write one or two sentences saying when to use the function and what it returns. Include the limits: what the function cannot do, so the model does not call it for the wrong job.

Step 3: Schema the parameters

Write the parameters schema: each argument’s name, type, description, and whether it is required. Mark the arguments the function cannot run without as required, and leave the rest optional.

Worked example: Northgate Clinic appointment lookup

The fictional Northgate Clinic defines a lookup_appointment function for its agent.

Part Value Why it matters
Name lookup_appointment Says what it does
Description Finds an appointment by patient name and date Tells the model when to call it
Parameter patient string, required Cannot look up without a name
Parameter date string, required Cannot look up without a date
Parameter clinic string, optional Defaults to the main clinic

The function has a verb-based name, a description of when to use it, and 3 parameters, 2 required and 1 optional, so the model can call it correctly.

Expected result. The function definition has a name, a when-to-use description and a complete parameters schema. UNTESTED: this guide was not run against a live model or API. The worked example below is fictional practice material, and its result is the expected result, not a measured one.

Limits

  • The model generates arguments; it does not run the function. Your code must validate the arguments.
  • A missing description is the most common cause of wrong tool choices.
  • This guide does not cover custom tools with free-form text inputs.

Sources

See all