Skip to main content
AI Agents8 min readPublished September 19, 2026Updated September 22, 2026

How AI agents use tools

An agent is a model in a loop with a list of available actions. It reads the goal, chooses an action and its arguments, the surrounding program runs that action for real, the result comes back as text, and the loop repeats until the goal is met or a limit is hit.

What does one turn of the loop look like?

  1. 1The program sends the goal, the history so far and the list of tools.
  2. 2The model replies either with an answer or with a structured tool call.
  3. 3The program validates the arguments and runs the tool.
  4. 4The result — data or an error — is appended to the history.
  5. 5The loop repeats with the new information.

The model is not executing anything. Every real effect happens in the program around it, which is where your limits, checks and logging belong.

Why do good tool descriptions matter so much?

The description is the only thing the model has when choosing between tools. 'Get data' is a coin flip; 'Return the last 30 days of orders for a customer, by email' is a decision. Ambiguous names and overlapping tools are the main cause of an agent doing something reasonable-looking and wrong.

  • Name the tool after the intent, not the endpoint.
  • Say what it returns, including what happens when nothing matches.
  • Constrain the input schema tightly — enums instead of free text where possible.
  • Avoid two tools that could both plausibly answer the same request.

How do agents fail?

FailureWhat it looks likeMitigation
Wrong tool chosenA plausible action on the wrong dataClearer descriptions, fewer overlapping tools
Bad argumentsValidation error, or the right action on the wrong recordStrict schemas, validate before running
LoopingThe same call repeated with small variationsStep limits and loop detection
Silent successReports done without checkingMake the tool return verifiable state
Prompt injectionFetched content instructs the modelTreat tool output as untrusted data

Where should a human sit in the loop?

At the actions that are hard to undo. Reading is cheap to get wrong; sending an email, charging a card, deleting records and pushing code are not. A confirmation step at exactly those points buys most of the safety without making the agent useless.

Reversibility is a better rule than importance. Ask whether you could undo it in a minute, and gate what you could not.

How do you debug one?

  1. 1Read the trace: every tool call, its arguments and its result.
  2. 2Find the first step that was wrong, not the step where it became obvious.
  3. 3Decide whether the model chose badly or the tool behaved badly.
  4. 4Fix the description or the schema if it chose badly; fix the tool if it returned something misleading.
  5. 5Re-run the same goal and confirm the earlier step now goes the other way.

Frequently asked questions

What makes an agent different from a chatbot?
The loop and the tools. A chatbot answers; an agent takes actions and reads the results of those actions before deciding what to do next.
Do agents need MCP?
No. MCP is one standardised way to supply tools. Many agents use tools defined directly in their own code.
Why did it say it finished when it did not?
Because it reported on the actions it took rather than checking the outcome. Tools that return verifiable state fix this better than stern instructions.

Practice this in MessyDev

Reading it once helps. Doing it once sticks. These are the hands-on parts of MessyDev that cover the same ground.

Keep going