Back to Automation

What Is Tool Use and How Does It Work?

What Is Tool Use and How Does It Work?
AI Tutorials Team 8 May 2026

Tool use lets a model ask your code to do something: look up a record, run a calculation, fetch a page. The model does not execute anything itself, which is the part people misunderstand.

What is the loop?

  • You describe the tools. Names, purposes, parameters.
  • The model requests one. With arguments.
  • Your code runs it. And gets a result.
  • You send the result back. As part of the conversation.
  • The model continues. Possibly requesting another.

Who is in control?

You are, entirely. The model produces a request and your code decides whether to honour it, which is the property that makes this safe to build on.

What makes a good tool definition?

A clear name, a description saying when to use it, and parameters with types and explanations. The description is what the model reads to decide, so vagueness there produces tools called at the wrong moments.

How many tools should you define?

Few. A handful of well-described tools are selected reliably; twenty overlapping ones produce wrong choices, and the descriptions all consume input tokens on every call.

What goes wrong most often?

Arguments that do not match reality: an invented identifier, a malformed date, a value outside what your system accepts. Validating before executing is essential rather than defensive.

What about tools the model should not choose?

Worth controlling rather than hoping. Most providers allow forcing a specific tool, preventing tool use entirely, or letting the model decide, and choosing deliberately per request removes a source of unpredictability.

Forcing is particularly useful for extraction. Where you know a tool should be called, requiring it produces structured arguments reliably rather than occasionally receiving prose instead.

What about errors from the tool?

Return them as the result rather than failing the whole exchange. A model told that a lookup found nothing will handle it sensibly; one that receives silence will frequently invent an answer.

What about tools that cost money?

Worth treating differently from free ones. A tool that performs a paid lookup, sends a message or consumes a quota should be constrained more tightly than one that reads a local value.

Limiting how many times such a tool can be called in one exchange is the practical protection. A model that decides to check something twenty times is unusual and not impossible, and the cap costs nothing when it is not needed.

How do you stop a loop running forever?

Cap the number of rounds. A model that keeps requesting tools without converging will continue until something stops it, and a limit with a clear fallback is the practical protection.

What should a tool never do?

Anything irreversible without confirmation. Sending, paying and deleting are the categories where a misread instruction becomes a real problem, and a confirmation step costs almost nothing.

What about testing the tool loop?

Worth doing with deliberately awkward cases. A tool returning nothing, returning an error, or returning something unexpected all exercise paths that a happy-path test never touches.

The behaviour you want is the model handling it gracefully and telling the user, rather than inventing a result or looping. Confirming that before deployment is considerably easier than discovering it from a confused user report.

What about tools that take a long time?

A practical problem worth designing around. A tool call that takes thirty seconds holds up the whole exchange, and the user sees nothing while it runs.

Splitting into a start and a check, or returning a result that says the work is in progress, keeps the conversation responsive. That is more work to build and it prevents the experience of an application that appears to have frozen.

What about untrusted input?

The genuine risk here. If a tool fetches content from outside, that content can contain instructions aimed at the model, and the defence is limiting what tools can do rather than trusting the text.

What does this enable?

Everything agentic. Retrieval, actions in other systems and multi-step processes are all built on this loop, which is why it is worth understanding properly before building anything ambitious.