Let's talk

Agentic AI Essentials

Tool Calling: The Bridge Between LLMs and Action

Tool calling is the mechanism that enables an AI agent to move beyond text generation and perform real-world actions like querying a database or sending a message.

By Divyaprakash JhaUpdated 5 min readTopic: Agentic AI

Photo for Tool Calling: The Bridge Between LLMs and Action

Tool calling is the mechanism that allows an AI agent to move beyond simple text generation to perform real-world actions. By emitting structured commands, a model can trigger code that queries databases, sends messages, or interacts with external APIs to complete a specific goal.

What is Tool Calling?

At its core, tool calling is how a Large Language Model (LLM) interacts with the physical or digital world. While a standard chatbot can only talk about a topic, an agentic system uses tools to do something about that topic.

When a user asks a question that requires external data, the model does not simply guess. Instead, it identifies that it needs a specific "tool" to get the correct answer. The process works in three distinct steps:

  • Identification: The model analyzes the user's request and decides which function is needed and what specific parameters (like an ID number or a date) are required.
  • Structured Output: The model emits a structured call—essentially a piece of code—instead of a conversational sentence.
  • Execution and Feedback: Your software executes that function (the actual "work"), and the result is fed back into the model's context so it can explain the outcome to the user.

For a business owner, this transforms an AI from a research assistant into an active employee. Instead of just explaining how to check an invoice, the agent can actually search invoices, send a WhatsApp message to a client, or create a booking in a clinic's management system.

The Agentic Loop and Tool Use

To use tools effectively, an agent must operate within a continuous cycle known as an agentic loop. This is the fundamental agentic architecture that separates a simple chatbot from a functional AI worker. An agent does not just perform one action and stop; it follows a repetitive cycle to reach a goal.

The loop typically follows these stages:

  1. Goal: The agent receives a task with a clear definition of what "done" looks like (e.g., "Reconcile these GST invoices against the bank statement").
  2. Plan: The model decides the next step required to reach that goal.
  3. Act: This is the critical phase where tool calling occurs. The agent triggers a function to get data or perform a task.
  4. Observe and Verify: The agent reads the result of the tool. It asks: "Did the API return an error? Did the invoice total match the bank entry?"
  5. Repeat or Stop: Based on the observation, the agent either plans the next step or reports that the job is finished.

It is vital for builders to understand that the reliability of an agent often depends more on the loop logic (the code you write to handle the tools) than on the raw intelligence of the model itself. If the code doesn't handle a tool error correctly, the agent will get stuck in a loop of failure.

Designing Effective Tools

Not all tools are created equal. If you give an AI agent a tool that is too complex or too vague, it will likely fail. To build production-grade systems, you must design your functions with the model's limitations in mind.

Guidelines for Tool Design

  • Narrow Scope: A tool should do one thing well. Instead of a generic handle_data() function, use get_customer_address().
  • Descriptive Naming: The name of the tool is the primary way the model knows when to use it. Use clear, unambiguous language.
Feature Bad Tool Design Good Tool Design
Scope process_everything() calculate_gst_tax()
Output Size Returning 40,000 rows of data Returning a summary of the top 5 rows
Error Handling "System Error" "Invalid Date Format: Expected YYYY-MM-DD"

Governance and Guardrails

As agents move from "reading" data to "writing" data, the risks increase. An agent that can send messages or move money needs strict governance. You should never rely on the model's "willingness" to follow rules; instead, you must enforce rules through code.

Risk Classification

Every tool in your system should be assigned a risk class. This allows you to set different levels of autonomy based on how much damage a mistake could cause:

  • Read/Fetch: Low risk. The agent can look up a price list or a customer's name.
  • Write: Medium risk. The agent can update a shipping address or add a note to a CRM.
  • External/Critical: High risk. The agent can issue a refund, send a WhatsApp message to a client, or trigger a bank transfer.

Implementing Guardrails

A robust system uses human-in-the-loop patterns for high-risk actions. For example, if an agent is tasked with "resolving customer complaints," it might be allowed to draft a refund, but the actual execution should require a human to click "Approve" in a dashboard. This is a core component of a professional Shiva Agents deployment, where autonomy levels can be set from "Observe" to "Autonomous."

Effective governance also includes audit trails. Every tool call should be logged in a way that cannot be edited, providing a clear history of exactly what the agent did and why.

Common Tool-Using Patterns

When building your agentic workflows, you don't always need to reinvent the wheel. There are several established patterns for how models use tools to solve problems. Choosing the right pattern depends on whether your task is predictable or open-ended.

ReAct (Reason + Act)
The most common pattern for open-ended tasks. The agent writes out its "thought" process, calls a tool, observes the result, and then reasons again. It is excellent for troubleshooting or research where the path to the answer isn't known in advance.
Plan-and-Execute
The model creates a full, step-by-step plan of all required tool calls before any action is taken. This is highly beneficial for business owners because the plan can be reviewed and approved by a human before the agent starts executing expensive or sensitive tasks.
Router
A "router" is a small, fast model that acts like a receptionist. It classifies the incoming request and directs it to a specific specialized toolset. For example, if a customer asks about billing, the router sends the task to a "Billing Agent" rather than a general assistant.

For more complex setups where multiple agents must work together, you might explore advanced topologies like Agent-to-Agent (A2A) communication or multi-agent teams. However, for most business applications, starting with a well-defined Router or a Plan-and-Execute workflow provides the best balance of flexibility and control.

Yellow robotic arm operating inside a glass enclosure with a monitor above.
Photo: Robot arm works on a small component in a lab setting by Shixart1985, CC BY 2.0

Questions people ask

How is tool calling different from function calling?

While often used interchangeably, tool calling refers to the model's ability to select and structure arguments for a function, which your code then executes to bridge the gap between reasoning and action.

Can an agent call tools without a human?

Yes, depending on the autonomy level set. You can define 'always allow' rules for low-risk tools or require 'human approval' for high-risk actions.

What happens if a tool returns an error?

In an agentic loop, the error message is fed back to the model as an observation, allowing the agent to attempt a different approach or ask for help.

What makes a tool 'good' for an AI agent?

A good tool has a narrow scope, clear naming, typed parameters, and returns information that is short enough to fit within the model's context window.

Do I need a strong model for tool calling?

You should prioritize models with high reliability in instruction following and structured output, rather than just looking at raw benchmark scores.