AI Agent Tool Calling: How to Design Reliable Function Schemas

Tool calling is where most AI agent projects fall apart. Not at the model layer — the model is usually fine. The failure happens in the function schema: the JSON contract that tells the model what tools exist, what arguments they accept, and what they return. Get that contract wrong and the agent halts, hallucinates a parameter, or silently passes bad data downstream.
This guide is for engineers and technical leads building custom AI agents who want their tool-calling layer to be reliable in production — not just in demos.
What Tool Calling Actually Is
When an LLM like GPT-4o or Claude 3.5 Sonnet is given a list of tools, it doesn't execute those tools itself. It generates a structured JSON object describing which tool to call and what arguments to pass. Your runtime intercepts that JSON, validates it, calls the real function, and feeds the result back to the model.
The schema you define — typically in OpenAI's function-calling format or an equivalent — is the only instruction the model has about how to use each tool correctly. It reads your description, your parameters object, and any enum constraints. That's it. There is no implicit knowledge. If your schema is ambiguous, the model will guess, and guesses compound across multi-step agent runs.
The pattern looks roughly like this:
{
"name": "get_order_status",
"description": "Returns the current status and estimated delivery date for a given order ID.",
"parameters": {
"type": "object",
"properties": {
"order_id": {
"type": "string",
"description": "The alphanumeric order identifier, e.g. 'ORD-00482'."
}
},
"required": ["order_id"]
}
}
Simple enough — until production introduces optional parameters, nullable returns, ambiguous states, and downstream tools that depend on the output of this one.
The Four Most Common Schema Mistakes
In our engagements building custom AI agents, these four mistakes account for the majority of tool-calling errors we debug.
1. Descriptions that describe the function name, not the function's behavior.
"description": "Gets the order status" tells the model nothing it couldn't infer from the function name. A useful description tells the model when to call the tool, what preconditions need to be true, and what it will and won't return. Write the description as if you're explaining the tool to a junior engineer on their first day — because effectively, you are.
2. Missing or vague required arrays.
If a parameter is optional, the model needs to know what happens when it's omitted. If it's required, list it. Don't leave required parameters out of the required array hoping the model will figure it out from the description. It won't, consistently.
3. Overloaded tools.
A single tool that handles twelve different operations based on an action parameter is a schema anti-pattern. The model has to pick the right value from a long enum while also constructing all the other parameters correctly. Break it into separate tools. Yes, the tool list gets longer — that's fine. Clarity beats brevity here.
4. No format examples in parameter descriptions.
If a parameter expects an ISO 8601 date string, say so and give an example: "The start date in ISO 8601 format, e.g. '2026-01-15'." If it expects a specific ID prefix, show it. The model uses these examples to self-validate before generating output.
Schema Design Principles That Hold Up in Production
Be explicit about what the tool will not do
Negative constraints in descriptions are underused. If search_products only searches the product catalog and not orders or customer records, say that. This prevents the model from using the wrong tool when an ambiguous query could match multiple tools.
Use enums aggressively for constrained values
If a parameter can only be one of five values, define an enum. Don't accept a freeform string and then validate downstream — the model will generate cleaner output when it knows the constraint up front, and you'll catch errors earlier.
"status_filter": {
"type": "string",
"enum": ["pending", "processing", "shipped", "delivered", "cancelled"],
"description": "Filter orders by status. Use 'shipped' for orders in transit."
}
Design for the unhappy path
What does the tool return when nothing matches a query? What does it return on a network timeout? The model needs to handle these states gracefully. If your tool can return an empty result, document that in the schema description so the model knows to check before acting on the output. This is closely related to the failure modes we covered in Agent Failure Modes: What Breaks Custom AI Agents in Production.
Keep parameter counts low
If a tool has more than five or six parameters, reconsider the design. Either the tool is doing too much, or some parameters should be bundled into a nested object. Every additional parameter is another surface for the model to make a mistake.
Schema Quality Checklist
Use this before promoting any tool to a production agent:
| Check | What to verify |
|---|---|
| Description clarity | Does it explain when to call the tool, not just what it does? |
| Format examples | Do string parameters with specific formats include an example value? |
| Required array | Are all truly required parameters listed? |
| Enum coverage | Are constrained-value params using enum instead of freeform strings? |
| Negative constraints | Does the description say what the tool won't return or handle? |
| Empty/error states | Is the return behavior on failure or empty results documented? |
| Single responsibility | Does the tool do one thing, not many things via an action parameter? |
| Parameter count | Is the parameter count five or fewer (excluding optional ones)? |
Run every tool through this before wiring it into an agent. It takes five minutes per tool and saves hours of debugging.
Testing Tool-Calling Behavior Before Production
Evaluating agent tool use is not the same as unit testing a function. You need to test the model's decision to call the tool and the arguments it constructs — not just the function's output.
Adversarial prompts. Write user inputs designed to confuse the model about which tool to use. If two tools are semantically close, verify the model picks the right one under ambiguous conditions.
Argument injection tests. Give the agent inputs that include values that look like valid arguments for the wrong tool. Check that it doesn't cross-contaminate.
Missing-data scenarios. What happens when the user's request doesn't include enough information to construct a required argument? The agent should ask for clarification, not hallucinate a value. Schema design can help here — if a parameter is required and has no reasonable default, the model is more likely to ask rather than guess.
Parallel tool call tests. Some runtimes allow the model to call multiple tools in parallel. Test that the schema ordering and naming don't create collisions when tools run simultaneously.
If you're building a production AI agent and want a schema review before launch, our AI app development team works through exactly this kind of architecture — function design, runtime validation, and evaluation frameworks end to end.
Versioning and Evolving Schemas Over Time
Schemas change. New parameters get added, old ones get deprecated, return formats shift. Treat schema changes with the same discipline you'd apply to a REST API breaking change.
A few rules that prevent silent regressions:
- Version your tool definitions. Even a simple
v1/v2suffix on the tool name in staging lets you run the old and new schemas in parallel before cutover. - Deprecate before removing. If a parameter is going away, add a deprecation notice to its description for at least one release cycle before removing it.
- Re-run your eval suite on every schema change. A parameter rename or description rewrite can shift model behavior in ways you won't catch without running the full evaluation. We wrote about building those eval suites in AI Agent Evaluation Frameworks: How to Score Performance Before Shipping.
- Log every tool call with the full argument payload. This is non-negotiable. Without these logs, debugging production failures is guesswork.
Frequently Asked Questions
How long should a tool description be?
Long enough to be unambiguous, short enough to stay within context budget. Typically two to five sentences. If you need more than that, the tool is probably doing too much.
Should I include return value schemas in the function definition?
Yes, where your framework supports it. Describing what the tool returns — including error states — helps the model reason about what to do with the output. OpenAI's function-calling spec focuses on input parameters, but you can document return behavior in the top-level description.
How many tools can an agent have before performance degrades?
This depends on the model and the runtime, but in our engagements we've seen reliable performance up to approximately 15–20 well-named tools. Beyond that, retrieval-augmented tool selection (where the agent first picks a subset of relevant tools before calling) tends to perform better than presenting the full list in every context window.
What's the difference between tool calling and function calling?
Functionally, the same thing in most frameworks. OpenAI originally called it "function calling," then introduced "tool calling" as a broader concept that includes retrieval and code execution alongside custom functions. When people say "tool calling" today, they typically mean the general pattern of the model outputting a structured call to external functionality.
Should each agent have its own tool set, or can tools be shared across agents?
Tools can absolutely be shared — and in multi-agent systems they usually are. Define tools as independent modules and compose them into agent-specific tool sets. This keeps your schema maintenance centralized and your agents lean.
How do I handle authentication inside a tool?
Authentication should be handled at the runtime layer, not inside the schema. The model should never see API keys or tokens. Your tool wrapper function holds credentials and injects them before making the external call. The schema only describes the logical arguments the model needs to provide.
If you're in the middle of building a custom AI agent and the tool-calling layer is giving you trouble, book a call or reach out to our app development team — we'll look at your schema design and tell you exactly where the gaps are.