Skip to content
Engineering Bible
AI Engineering

AI Engineering on agents

An agent is a model in a loop

  • A chatbot answers once. An agent works toward a goal over many steps.
  • Each step: the model picks an action, a tool runs, the result comes back.
  • The loop repeats until the goal is met or a limit is hit.

Tools give the model hands

  • A tool is a function the model can ask to use: search, run code, send email.
  • Each tool has a name, a description and typed inputs, usually as JSON.
  • The model replies with a tool call. Your code runs it and returns the result.
  • MCP, the Model Context Protocol, is an open standard for plugging in tools.
  1. LLM decidesnext action
  2. Tool runssearch, code, API
  3. Resultback to the model

then back to “LLM decides”Goal met: done

The loop starts from a goal and repeats until the goal is met or a limit is hit.

Plans and memory

  • For big tasks, the agent first breaks the goal into smaller steps.
  • Short-term memory is the context window: everything so far in the task.
  • Long-term memory lives outside, in notes or a database, fetched when needed.

Small errors compound

  • If each step works 95% of the time, 10 steps in a row succeed only ~60%.
  • Keep tasks short, check results between steps, and allow retries.
  • A few well-described tools beat many confusing ones.

Not everything needs an agent

  • If the steps are always the same, a fixed workflow is cheaper and steadier.
  • Use an agent when the path can't be planned ahead.

Prompt injection is the top risk

  • Web pages, emails and files can hide orders like “ignore your rules”.
  • OWASP ranks prompt injection the number one risk for LLM apps.
  • Give agents only the access they need, and ask before risky actions.
AI Engineering in five pages3 / 5