StackLift
All terms

Glossary

Tool calling

How a language model asks software to run an action, such as a search or database query, and uses the result.

Tool calling, also called function calling, is a feature where a language model returns a structured request to run a named tool with specific arguments, instead of plain text. Your application runs the tool, sends the result back, and the model uses it to continue or to write the final answer.

You describe each tool to the model with a name, a description and a schema for its inputs. When the model decides a tool would help, it replies with the tool name and arguments. The model does not run the tool itself; your code does, which is where permissions and checks belong.

Tool calling is what turns a model that only writes text into one that can act: look up an order, check a calendar, create a ticket. It is the base layer under AI agents.

Providers such as OpenAI, Anthropic and Google all support it, with small differences in format. Standards like MCP aim to make tools reusable across them.

Start in 60 seconds

Put this to work on your project.

Get an AI-assisted, architect-reviewed scope, cost range, and timeline. Free, no login.

The complete guide

Tool calling: the complete guide

Updated November 18, 2026 ยท Published by , Founder, StackLift AI. Written with AI assistance; how we make content.

Short answer

Tool calling lets a language model request an action by returning a structured call, a tool name plus arguments, instead of plain text. Your application runs the tool, returns the result, and the model continues. The model never executes anything itself, so your code controls permissions, validation and limits.

What is tool calling?

A language model can only produce text. Tool calling gives it a way to ask for things it cannot do alone: fetch live data, run a calculation, send a message. You list the tools it may use; it chooses when to call one and with what inputs.

It is also known as function calling. The terms are used interchangeably, though some vendors use "tool use" for the broader feature, including tools run on the provider's side.

How does tool calling work step by step?

  1. You send the model the user's request and a list of tool definitions.
  2. The model replies with a tool call: a name and arguments in a structured format.
  3. Your code validates the arguments and checks permissions.
  4. Your code runs the tool, such as an API request or a database query.
  5. You send the result back to the model.
  6. The model either calls another tool or writes the final answer.

Repeating this loop is what makes an AI agent. The quality of each tool's name, description and input schema strongly affects whether the model uses it correctly.

What kinds of tools do agents use?

Common tool types
TypeExampleRisk level
Read-only lookupSearch help center, fetch an orderLow, but check data access
ComputationRun a calculation, query analyticsLow to medium
Write actionCreate a ticket, update a recordMedium; log and limit
Irreversible actionSend an email, issue a refund, deployHigh; require approval

Match the safeguards to the risk. Read-only tools can run freely; irreversible ones should pause for a person.

Tool calling vs. MCP: how are they related?

Tool calling is the model-side capability: returning a structured request. MCP is a protocol for how tools are packaged and discovered by clients. A client can use MCP to find tools, then pass them to the model through tool calling. They work at different layers and are often used together.

How do you design good tools?

  • Give each tool one clear job and a plain-language description.
  • Use strict input schemas with allowed values where possible.
  • Return concise, structured results, not huge dumps.
  • Return clear errors the model can act on.
  • Keep the list short; too many tools make wrong choices more likely.
  • Scope credentials to the minimum for each tool.

Validate every call in your code. A model can produce a malformed or unexpected argument, so never pass its output straight to a database or shell.

What are the risks of tool calling?

The main one is that nothing ensures the model chooses correctly. It may call the wrong tool, use wrong arguments or be steered by hostile text in a tool result (prompt injection). Cost can also rise when an agent loops.

  • Validate inputs and enforce permissions in code.
  • Add approvals for consequential actions.
  • Limit the number of calls per task.
  • Log every call and result for review.
  • Test with adversarial cases (AI red teaming).

How do you start adding tools to an AI feature?

Begin with read-only tools, such as a lookup of order status or a search of your help center. They deliver value with little risk, and they show you how the model chooses and uses tools before you give it any power to change things.

Add write actions one at a time, each with validation, a limit and logging. For anything irreversible, add an approval step. A short AI Scope Sprint is a good way to list the tools and their risk before building.

  1. List the actions the feature needs.
  2. Sort them by risk.
  3. Build the read-only ones first.
  4. Add writes with limits and logs.
  5. Test with real and hostile cases.

How StackLift approaches tool design

StackLift scopes each tool as a deliverable with its permissions, validation, approval rule and monitoring, and agents never touch production secrets. Observability and rollback are planned from sprint one. See LLM integration, AI agent development and the free estimate.

What does a tool call look like in a real request?

Imagine a support assistant with one tool called get_order_status that takes an order number. A customer writes: where is order 4821? The model does not guess. It replies with a structured request instead of text, naming the tool and the argument it wants to use.

One round trip, piece by piece
StepWho actsWhat happens
1. DefinitionYour appSends the tool's name, description and input schema along with the question
2. RequestModelReturns a call: tool get_order_status, argument order number 4821
3. ValidationYour appChecks the arguments and that this user may see this order
4. ExecutionYour appCalls your order system and gets a result
5. ResultYour appPasses the result back to the model as a tool message
6. AnswerModelWrites a plain reply: your order shipped and arrives soon

