Prompts & Agents

Custom Tool

A function you write and expose to an agent so it can perform a specific action in your system.

In common use since 2023

A custom tool is a function you write and expose to an AI agent so it can perform a specific action in your system. Out-of-the-box, an LLM can only generate text. Custom tools are how you give it the ability to actually do things — query your database, send an email through your provider, create a ticket in your support system, kick off a workflow in your business logic.

The anatomy of a custom tool:

  • Name — short, action-oriented (create_invoice, search_customer_records).
  • Description — clear sentence explaining what it does, in language the LLM will understand. This is critical; vague descriptions produce wrong calls.
  • Argument schema — JSON schema defining the parameters: types, required fields, enums, descriptions of each.
  • Implementation — the actual code that runs when the model decides to call it.
  • Return shape — structured response the model can parse and reason about.

A well-written custom tool, expressed in pseudocode, has a name like search_orders, a description like "Search customer orders by date range, status or product. Returns up to 50 matching orders.", and a parameters schema with customer_id (required string), days_back (integer, default 30, max 365), and status (string enum of pending, shipped, delivered, returned). That structure — short clear name, sentence-long description, tightly typed parameters with sensible defaults — is the entire art of designing tools an LLM can use reliably.

The principles that produce reliable custom tools in 2026:

  • One job per tool — update_order is better than update_anything. Narrow tools are easier for the model to use correctly.
  • Idempotent where possible — repeat calls with the same arguments should be safe. Retries happen.
  • Permission-scoped — read tools and write tools should be separate; high-stakes actions should require explicit approval.
  • Robust error returns — when a tool fails, return a structured error the model can reason about and recover from, not a stack trace.
  • Validation in the tool, not the prompt — never trust that the LLM will give valid arguments; validate inside the tool and return a clear error if not.
  • Audit logging — every tool call should be logged with arguments, result and timing. This is your debugging surface when agents misbehave.

For a US engineering team in 2026, custom tools are where most of the AI product engineering happens. The LLM is roughly the same across products; what differentiates is the set of tools it can call into your specific system. A well-crafted set of 10–20 custom tools, exposed through MCP or the provider's tool-calling API, can transform an LLM from a chat box into a genuinely useful operator inside your business. Most of the operational care goes into making those tools safe, observable and correct — the LLM half is comparatively easy.

Keep exploring

Looking for something else? The full glossary covers 120+ AI terms updated for 2026.

Open the glossary
Chat on WhatsApp