The thing that turns an LLM into an agent — more than anything else — is giving it tools.
Let's dig into how that actually works.
What Is a Tool?
In the agent world, a tool is essentially a function the LLM can call.
Examples:
search_web(query)— Takes a search query, returns search results.read_file(path)— Takes a file path, returns the file's contents.send_email(to, subject, body)— Sends an email.get_weather(city)— Returns the current weather in a city.calculate(expression)— Evaluates a math expression.book_flight(from, to, date)— Books a flight via an airline's API.
Each tool has:
- A name.
- A description of what it does (in plain English) so the LLM knows when to use it.
- A list of inputs it needs (with descriptions and types).
- An output it returns.
How the LLM Uses Tools (Function Calling)
Here's the clever part.
When you set up an agent, you describe the available tools in the prompt (or in a structured form the model is trained to understand).
The model is then trained — through fine-tuning — to output a special structured response when it wants to use a tool.
A simplified example.
Suppose the LLM is given:
"You have these tools available:
get_weather(city): Returns the current weather for a city.search_web(query): Searches the web and returns results.User question: What's the weather like in Paris right now?"
Instead of just generating a natural-language response, the model outputs a structured tool call.
The exact format differs between providers.
Here is the shape used by Anthropic's Messages API:
{ "type": "tool_use", "id": "toolu_01", "name": "get_weather", "input": { "city": "Paris" } }
The agent framework recognizes this, actually calls get_weather("Paris") in the real world, gets back something like {"temp": "12°C", "conditions": "Cloudy with light rain"}, and sends that result back to the model, tied to the same call id:
{ "type": "tool_result", "tool_use_id": "toolu_01", "content": "{\"temp\": \"12°C\", \"conditions\": \"Cloudy with light rain\"}" }
Now the model can produce its natural-language response:
"It's currently 12°C in Paris with cloudy skies and light rain."
This pattern — LLM emits a tool call, framework executes it, result is fed back — is called function calling or tool use.
Current LLMs (Claude, GPT, Gemini and others) have been specifically trained to do this reliably.
Tools can also be shared across applications through the Model Context Protocol (MCP), which we cover in lesson 4.1.
Why This Is a Big Deal
Tool use breaks the LLM out of its purely textual world.
Suddenly it can:
- Access current information (web search, APIs)
- Perform precise calculations (calculator tools eliminate math errors)
- Read and modify files
- Interact with databases
- Send messages
- Run code
- Control web browsers
- ... basically anything you can wrap in a function
Each new tool exponentially expands what an agent can do.
A Note on Safety
Once you give an LLM the ability to take actions in the world, you've crossed a major safety boundary.
A chatbot that gives bad advice is unfortunate; an agent that sends emails on your behalf or makes purchases makes real-world commitments.
Designing guardrails — what the agent is allowed to do, what requires confirmation, what's logged for human review — becomes essential.
We'll return to this in section 3.8.