What's under the hood of an AI agent - and why you don't have to rebuild it all
An AI agent isn't magic: a model, some tools, and a loop that makes them work together. Building one once is the best way to understand it. Rebuilding everything for every need means forgetting that others have already thought about it.
What it actually is
When you hand a task to an AI agent, it feels like talking to one single thing. In reality, three parts are working together.
The model. That’s the brain: it reads the situation and decides what comes next. It can be swapped - one lab’s model, another lab’s model - without the rest changing. It comes with the system prompt: the starting instructions, what the agent is supposed to be and do.
The tools. On its own, the model only writes text. Tools give it hands: read a file, search the web, send an email, run a command. Today, the most common way to plug them in is called MCP: a standard socket, so the same tool works with several agents.
The loop. This is what turns it all into an agent. Without a loop, you have a model that answers once. With the loop, you have something that moves forward on its own, step by step.
The loop, without a line of code
The best-known and simplest loop is called ReAct (Reason + Act). It fits in four steps:
- Reason: the model looks at the task and what it already knows. “To answer, I need the amount of the last invoice.”
- Act: it picks a tool and calls it. “I open the invoices folder.”
- Observe: it reads what the tool sends back. “The last invoice is 1,200 euros.”
- Repeat or conclude: if something is still missing, back to step 1. Otherwise, it gives you the answer.
That’s it. Almost every agent you use is built on this idea, with extra layers on top. And it explains a lot: an agent that “goes in circles” is a loop that can’t conclude. An agent that costs a lot is a loop that takes too many turns.
Build it once, to understand it
If you’re curious, or if you code a little, the best way to learn is still to build a small harness yourself. Not a product: a toy you can open and read. And the good news is you don’t even have to write it by hand: give the ReAct research paper to your agent, ask it for a minimal version, then read it calmly.
Three habits make all the difference:
- Keep the system prompt short. The longer it is, the less you can tell what comes from it and what comes from the model.
- Try several models. The small versions of the big labs’ models are plenty for learning, and cost little.
- Log everything that goes in and out. In and out of the loop, the model, each tool. Prepare a handful of varied tasks and rerun them after every change. Reading those traces is how you really understand.
For the business owner - and for the employee
If you run your own business: you don’t need to build your agent. But knowing there’s a model, tools and a loop gives you the right questions when something gets stuck: is the model reasoning badly, is a tool returning nonsense, or are the starting instructions too vague? It’s the difference between “AI doesn’t work” and “I know what to fix”.
If you’re an employee: look at where judgment sits in the diagram. The model picks the next step, the tools execute. But deciding which tools it gets, which tasks serve as tests, and whether the result is good is still human work. That’s the part gaining value.
Let’s be honest about the limits
- A homemade harness is for understanding, not for replacing the tools on the market. For serious use, foundations already exist (LangChain and others): starting from scratch only makes sense to learn.
- The next layers are trickier. Skills, memory, subagents: you add them once you’ve mastered the loop, not before. Keeping each part separate helps a lot.
- Nobody thinks of everything. That’s normal, and it’s what the box below is about.
The official sources
- The ReAct paper: arxiv.org/abs/2210.03629
- The skills library (where find-skills searches): skills.sh
- Claude Code - the docs: code.claude.com/docs