Tool Use & Function Calling
You'll be able to:
You can design a tool schema an LLM can call reliably, explain why tool descriptions are prompts in disguise, and name three common failure modes (hallucinated args, retry loops, silent tool errors).
A tool is registered with the name get_data and the description "gets data". In testing it works, because the engineer who wrote it knows what it expects. In production the model calls it with invented arguments roughly a third of the time, and every one of those calls returns something that looks like a plausible answer. The schema was written as API documentation. The model read it as an instruction, because that is the only thing it can be.
Tool descriptions are prompts wearing a costume
The model has no access to your source, your tests, or the engineer who wrote the function. The name, the description, and the parameter schema are its complete information. Whatever ambiguity you leave, the model resolves by guessing — confidently and invisibly.
A schema that works in production states four things that terse API docs habitually omit: when to use this tool and when not to, the exact format and units of each parameter, the enumerated valid values wherever the set is closed, and a worked example of a correct call. The description is not documentation of the function; it is the decision procedure for a reader who cannot ask a clarifying question.
Errors are prompts too
The tool's return value goes straight into the model's context and becomes the basis of its next decision. Returning a stack trace or a bare 500 tells the model nothing it can act on, so it does the only thing available: it tries again, identically.
An actionable error changes the outcome. "Invalid date format: expected YYYY-MM-DD, received 'last tuesday'. Call resolve_date first." gives the model a specific correction and a next action. This single change eliminates most retry loops, and it costs one line per error path.
Failure modes
Hallucinated arguments — the schema does not constrain a value, so the model produces a well-formed, entirely fabricated one. Signal: tool calls carrying identifiers that match your format perfectly and exist nowhere in your database.
Retry loop — an opaque error gives the model no new information, so it repeats the same call. Signal: consecutive identical tool calls in a trajectory, usually terminated only by a step limit.
Silent tool failure — the tool catches its own exception and returns an empty result with a success status. The model treats absence of data as evidence of absence. Signal: confident, fluent answers built on nothing, with no error anywhere in the logs.
Tool overload — as the registered tool count grows, selection accuracy degrades. Signal: a measurable accuracy drop that correlates with tool count rather than with task difficulty.
Explaining this to stakeholders
On schema quality: a tool description is a job specification for a contractor who will never phone you to clarify. Write it vaguely and you will get confident, well-presented, wrong work — and you will not find out until you inspect the result.
On error messages: telling the system "that failed" produces another attempt at the same thing. Telling it "that failed because the date was in the wrong format" produces a correction. The difference in engineering effort is a sentence.
On tool count: adding a fortieth tool is not free. Every option makes every choice slightly harder, and the cost lands on the tasks that used to work.
Check Yourself
Module Mission
20–30 minDefine a tool schema for a 'send_email' function — name, description, parameters. Write it two ways: one an LLM will misuse, one it will call correctly. Explain the difference in one paragraph.
Loading your work…
Curated Materials
1.2hThe deep work happens here — the lesson is your briefing.
Live on aiqbench
This lesson's subject on the rest of the site, today.
In the news, last 30 days
- OpenAI AI Agents Bypass Security Restrictions and Access Government Systems Without PermissionCybersecurity News ·
- We let AI agents break the rules on Black Friday. One stole a TV and another called the policeFortune ·
- How workable is the “human-in-the-loop” concept in agentic AI?IDC ·