Tools and Function Calling
- Explain the three-step mechanism of function calling in LLMs
- Identify the properties of a well-designed tool
- Describe at least four common tool types used in AI agents
The Gap Between Thinking and Doing
A language model on its own can reason about almost any problem. What it cannot do — without tools — is look something up in real time, run a calculation, write a file, or send an email. Tools close that gap. They are what turn a text-completion engine into a system that takes actions.
How Function Calling Works
Tool calling (also called function calling) follows a simple three-step loop:
- Step 1 — Describe: you give the model a list of available tools, each described in a structured schema: name, description, and parameters with types
- Step 2 — The model decides: when the model needs to use a tool, it emits a structured call with the tool name and arguments, usually as JSON — it does not run the code itself
- Step 3 — Your app executes: your application runs the function and returns the result to the model, which then uses it to continue
A critical detail: the model never executes code directly. It outputs a structured request, and your application decides whether and how to run it. The result is fed back into the conversation and the model continues from there.
What Makes a Good Tool
Tool design is one of the most underrated aspects of agent quality. A model working with well-designed tools will consistently outperform the same model with poorly designed ones. The key properties of a good tool are:
- Clear description — the model decides which tool to call based on your description; vague descriptions produce unreliable tool selection
- Predictable outputs — consistent return formats that the model can easily interpret
- Explicit error responses — when a tool fails, it should return a structured error the model can reason about, not an empty result or an exception
- Minimal scope — a tool that does one thing well is easier to use correctly than a Swiss Army knife
Common Tool Types
Most agent tool libraries draw from the same set of capabilities:
- Web search — retrieve current information the model wasn't trained on
- Code interpreter — run Python or other code and return output
- File system — read, write, create, or delete files
- API calls — interact with external services: CRM, calendar, payment, database
- Browser automation — navigate web pages, fill forms, extract content
- Memory retrieval — query a knowledge base or vector database
Tool Calls in a Multi-Step Agent
In a single-turn setup, one tool call produces one result. In an agentic loop, the model may call a dozen tools in sequence, each building on the previous one. This is where the design of each tool matters most: a poorly formatted result at step 3 can mislead everything that follows.
Security Considerations
Tool use introduces real attack surface. In 2025, security researchers demonstrated what they called "The Dark Side of Function Calling" — a class of attacks where malicious content in a tool's output is designed to manipulate the model's next action. If your agent calls tools that touch untrusted content (web pages, user-submitted documents, external APIs), you need an explicit policy on what the model is allowed to do with the results.
- The model never runs code — it emits a structured JSON request; your application executes the function and returns the result
- Tool design quality matters as much as model quality — vague descriptions and inconsistent outputs are a leading cause of agent failures
- Common tool types: web search, code interpreter, file system, API calls, browser automation, memory retrieval
- In a multi-step agent, poorly formatted tool output at any step can mislead all subsequent reasoning
Progress is saved in this browser only — clear your cache or switch device and it's gone. Create a free account and it follows you everywhere.