The model never touches your order system. It proposes, your code decides and acts. That separation is what makes the pattern safe to build on.

What types of tools can a model call?

Tool categories
TypeExamplesRisk level
Read-only lookupsOrder status, knowledge search, calendar availabilityLow; mainly data exposure
Calculations and codeMath, data transformation, running a sandboxed scriptLow to medium; limit what the code can reach
Write actionsCreate a ticket, update a CRM record, draft an emailMedium; needs validation and logging
Irreversible or costly actionsRefunds, payments, deleting data, sending to customersHigh; add human approval; see human in the loop
Provider-run toolsWeb search or code execution hosted by the model vendorDepends on vendor settings and data handling
Other agentsA specialist agent called as a toolCompounds the risk of each; see multi-agent systems

Group tools by risk, and give each group its own rules for approval, rate limits and audit trail.

How do you describe a tool so the model uses it well?

The model reads your tool definition the way a new colleague reads a handover note. A vague note leads to wrong choices, so write it carefully. Use a clear verb-and-noun name, a description that says when to use it and when not to, and a typed schema for inputs.

  • Name tools by what they do: search_help_center, not tool1.
  • Say when to use the tool and what it returns, in one or two plain sentences.
  • Constrain inputs with types, enums and required fields, so invalid values are impossible.
  • Describe each parameter with an example of a valid value.
  • Return compact, useful results, not an entire database row of fields the model does not need.
  • Return clear error messages that tell the model what to do next, such as order not found, ask the customer to check the number.

If two tools overlap, the model will confuse them. Merge them or sharpen the descriptions until each has one obvious job.

How do you measure whether tool calling works?

  • Tool selection: did the model pick the right tool for the request?
  • Argument accuracy: were the arguments valid and correct for the situation?
  • Task completion: did the full conversation reach the right outcome?
  • Unnecessary calls: did it call tools it did not need, adding delay and cost?
  • Error recovery: when a tool failed, did it retry sensibly or ask for help?
  • Refusals and blocks: were disallowed actions stopped by your checks?

Keep a test set of realistic requests, including tricky and hostile ones, and re-run it after each prompt, tool or model change. See agent evaluation and the AI agent evaluation checklist.

Which technologies support tool calling?

Major providers expose tool calling in their APIs, including OpenAI, Anthropic Claude and Google Gemini, with minor differences in naming and format. Frameworks such as the Vercel AI SDK, LangChain and LangGraph, and cloud services such as AWS Bedrock and Azure OpenAI, wrap the loop so you do not hand-write it. Support, limits and the way tools run differ by model, so confirm in current documentation before you choose.

What does tool calling mean for cost and timeline?

Each tool is a small integration project: connecting to a system, handling its errors, enforcing permissions and testing edge cases. Running cost also rises, because tool definitions and results are sent as tokens and an agent may loop several times per task. Effort grows with the number of tools, how sensitive their actions are and how strict the approval rules need to be.

The AI agent cost pages show what shapes budgets by use case, and the free estimate scopes an agent feature by feature.

What should you log and review for tool calls?

A tool call is an action taken on someone's behalf, so keep a record that a person can read later. Good logs turn a mysterious agent into one you can debug, audit and improve.

  • Who asked, and which user's permissions applied to the call.
  • The tool name, the exact arguments and the time.
  • The result or error that came back, trimmed of sensitive fields.
  • Whether a person approved the action, and who.
  • The model, prompt version and settings in use at the time.

Review a sample regularly and alert on unusual patterns, such as a burst of write calls or repeated failures. This is the same discipline as AI observability applied to actions.

Questions people ask

Is tool calling the same as function calling?

In practice, yes. Both describe a model returning a structured request to run a named function with arguments.

Does the model run the tool?

No. The model only asks. Your application runs the tool and returns the result, which is why validation and permissions belong in your code.

Which models support tool calling?

Current models from major providers, including OpenAI, Anthropic and Google, support it, with differing formats. Check each provider's documentation.

How many tools can an agent have?

There is no fixed limit, but a long list makes wrong choices more likely. Keep tools few and clearly described, or load only the ones a task needs.

How do I stop a model calling a tool it should not?

Only expose tools the task needs, check permissions in your code before running anything, and require approval for risky actions.

Can a model call several tools at once?

Many models can request more than one call in a single turn, and your code can run independent ones in parallel. Check the provider's documentation, and make sure each call is validated separately.

What if the tool returns an error?

Pass a clear error message back to the model. It can often correct its arguments or explain the problem to the user. Put a limit on retries so a failing tool cannot cause an endless loop.

Is tool calling safe for customer data?

It can be, when your code enforces access rules on every call instead of trusting the model. Check that the signed-in user may see the record, log each call, and keep secrets out of prompts.

Do I need an agent framework to use tool calling?

No. A simple loop in plain code works for a handful of tools. Frameworks help when you need state, branching, retries or several agents working together.

Sources

Sources and further reading

The standards, rules, research and official documentation this page draws on.