Tool Schemas (Tools & JSON Schema)
A standardized formal description of tool interfaces for large language models using the JSON Schema standard. It includes the function name, a detailed textual description of its purpose, a list of required parameters, and their value types.
1. Concept Overview & Systemic Problem
Imagine you invited a new assistant to the office and told them: “Here we have a special program, use it.” But you didn’t explain what the buttons do or what fields need to be filled. Naturally, the assistant would be confused.
To ensure the language model knows what digital tools it possesses, developers provide it with a Tool Schema.
This is a compact description structured according to the JSON Schema standard:
- Name: a short name for the button (e.g.,
book_hotel). - Description: a human-readable explanation of the action's purpose.
- Parameters: the data required to execute (city, check-in date, number of guests).
Mental model: a job description for AI: a list of tools on the master’s belt with clear instructions on when to use a hammer and when to use a screwdriver.
2. How a Real Tool Schema Looks
{
"name": "calculate_mortgage",
"description": "Calculates the monthly payment for a mortgage loan.",
"parameters": {
"type": "object",
"properties": {
"loan_amount": {
"type": "number",
"description": "The total loan amount in currency, e.g., 1500000"
},
"years": {
"type": "integer",
"description": "The loan term in years from 1 to 30"
},
"interest_rate": {
"type": "number",
"description": "Annual interest rate in percentage, e.g., 7.5"
}
},
"required": ["loan_amount", "years"]
}
}
3. Four Golden Rules for Crafting a Good Schema
- Write the description as if explaining to an intern: specify not only what the tool does but also when it should NOT be called.
- Provide examples in the description field: “date format strictly YYYY-MM-DD, e.g., 2026-05-18”.
- Limit options using
enum: if the order status can only be one of three types, specify strictly:["pending", "shipped", "delivered"]. - Mark required fields in the
requiredarray: if the function cannot operate without the client's email, do not allow the model to run it blindly.
4. Production Engineering Scenarios
01. Tool Integration in a Chatbot
Integrate tool schemas into a chatbot framework to enhance user interactions. Ensure that the chatbot can dynamically call functions based on user input, leveraging the clarity of tool descriptions to minimize errors.
02. API Development with JSON Schema
Utilize JSON Schema to define API endpoints for your application. This ensures that all developers understand the expected input and output formats, reducing integration issues and improving collaboration.
03. Automated Testing of Tool Functions
Implement automated tests that validate the functionality of tools against their schemas. This will help catch discrepancies between the expected and actual behavior of functions, ensuring reliability in production.
5. Pitfalls, Common Mistakes & Security
- Ambiguous Descriptions: Vague descriptions can lead to misinterpretations by the model, causing incorrect function calls.
- Neglecting Required Fields: Failing to specify required fields can result in runtime errors when the model attempts to execute functions without necessary data.
- Inadequate Testing: Not validating tool schemas against real-world scenarios can lead to unexpected failures in production, undermining user trust and system reliability.
FAQ: Tool Schemas (Tools & JSON Schema)
Related terms
Function Calling / Tool Calling
A technical protocol and standard for LLM interaction with external software. Instead of free text, the model returns valid JSON containing the function name and typed arguments according to JSON Schema, enabling the backend to deterministically execute actions in real APIs.
Dynamic Tool Selection
An architectural approach for building scalable AI agents equipped with hundreds of tools. Instead of loading all function descriptions into the context simultaneously, the system employs semantic search or a Router model for dynamic selection of only 3-5 most relevant tools for a specific user query.
Agentic Loop: Steps of Thought ➔ Action ➔ Observation (ReAct)
A fundamental algorithmic pattern for autonomous agents, known as ReAct: Reasoning + Acting, consisting of an infinite cycle of three steps: 1) Thought — situation analysis; 2) Action — tool invocation; 3) Observation — result analysis and plan adjustment.