AI Agent Tool Calling: From Chat to Action in 2026

AI Agent Tool Calling: From Chat to Action in 2026

What happens when you ask an AI assistant to “book me a table for two” and it actually does it? Somewhere behind that reply, the model stopped writing text and started making a structured request to a piece of software that could reserve the table. That handoff is tool calling, and it is the difference between an AI that chats and an AI that gets things done.

This article explains how tool calling works, the protocols that carry it, the security traps that come with it, and what teams actually get wrong when they wire it up for the first time.

What Tool Calling Actually Is

Tool calling, also called function calling, is a mechanism where a language model outputs a structured request, usually JSON, that names a function and supplies its arguments. The model does not run the function itself. Instead, the host application reads the request, executes the function, and sends the result back to the model so it can continue reasoning with real data.

That distinction matters more than it looks. The model is a planner, not an executor. It can propose “call `get_weather` with city=Berlin,” but the actual API request happens in your code, under your credentials, with your logging. This is why tool calling is sometimes described as giving a model hands without giving it a body. (Giving an AI agent the minimum permissions it needs)

OpenAI introduced function calling in its Chat Completions API on June 13, 2023, and the pattern spread quickly across vendors. Anthropic’s Claude models use a closely related “tool use” pattern in which the model returns a `tool_use` content block and the client answers with a `tool_result` block. The vocabulary differs; the underlying loop is the same.

The parameters a model must fill in are typically described using JSON Schema, a specification for describing the structure of JSON data. If you want to understand why a tool description like “`date` must be a string in ISO 8601 format” turns into reliable behavior, the JSON Schema specification is the place to look.

The Loop Behind Every Tool-Using Agent

The Loop Behind Every Tool-Using Agent

A single tool call is a small event. An agent is what you get when you put that event in a loop.

The loop looks like this:

  • The user asks for something that requires outside information or an action.

  • The model reasons about the goal and decides whether a tool is needed.

  • The model emits a structured call naming the tool and its arguments.

  • The host application validates the call, executes it, and captures the result.

  • The result goes back into the model’s context.

  • The model either calls another tool or produces a final answer.

This reason-act-observe cycle has a well-known academic framing. The ReAct paper by Yao and colleagues, posted to arXiv in October 2022, showed that interleaving reasoning traces with actions improves performance on tasks that need external knowledge. If you want the conceptual root of modern agent design, the ReAct paper on reasoning and acting in language models is worth reading in full.

The practical consequence is that agents can chain calls. A travel agent might check a calendar, query flights, compare prices, then book. Each step depends on the last. That chaining is powerful and also where most failures hide, because an error in step two quietly poisons steps three through six.

How Tools Get Connected: From Ad Hoc Functions to MCP

In the early days of function calling, every integration was bespoke. You wrote a JSON schema, pasted it into a prompt, and hoped the model filled it correctly. If you had ten tools, you maintained ten schemas and ten parsers.

That changed with the Model Context Protocol (MCP), an open standard for connecting AI applications to external tools and data sources, announced by Anthropic on November 25, 2024. MCP defines how a server exposes tools, resources, and prompts to a client, so the same tool can be reused across applications without rewriting the glue each time. The MCP specification and documentation explain the full architecture if you want to build a server.

Under the hood, MCP uses JSON-RPC 2.0, a lightweight remote procedure call protocol published in 2010 that defines a standard request and response message format. That choice is unglamorous but sensible: JSON-RPC is simple, transport-agnostic, and already understood by a generation of developers. The JSON-RPC 2.0 specification covers the message shapes you will see in MCP traffic.

OpenAI added MCP support to its Agents SDK and Responses API in March 2025, which signaled that the protocol was becoming a shared layer rather than a single vendor’s convenience.

Approach How tools are described Main trade-off
Ad hoc function calling JSON schema pasted into each prompt Fast to start, painful to maintain at scale
Vendor tool-use APIs Native schema fields in the API request Tight integration, vendor-specific code
MCP Standard server exposing tools, resources, prompts Reusable across clients, extra moving part to run

None of these is universally “best.” A single-purpose internal assistant with three tools does not need a protocol server. A platform connecting twenty data sources to five different AI clients probably does.

Why Tool Descriptions Are the Real Interface

Here is the part that surprises people: most tool-calling bugs are not model bugs. They are description bugs.

A model decides which tool to call based on the name and description you give it. If two tools are called `search_docs` and `find_documents`, the model will sometimes pick the wrong one, and no amount of prompt engineering will fully fix the ambiguity. Experienced teams treat tool descriptions as API documentation written for a very literal reader.

Practical habits that work:

  • Name tools by the action and the object. `create_calendar_event` beats `calendar_helper`.

  • State when not to use a tool. “Do not use this for recurring events; use `create_recurring_event` instead” prevents a whole class of errors.

  • Constrain arguments in the schema, not the prompt. Enums and required fields are enforced; polite requests in prose are not.

  • Return errors in a form the model can act on. “Invalid date format, expected YYYY-MM-DD” lets the model retry correctly. A stack trace does not.

