An agent is a model in a loop with tools.
An AI agent is software where a language model decides what to do next: it reads a goal, picks a tool (search, code, an API, a file), observes the result and repeats until the job is done. The model is the planner; the engineering around it, tool design, limits, memory, verification, is what makes it reliable. Most failures are engineering failures, not model failures.
- Parts
- Model, tools, memory, loop, limits
- Protocol
- Tool calling; MCP for standard tool servers
- Fails on
- Vague goals, too many tools, no verification
- I built
- An MCP server with 66 tools running this site
- 5production AI apps
- 14engineers led
- 200+students mentored
Questions students ask
The AI agent questions searched most, answered from building agents and the tools they call.
What is AI agent?
An AI agent is a program that uses a language model to pursue a goal through a sequence of actions rather than a single answer. A chat assistant replies once; an agent plans, acts, checks and continues. The actions are tool calls: searching documents, running code, querying a database, calling an API, reading and writing files, sending a message. The model chooses which tool to use and with what arguments, your code executes it, and the result goes back to the model for the next decision. Agents range from a simple loop with two tools to systems that run for hours across many steps.
What are AI agents and how do they work?
- A goal arrives, from a user or a schedule.
- The model receives the goal, a system prompt describing its role and rules, the available tools with schemas, and any memory of past work.
- It reasons about the next step and emits a tool call, or a final answer if done.
- The application validates and executes the call and appends the result to the conversation.
- The loop repeats, bounded by a step limit, a token budget and timeouts.
- A verification step checks the outcome before it is reported or acted on; consequential actions wait for human confirmation.
- Every step is logged, which is what makes agents debuggable and evaluable.
AI agents examples
Coding agents that read a repository, make changes, run tests and open a pull request. Research agents that search, read sources, and compile a cited report. Support agents that look up an order, check a policy and issue a refund within limits. Data agents that write and run SQL to answer questions. Browser agents that fill forms and navigate sites. Operations agents that monitor logs and open tickets. Retrieval agents that decide how to search a knowledge base, which I describe under agentic RAG. The agent that publishes and maintains pages on this site through its MCP server is one more: it reads analytics, drafts content and runs publishing tools under scoped permissions.
What is AI agents vs agentic AI?
AI agents are the systems; agentic AI is the approach or property. Saying a product is agentic means a model inside it makes decisions and takes actions autonomously over several steps, rather than responding once. An AI agent is a concrete instance of that: this loop, these tools, this goal. Marketing uses both loosely. The useful question for any product is concrete: what decisions does the model make, what actions can it take, what are the limits, and how is the result verified? A system that answers those clearly is agentic in a meaningful sense; one that cannot is a chatbot with a new label.
How to build AI agents
Start with the smallest loop that does something useful. Define the goal precisely and the three to five tools the agent needs, each with a clear description, typed arguments and a predictable output. Write the system prompt as a specification: role, when to use each tool, when to stop, what to do when stuck. Implement the loop with a step cap and logging. Add a verification step (a check against the goal, a test run, a schema validation) before the result counts. Build an eval set of tasks with known outcomes and run it on every change. Only then add tools, memory or sub-agents, one at a time, measuring each. Frameworks help later; the first version should be plain code so you understand every step.
How to build AI agents from scratch
- Pick a provider SDK (or a local model through Ollama) that supports tool calling.
- Write two or three Python functions with docstrings and type hints; generate their JSON schemas.
- Build the loop: send messages plus tool definitions; if the response contains a tool call, validate arguments, run the function, append the result; otherwise return the answer.
- Add a maximum of about ten steps, a timeout per tool, and a log of every message.
- Add a verifier: a second model call or a deterministic check that the goal was met.
- Write ten test tasks with expected outcomes; run them; read the traces where it fails and fix the tool descriptions or the prompt before anything else.
- Expose tools through MCP when other agents or clients should reuse them.
Why AI agents fail
Vague goals: the agent cannot tell when it is done, so it wanders or stops early. Too many tools with overlapping descriptions, so it picks the wrong one. Tools with messy outputs that the model misreads. No limits, so a loop burns tokens for an hour. No verification, so a confident wrong result is reported as success. Hidden state the model cannot see, such as a file it changed earlier. Prompt injection from content it reads. And no evaluation, so regressions ship silently. Nearly every failure I have debugged traced to one of these, not to the model's intelligence. The fixes are specification, small tool sets, limits, verification and evals.
How to use AI agents
Give them bounded, verifiable tasks with clear success criteria: 'make the tests pass', 'find the three sources that support this claim and quote them', 'extract these fields and flag anything that fails validation'. Provide the context they need up front rather than hoping they find it. Keep consequential actions behind confirmation: sending, paying, deleting, publishing. Read the trace when the result matters, especially the first few times. Treat outputs as drafts to check, not verdicts. And use them where the loop is worth it; a single well-prompted model call is cheaper and more predictable for anything that does not need multiple steps.
What is n8n AI agent?
n8n is a workflow automation tool with a visual editor, similar in spirit to Zapier but self-hostable and open source, and its AI agent node lets you drop a language model agent into a workflow: you connect a model, attach tools (HTTP requests, databases, other n8n nodes, vector stores), add memory, and the node runs the plan-act-observe loop as part of the larger automation. It is a fast way to build agents that glue existing services together without writing the loop yourself, well suited to internal automations and prototypes. For products that need custom tools, strict limits and evaluation, a coded agent is easier to test and control.
Best AI agent for coding free
Several good options cost nothing to start. Open-source editor agents such as Cline, Roo Code and Continue run inside VS Code and work with free hosted models or local models through Ollama. Aider is an open-source terminal agent that pairs well with local models. Gemini's command-line agent and GitHub Copilot both offer free tiers with usage limits. The paid agents from the major providers are stronger on large, multi-file tasks, and many teams pay for them once the value is clear. For a student: start with a free editor agent plus a local model, learn to write precise tasks and to read the diffs, and the skill transfers to any of them.
A first agent in an evening
Small, bounded, tested.
- 01
Three tools
Search a folder, read a file, write a note. Clear docstrings; typed arguments.
- 02
The loop
Model plus tools; validate arguments; ten-step cap; log every message.
- 03
A verifier
Check the note answers the question with citations before returning.
- 04
Ten tasks
Known outcomes; run after every change; read the traces that fail.
In the room
Where these systems get explained to students.


Read next
Agents, tools and retrieval in depth.
An agent that needs to be trusted?
I build agents with scoped tools, limits, verification and evals, and the MCP servers they call.

