AI, explained

What is tool calling?

Tool calling is the moment a language model stops writing text about your systems and starts touching them.

What is tool calling? Tool calling is a mechanism where a language model, instead of answering in prose, emits a structured request to run a named function with specific arguments. Your code executes that function, returns the result, and the model continues with real data. It is how an assistant becomes an agent.

The model never runs anything itself. You give it a list of functions with names, descriptions and an argument schema. It decides which one fits the request and produces a JSON payload matching that schema. Your application validates the payload, runs the actual code, and hands the output back. The model is choosing, your system is doing. Keeping that distinction clear in your head prevents most of the security mistakes people make here.

Schema design is the whole job

A tool the model uses correctly and a tool it misuses are usually the same function with different descriptions. Some things that reliably help:

The permission boundary

Treat every tool call as arriving from an untrusted client, because functionally it is. The model may be reasoning over a customer email, a scraped page or a PDF, and anything in that content can try to steer it. Authorisation belongs in your code, checked against the authenticated user's real permissions, never in the prompt telling the model what it is allowed to do. A prompt instruction is a suggestion. A permission check is a control.

Draw a hard line between read tools and write tools. Reads can be broad and cheap. Writes should be narrow, logged with the input that triggered them, idempotent where possible, and reversible or gated by human confirmation when the action costs money, sends something external or deletes anything.

What breaks in production

Three failures show up repeatedly. The model calls the right tool with a hallucinated identifier, which strict schemas and an existence check catch. The model loops, calling the same tool with slight variations, which a call budget and a clear stop condition catch. And a tool fails silently, returning an empty result the model then narrates as a fact, which is why error responses should say plainly that the call failed rather than returning nothing. An AI audit usually starts by mapping which of your systems can safely be reached this way at all.

Frequently asked questions

What is tool calling in AI?

Tool calling is a mechanism where a language model returns a structured request to run a named function with arguments instead of answering in text. Your application validates and executes it, then returns the result so the model can continue with real data. It is what separates an agent that acts from a chatbot that describes.

Is tool calling the same as function calling?

They are the same mechanism under two names. Function calling was the earlier term used when models could request a single function, and tool calling became standard as providers added parallel calls, built-in tools like code execution and search, and protocols such as MCP for exposing tools across systems.

Is tool calling safe for write operations?

It is safe when authorisation lives in your code rather than the prompt. Check every call against the authenticated user permissions, keep write tools narrow and logged, make them idempotent where you can, and require human confirmation for anything that moves money, sends a message externally or deletes records.

Related

AI SEO in LisbonAI agency in LisbonBook an AI audit

Ready to put AI to work?

Book a discovery audit and we will map the highest-ROI AI agents and automations for your business.

Book a discovery audit →