A common mistake is stuffing thirty tools into one context and expecting clean selection. Accuracy tends to degrade as the tool list grows, so splitting tools into focused groups or routing to a sub-agent often beats brute force.

Security: Where Tool Calling Gets Dangerous

Tool calling expands the attack surface in ways that plain chat does not. A chatbot that can only produce text can mislead you. An agent that can send email, move files, or call an internal API can be manipulated into doing so.

The main risk is prompt injection, where instructions hidden in content the agent processes, such as a web page, an email, or a document, cause it to invoke tools with attacker-chosen arguments. The OWASP Top 10 for LLM Applications lists prompt injection as its first entry, and the OWASP guidance on LLM01 prompt injection explains why tool-enabled systems raise the stakes.

The defensive principles that hold up in practice:

  • Least privilege. Give each tool the narrowest scope that satisfies its job. A read-only reporting agent should not hold a token that can delete records. The discipline of giving an AI agent the minimum permissions it needs is a good starting frame.

  • Human confirmation for irreversible actions. Sending money, deleting data, and publishing content deserve a pause.

  • Treat tool output as untrusted input. A tool result can itself contain injected instructions. The loop must not blindly obey them.

  • Test before you grant write access. Read-only dry runs catch a surprising number of argument-shape and permission errors before they reach production, which is the logic behind testing AI agents before granting write access.

Teams that skip these steps usually learn the lesson the expensive way: an agent with broad credentials, a plausible-sounding instruction from a malicious document, and no confirmation step. (News)

What Teams Get Wrong in Practice

A few failure patterns show up again and again.

Assuming the model will validate. It will not reliably reject a malformed argument. Your code must validate every call against the schema before execution and return a clear error if it fails.

Ignoring idempotency. Agents retry. If a retried `charge_card` call creates a second charge, the design is broken. Tools that mutate state should accept an idempotency key.

Logging too little. When an agent does something unexpected, you need the exact tool call, arguments, result, and model reasoning that led there. Without that trace, debugging becomes archaeology.

Forgetting latency budgets. Every tool round trip adds time. A five-step chain with a two-second API can take ten seconds before the model writes a word, which users notice.

Treating the tool list as static. Tools change, APIs deprecate, schemas drift. Versioning tool definitions the way you version any public interface prevents silent breakage.

Conclusion

Tool calling turned language models from clever text generators into something closer to actors in a system. The mechanics are simple enough to explain in a paragraph: the model emits a structured request, your code runs it, the result comes back, the loop continues. The hard parts are everything around that paragraph: clear tool descriptions, tight schemas, least-privilege credentials, confirmation for irreversible actions, and logs good enough to reconstruct what happened.

The protocol layer is settling, with MCP and JSON-RPC giving teams a shared vocabulary for exposing tools. The security layer is not settled, and prompt injection remains an open problem that no single product solves. Teams that treat tool calling as a permissions and interface design problem, rather than a prompt engineering problem, tend to ship agents that behave predictably. Everyone else ships demos that impress for a week and then quietly get restricted to read-only mode.

FAQ

What is the difference between tool calling and function calling?

They describe the same mechanism. OpenAI popularized “function calling” in 2023, while Anthropic uses “tool use” and MCP simply says “tools.” In all three cases, the model emits a structured request naming a function and its arguments, and the host application executes it and returns the result.

Does the AI model actually execute the tool?

No. The model only produces a structured request. The host application decides whether to run it, runs it with its own credentials, and sends the result back. This separation is what lets developers add validation, permissions, logging, and human approval between the model’s intent and the real-world action.

What is the Model Context Protocol?

MCP is an open standard, announced in November 2024, for connecting AI applications to external tools and data sources. It defines how a server exposes tools, resources, and prompts to a client, so integrations can be reused across applications instead of rebuilt for each one. It uses JSON-RPC 2.0 for its message format.

Why do agents call the wrong tool?

Usually because tool names and descriptions are ambiguous or overlap. A model picks a tool based on the text you give it, so two similarly named tools will sometimes be confused. Clear names, explicit “do not use for” notes, and smaller focused tool sets fix most of these errors.

What is prompt injection in the context of tool calling?

Prompt injection is when instructions hidden in content the agent reads, such as a web page or document, cause it to call tools with attacker-chosen arguments. Because tool-enabled agents can take real actions, injection is more dangerous than in plain chat. It tops the OWASP list of LLM application risks.

Should every agent get write access to production systems?

Rarely at first. Start read-only, confirm the agent selects the right tools and arguments, then add write access one tool at a time with confirmation steps and audit logs. Least privilege and staged rollout catch most problems before they cause damage.

Latest articles

Scroll to Top