Course contentsShow
← Machine Learning and Deep Learning
Lesson 2072 of 3,53844. AI Agents: FoundationsFree lesson

Tool Schema Definition

How to define tool schemas with parameters, types, descriptions, and constraints for LLM understanding.

Tool Schema Definition

What you'll learn: How to explicitly structure tool descriptions so an LLM agent knows exactly what parameters a tool accepts, what types they are, and how to use them correctly.

The Challenge of Tool Invocation

When your AI agent decides to use a tool (like a web search function or database query), it needs precise instructions. The LLM doesn't inherently "know" what parameters search_products(query, max_results, category) expects. Without a clear schema, the agent might pass a string where an integer is required, omit mandatory fields, or misunderstand what each parameter does.

What is a Tool Schema?

A tool schema is a structured specification that describes:

  • Tool name: The function identifier
  • Description: What the tool does (guides action selection)
  • Parameters: Each argument's name, type, description, and constraints
  • Required vs. optional fields: Which parameters are mandatory
  • Return value description: What the tool produces

Think of it like an API documentation page, but formatted specifically for LLM consumption—typically as JSON or structured text.

Example Structure

{
  "name": "search_products",
  "description": "Search the product catalog by keyword",
  "parameters": {
    "query": {
      "type": "string",
      "description": "Search keywords",
      "required": true
    },
    "max_results": {
      "type": "integer",
      "description": "Maximum number of results",
      "default": 10,
      "minimum": 1,
      "maximum": 50
    },
    "category": {
      "type": "string",
      "enum": ["electronics", "clothing", "books"],
      "required": false
    }
  }
}

The schema guides the LLM to generate valid tool calls with correct types and constraints, reducing errors in the perception-action loop.

Key Takeaway: Tool schemas are structured specifications that teach LLMs exactly how to invoke tools correctly by defining parameter names, types, descriptions, and validation constraints—essential for reliable agent behavior.