AI Agents
Tools, Function Calling, and the Foundation of AI Agents
To an agent, a tool is everything it reads: a description, a schema, a result, an error, and the prompt template that presents them. The same agent, measured with three toolsets: what changed when the tools' results got richer, and when a decision moved into a tool.
On this page · 10 sections
In “What Is an AI Agent? (opens in a new tab)”, a support assistant was asked “Which of my invoices can still be refunded?” It had a tool that listed the invoices and a tool that searched the help center, and a loop that let it call them as often as it needed. In all 8 conversations, it never made both lookups.
It’s tempting to blame the model. But the model never touched the invoices or the help center. It only saw what the tools showed it: a name, a description, a list of parameters, and whatever came back. If the tools had shown it something different, would it have done something different?
This article tests that. The same assistant, the same two small models, the same prompt, and the same loop answer the same ten questions with three different toolsets. Only the tools change.
Try to Understand It This Way
Go back to the new support representative from “Function Calling and Tool Use in LLMs (opens in a new tab)”, who can’t touch the till and works through request slips. A customer asks which of their invoices can still be refunded. Picture three back offices.
The first sends back the ledger, as stored: four rows of invoice numbers, dates, and amounts. The representative has to know the refund rule, find today’s date, and do the date arithmetic in their head.
The second sends back the same ledger with two more columns: how old each invoice is, and the last day it can be refunded. The arithmetic is mostly done. The representative still has to compare each deadline with today.
The third has a form for exactly this question: “Can this invoice be refunded today?” It comes back stamped yes or no, with the reason.
The representative is the same person each time, with the same training. What changes is how much of the decision the back office makes, and how much is left for the representative to work out. That is tool design. The model doesn’t use your systems. It uses the slips you give it.
What a Tool Is, to an Agent
Article #8 covered the mechanics: the model requests a call, your code checks and runs it, and the result goes back. From the model’s side, a tool is everything it reads along the way:
- The name and description, from which it decides whether this tool fits the question.
- The parameter schema, from which it decides what to pass.
- The result, from which it decides what to do next.
- The error, when a call fails, from which it decides how to recover.
There is a fifth thing, easy to miss: how the runtime presents all of this. The model never receives your tool definitions as JSON objects; a chat template turns messages and tools into one prompt. While building this experiment, that template turned out to matter as much as the tools. In the setup used here (Ollama 0.40.16), llama3.2:3b’s template includes the tool definitions only while the customer’s message is the last one. After the first tool result, the next request carries no tools at all, and the template’s system text tells the model to “use the output to format an answer to the orginal [sic] user question.” qwen2.5:3b’s template keeps the tools in every request.
So with this saved template and runtime configuration, llama3.2:3b could take only one round of tool calls, and that is a property of the configuration, not of the model: Meta’s own Llama 3.2 prompt format describes putting tool definitions in the system message, which keeps them in every request. It also changed how Article #21’s opening conversation should be read, and that article now says so.
Anthropic’s “Building effective agents” calls this whole surface the agent-computer interface and advises: “Carefully craft your agent-computer interface (ACI) through thorough tool documentation and testing.” Its later guide, “Writing effective tools for agents,” is more specific. It warns that “A common error we’ve observed is tools that merely wrap existing software functionality or API endpoints,” and notes that “More tools don’t always lead to better outcomes.” Those are claims you can test on your own agent. Here is one test.
The Experiment
The companion demo, 01-tool-design, reuses Article #8’s assistant: the same system prompt, the same loop (up to five model calls), the same models and settings. The synthetic data was adjusted for this experiment: the account has two more invoices, so there is more to ask about, and the help center leaves out Article #8’s planted-instruction tickets, which tested something else. Within this experiment, everything except the tools is identical across the three toolsets.
toolset tools what changes
A search_help_center, get_invoices Article #8's read tools: invoices
as stored; short errors
B the same two tools, names, descriptions richer responses: each invoice's
age and refund deadline; errors
that say how to call the tool
C A's two tools + get_refund_status one task-shaped tool that works
out, from the account data, whether
each invoice can be refunded today
Here is the same invoice as each toolset returns it (line breaks added):
A {"id": "INV-1001", "date": "2026-09-28", "amount": 25,
"description": "Pro plan, September 2026", "status": "paid"}
B ...same fields..., "days_since_invoice": 45, "refund_deadline": "2026-10-28"
C ...same as B..., "refundable_today": false,
"reason": "outside the 30-day refund window"
Ten questions, each asked three times (seeds 1 to 3) with each toolset and each model: 180 conversations. Eight questions need more than one fact, such as “Which is the oldest invoice I can still get refunded?” Two are single-fact controls: “How long do I have to request a refund?” and “How much was my most recent invoice?”
The questions, their expected answers, the facts each one depends on, and the grading rules were written and frozen before any toolset code existed: their hashes were recorded first, and the runner checks them before every run. They were committed to the repository after that, before any model was run. Every conversation was graded two ways:
- Facts retrieved (in code): every fact the answer depends on appeared in a tool result the model actually received. This shows what the model was given, not what it understood.
- Answer (by hand, every reply read): correct, incorrect, or no answer. Any false statement about the customer’s invoices, the policy, or prices makes a reply incorrect.
A conversation counts as a success only when it is both: a correct answer built on facts it actually retrieved.
Implementation note: the exact setup
Runtime: Ollama 0.40.16 on an Apple M4 Pro, /api/chat with tools
Models: llama3.2:3b (a80c4f17acd5), qwen2.5:3b (357c53fb659c), Q4_K_M
Templates: saved with each run; sha256 966de95c... (llama), eb440283... (qwen)
Settings: default sampling, seed = run number, at most 5 model calls and
1,000 tokens per call; model unloaded before and after each run;
fixed order: toolset, question, seed
Runs: 3 toolsets x 10 questions x 3 seeds = 90 per model
Time: 99 s (llama3.2:3b) and 224 s (qwen2.5:3b) for the 90
Frozen: data/ hashed at 2026-11-15 08:49:32 UTC, before any toolset code;
committed (ca4aa54) at 08:56 UTC, before the first model run;
run.py checks the hashes before it runs
Date: 2026-11-15
Every reply was labeled by hand and stored with a SHA-256 of its exact text, so a label can’t silently move to a different reply. One interpretation was settled while labeling began, before any counts were compiled: the part of the expected answer that answers the question is required (for example, “no” for a refund question), supporting values are optional, and anything a reply states must be true. Both are recorded in the demo, with a short note on every label.
Because toolsets A and B present the same tools with the same descriptions, each model’s first request is identical under both. In all 60 pairs, the first tool decision was the same; any difference between A and B comes after the first result.
What the Numbers Say
A endpoint-shaped B richer responses C + task tool
all 10 questions, of 30
successes (correct answer AND facts retrieved)
llama3.2:3b 6 5 9
qwen2.5:3b 6 5 13
facts retrieved
llama3.2:3b 6 7 10
qwen2.5:3b 7 24 15
the 8 multi-fact questions, of 24: successes
llama3.2:3b 0 0 6
qwen2.5:3b 3 2 10
With only three seeds per question, a difference of one or two conversations, such as A’s 6 and B’s 5, should be treated as noise rather than evidence of a real improvement. The larger differences, and the reasons behind them, are what’s worth reading.
The facts reached the model; the answers didn’t follow
Toolset B was built to put the facts in front of the model, and it did. With qwen2.5:3b, the facts each question needed appeared in a tool result in 24 of 30 conversations under B, against 7 under A. Successes went from 6 to 5.
In 18 of B’s 24 multi-fact conversations, qwen2.5:3b had every fact it needed and still didn’t give a correct answer: 17 were wrong, and one didn’t answer. This one had INV-1001’s deadline and today’s date side by side (line break added):
For the invoice INV-1001, the refund deadline is on or before October 28, 2026.
Since the current date is November 12, 2026, the refund deadline has not passed yet.
Another listed all four deadlines correctly, then concluded that INV-0998, the one invoice already refunded, was “the only invoice that is within the refund window.” Richer results moved the facts into the context. The decision that remained, comparing a date with today, was the step the model kept getting wrong.
B’s other change, error messages that say how to call a tool correctly, had nothing to act on. Neither model made an invalid call or got an error result under A or B, so no error message was ever shown. The closest case wasn’t an error at all: a search that ran successfully and found nothing, six times, all llama3.2:3b. Under B, that ordinary empty result also carried a hint to try other words; under A, it was an empty list. Either way, llama3.2:3b’s template gives it no tools after the first result, so the hint had no next call to change. The experiment didn’t exercise error recovery, and says nothing, either way, about the value of better error messages.
Moving the decision into the tool
Toolset C made that decision in code: get_refund_status compares each invoice with the 30-day rule and today’s date, at the time of the call, and returns the verdict with its reason. Successes on the eight multi-fact questions went from 3 to 10 for qwen2.5:3b and from 0 to 6 for llama3.2:3b.
Put the two rows of the table side by side. Under B, the required facts reached qwen2.5:3b in 24 of 30 conversations, and 5 were successful. Under C, the required facts reached it in 15 of 30 conversations, and 13 of those were successful. For llama3.2:3b under C, the corresponding figures were 10 conversations with the facts retrieved and 9 successes. When the facts arrived as a decision, the model almost always used them correctly; when they arrived as dates to compare, it mostly didn’t.
The gains sit almost entirely on questions whose answer is the tool’s output: which invoices can be refunded, whether INV-1001 can be, and until when INV-1002 can be. Here is llama3.2:3b, which never reached the invoices on this question under A or B:
Based on the tool output, the invoices that can still be refunded are:
* INV-1002: Pro plan, October 2026 (within the 30-day refund window)
* INV-1003: Extra seats add-on (within the 30-day refund window)
Where the question needed one more step on top of the tool’s answer, C helped much less. “Which is the oldest invoice I can still get refunded?” needs the refundable invoices and then the oldest of them; no conversation, with any toolset, got it right. The tool removed the decision it made. It didn’t make the model better at the ones that were left.
A task-shaped tool pulls other questions toward it
C has a cost the other two don’t. Asked the single-fact control question “How long do I have to request a refund?”, A and B answered correctly in 10 of 12 conversations; the policy is one help-center search away. With C, 1 of 6 answers was correct, and that one didn’t come from a tool result. llama3.2:3b reached for get_refund_status instead of searching: twice as a call, once written into its reply as text. qwen2.5:3b didn’t call anything and asked the customer for an invoice:
To provide you with the specific information about your refund deadline, I need to
know the ID of the invoice you want to check.
A tool about refunds made a general question about refunds look like a question about one invoice. Anthropic’s tool-writing guide warns about exactly this: “When tools overlap in function or have a vague purpose, agents can get confused about which ones to use.” Here, adding one tool cost a question that had worked without it.
The arguments the model makes up
C also offers something A and B never did: an argument. get_refund_status takes an optional invoice_id; called without one, it returns every invoice, the most recent and the August one included. The models filled it in anyway, llama3.2:3b in 24 of its 26 calls and qwen2.5:3b in 15 of 18. Of the 44 calls, 23 didn’t execute. llama3.2:3b passed "get_invoices" as an invoice id, an empty string, null, and descriptions like "(get_most_recent_invoice)". In five conversations it passed INV-0000.
INV-0000 appears in exactly one place: the description of the tool’s invoice_id parameter, which says “for example INV-0000.” That was a choice made while writing the tool, and it repeated Article #8’s finding about INV-1234, which also came from a description. qwen2.5:3b invented ids instead, such as INV-123456. Both models were trying to name an invoice they hadn’t looked up, usually “my most recent” or “my August invoice.” The tool didn’t need an id for that: leaving it out would have returned both. The question described an invoice, and the models turned the description into an id they didn’t have.
The first choice comes before any result
Toolset B couldn’t help llama3.2:3b at all, and the reason is visible before any tool runs. On 23 of the 24 multi-fact questions, under both A and B, its first and only call was a help-center search, so it never saw an invoice. Better results can’t fix a call that goes to the wrong tool, and in this setup llama3.2:3b got no second call to correct it. Under C, it chose get_refund_status first for all 24. In this run, a tool whose name matched the question was chosen; one whose name described a data source wasn’t.
Announcing a step is not taking it
Six qwen2.5:3b replies ended by describing a next step and then stopping. This one had just looked up the oldest invoice:
The invoice with ID INV-0998 is from August 2026, and it has already been refunded,
so it cannot be refunded today. Let's check the next oldest invoice.
That is the right next step, written as text instead of requested as a call. To the loop, a reply without a tool call means “done,” so the run ended there. It is Article #21’s “stopping too early,” in a new form.
Want to go deeper? Correct answers without the facts, and token cost
Five conversations were labeled correct without retrieving the facts their answer needed, for example “30 days” without a help-center search, from a model that guessed the common policy. They are counted as correct but not as successes: a right answer the model couldn’t have known from the tools is a guess that happened to match.
Richer results and extra tools cost input tokens. The median tokens per conversation (Ollama’s prompt_eval_count, summed over the conversation’s model calls):
A B C
llama3.2:3b 436 444 517
qwen2.5:3b 724 861 840
C’s third tool definition adds about 80 tokens to every first request. B’s longer invoice rows add more on the second, for the model that keeps reading after a result. Neither is large here, with four invoices; with four hundred, what a tool returns becomes a budget decision, which is why Anthropic’s guide recommends returning “only high signal information.” The numbers are for these models’ tokenizers on Ollama; other providers count differently.
Designing Tools for Decisions
1. Move decisions you can make in code into the tool
The largest gain came from get_refund_status doing a comparison the model kept getting wrong. If a rule has one right answer, compute it and return the verdict. This is the boundary from “LLM Applications vs AI Agents: What’s the Difference? (opens in a new tab)”, applied inside an agent: the model still decides what to ask, and code decides what has one answer. As Anthropic’s guide puts it, “Tools can consolidate functionality, handling potentially multiple discrete operations (or API calls) under the hood.”
2. Return what the next decision needs, and don’t assume it gets used
Toolset B put the right facts in front of the model 24 times out of 30 and gained nothing. Context is necessary, not sufficient. When a result requires arithmetic or comparison before it’s useful, either do that step in the tool or test whether the model does it reliably.
3. Keep a task tool’s scope narrow and its name exact
A refund-status tool captured a general refund-policy question. A task tool should say what it is not for as clearly as what it is for, and you should test the questions next to its scope, not only the ones in it. (This experiment didn’t test a narrower description; that is a reasonable next step, not a result.)
4. Design arguments around what the user actually says
Customers say “my most recent invoice” and “my August invoice,” not INV-1003. get_refund_status already accepted no id, and returned everything, but its parameter description said what an id looks like and not what leaving it out does, and the models invented ids. Two options worth testing (this experiment didn’t): say in the description what an omitted argument returns (“leave out invoice_id to get every invoice, including the most recent”), or accept what the question provides, such as a month or “latest,” instead of an id.
5. Don’t put example values in descriptions
INV-0000 came straight from the description, as INV-1234 did in Article #8. An example that looks like a real value will be used as one. Describe the format in words (“the invoice id, as returned by get_invoices”) instead.
6. Check what your runtime actually shows the model
The same loop and tools gave one model one round of tool calls and the other as many as it wanted, because of a chat template. Read your runtime’s template, or the provider’s documentation on how tools are presented, and check per-request token counts for surprises. If your tools disappear after the first result, no tool design will make the agent take a second step.
7. Measure tools on your own tasks, two ways
Grade whether the facts reached the model separately from whether the answer was right. Without that split, B and A look nearly the same; with it, you can see that B solved retrieval and left the decision unsolved. Anthropic’s guide makes evaluation the center of tool design for the same reason: the effects vary by model, and the only reliable answer is a test on your own questions.
Everything Article #8 said about authority still holds. All of these tools only read. Tools that act need the rules in code, the confirmations, and the log that Article #8 described.
What Breaks
Consolidating past the decision. A tool that answers a whole question is the right design when the question has one answer. Keep going and the tool becomes the workflow, with the model reduced to phrasing; at that point, Article #22’s question applies: do you still need an agent?
Results that grow with the data. Four invoices cost a few dozen tokens. A customer with four hundred will cost far more on every call that returns them all. Return what the decision needs, and filter or page the rest.
Tool descriptions you didn’t write. When tools come from a third party, for example a server speaking the Model Context Protocol, their names, descriptions, and examples become part of your prompt. Everything in this article applies to them, including the example values, and you can’t edit them, only choose whether to expose them.
What to Take Away
- A tool is what the model reads. Name, description, schema, result, error, and the template that presents them. That is the whole interface.
- Getting facts to the model isn’t the same as getting them used. Richer results raised retrieval from 7 to 24 of 30 for one model, and successes didn’t rise.
- Decisions with one answer belong in the tool. Moving one comparison into code more than tripled one model’s multi-fact successes (3 to 10 of 24) and gave the other its first (0 to 6).
- A new tool changes how the model reads other questions. The refund-status tool broke a simple policy question that worked without it.
- The model fills arguments it doesn’t have. From the description’s example, or by inventing them. Accept what users actually say.
- Check the runtime, not only the code. A chat template decided whether one model could take a second step at all.
Think About These Use Cases
-
An order-tracking agent: Your API has
get_order(id),get_shipment(id), andget_carrier_status(tracking_number). A customer asks “Where’s my package?” Which tool would you add, and what would it return? -
A calendar assistant: Users say “move my 3pm with Priya.” Your tool takes an event id. What do you change: the tool, or the steps before it?
-
A reporting agent: Its tool returns ten thousand rows, and the model has to sum them. What should the tool return instead?
-
A tool from a vendor’s server: Its description includes an example customer id. How would you find out whether your agent uses it, and what can you do if it does?
-
A new tool next to old ones: You add a task tool for one common question. Which other questions would you re-test before shipping it?
If you want to talk one of these through, take it to GPT along with this article. Ask GPT ↗️
Related Sources
- 01-tool-design: The companion demo: the three toolsets, the frozen questions and grading rules, all 180 saved conversations with their hand labels, the saved chat templates, and a report script that re-grades without calling a model.
- Anthropic: Writing effective tools for agents — with agents (September 2025): Choosing which tools to build, consolidation, namespacing, returning meaningful context, token efficiency, error messages, and evaluation-driven tool design.
- Anthropic: Building effective agents (December 2024): The agent-computer interface, and Appendix 2 on prompt engineering tools. The page notes that the tooling it describes has changed since publication.
- Meta: Llama 3.2 prompt format: How Llama 3.2 expects tool definitions and tool results, with system-message definitions as the default.
- tool-calling: Article #8’s demo, whose assistant, loop, and data this experiment starts from.
What’s Next?
In every toolset here, the model decided the order of steps: which tool first, whether to look again, when to answer. Some of the failures came from exactly that freedom, such as a search where an invoice lookup was needed, or a next step announced and never taken. For a question whose steps are known, that freedom isn’t needed.
In the next article, we’ll look at Agentic Workflows: When Should an LLM Control the Flow?: where dynamic decisions earn their place, and where a fixed sequence in code does the job better.