The secret power of LLM: Tool calling
Here is a puzzle. An LLM can only do one thing: read text and write text. That's it. So how does ChatGPT check today's weather? How does your coding assistant run your tests? How does any AI agent actually do things? The answer is a mechanism called tool calling (you'll also see it called function calling), and it is the one of most the important building block of AI agents.
💡 Note: No code needed to follow along. If you have ever watched a hospital drama on TV, you already understand tool calling.
Think of an operating room
Picture a surgeon in the middle of an operation. She is brilliant, focused, and completely scrubbed in. She never leaves the table, never digs through drawers, never runs down to the lab. When she needs something, she says one word: "Scalpel." A surgical tech picks the right instrument from the tray and places it in her hand. She works, then calls again: "Suction." Need a blood test mid-surgery? She doesn't run it herself. She asks, someone else runs it, and the result is read back to her.
The surgeon supplies the judgment. The team supplies the hands.
That is exactly how an LLM uses tools. The model is the surgeon: smart, but physically unable to touch the outside world. Your code is the surgical tech: not making the decisions, but the only one who actually picks things up. And the instrument tray? That's the list of tools you prepared before the operation started.
What is a tool call, really?
A tool call is a structured request that the model writes instead of a normal answer. Before the conversation starts, you hand the model a menu of tools, each with a name, a short description, and the exact shape of input it expects. Then, when you ask "what's the weather in Paris?", the model doesn't guess. It looks at the tray, picks a tool, and writes something like this:
📦JSON1234{ "name": "get_weather", "input": { "city": "Paris" } }
Notice what just happened. The model did not call any weather API. It asked for the weather tool, the way the surgeon asks for the scalpel. Your code receives this request, actually calls the weather API, and sends the answer back into the conversation. Only then does the model write its final reply: "It's 18°C and cloudy in Paris."
💡 Attention! Remember this: the model never executes anything. It only writes a request. Your code has the hands, and nothing happens unless your code makes it happen. This is true whether you use Claude or GPT, the loop is the same everywhere.
So how does the full loop work?
Great question! Every tool-using conversation runs the same five-step loop:
- You send the prompt plus the tool menu. "What's the weather in Paris?" along with the list of tools and their descriptions.
- The model answers with a tool call. Instead of prose, it returns the structured request you saw above: a tool name and JSON arguments.
- Your code executes the tool. You call the real weather API, query the real database, or run the real command.
- You send the result back. The tool's output goes into the conversation as a new message, like the lab result being read back to the surgeon.
- The model continues. It either writes the final answer, or calls another tool, and the loop runs again.
That last part is the magic. The loop can repeat. Ask an assistant to "find my cheapest flight to Rome and add it to my calendar" and it will call a flight search tool, read the results, then call a calendar tool with the winner. Modern models can even request several independent tools in one turn, like a surgeon calling for two instruments at once.
💡 Think of it this way: an AI agent is not some mysterious new technology. It is just an LLM running this exact loop again and again until the job is done. Surgery is not one instrument. It is a long sequence of "scalpel, suction, suture", one call at a time.
Why should you care?
Three practical reasons:
- This is what agents are made of. Every coding agent, research agent, and workflow we talk about on this blog is this loop wearing a trench coat. Once you see the loop, agents stop being magic and start being debuggable.
- Tools fight hallucinations. We knows that a model would rather guess than stay silent. A tool call replaces the guess with a real lookup. The surgeon doesn't estimate your blood pressure, she asks the monitor.
- You stay in control. Because your code executes every call, your code can also refuse one. This is exactly where HITL (Human-in-the-Loop) lives: sending an email or deleting a file can wait for your approval, while reading a file runs freely.
The practical takeaway: the model picks tools by reading their names and descriptions, nothing more. So write every description like you are labeling the tray for a brand new surgical tech on their first day: what the tool does, when to use it, and what goes in each field. A vague label gets the wrong instrument slapped into the surgeon's hand. And keep the tray small. Ten sharp, well-labeled tools beat fifty confusing ones, because every extra tool is one more thing competing for the model's attention.
Conclusion
An LLM is a mind without hands. Tool calling gives it a team: the model writes structured requests, your code executes them, and the results flow back until the work is done. Master this one loop and you hold the key to every agent you will ever build or debug. Next time, we can look at what happens when everyone wants to share the same tray: MCP, the protocol that lets any tool plug into any model. Until then, go label your scalpels.
Sources
Comments
0 comments

