An AI Agent Is Just a Model, Some Tools, and a Loop
ยท 11 min read
Most writing about AI agents makes them sound like a tiny brain that sits there thinking, reasoning, and deciding things for itself. I think that framing is a big reason agents feel like hype. It is hard to trust something when nobody will tell you what is inside it, and "it reasons on its own" tells you nothing you can actually check.
The reality is smaller and much easier to hold in your head. An AI agent is a language model that can use tools, running in a loop until the job is done. That is it. Everything else people pile on top is detail about how well each of those three parts is built.
So in this article I want to open the box. We will go through what is actually happening, one piece at a time, and then follow a single request all the way through an agent so you can watch the pieces work together. The whole way through, I will use the same example: a personal assistant that can see your calendar and check the weather. You ask it one thing, "Will it rain during my football game on Saturday? If it will, move it to Sunday at the same time," and we will see what it takes to actually answer that.
The confusion I run into most often is the line between a chatbot and an agent, so that is worth settling first.
A plain language model (an LLM) does exactly one thing: it generates text. You send it a message, it sends text back, and that is the entire interaction. It cannot read your email, search the web, book a table, or touch a database. All it does is predict words.
An agent is what you get when you take that same model and give it two extra abilities. The first is that it can take actions, by calling tools. The second is that it can keep going on its own, step after step, instead of stopping the moment it produces one reply.
That is why you ask a chatbot a question but you give an agent a goal. The agent then works through as many steps and tool calls as the goal needs. Ask a plain chatbot about your Saturday game and the most it can do is tell you how to check the forecast yourself and where to edit the event. It cannot see your calendar, it does not know the forecast, and it cannot move anything. The assistant I described can look up the game, check the weather, and move the event for you, because it can act and it can keep going.
At the center of every agent is the LLM. People like to call it the brain, and that is fine as a shorthand, but it pays to be precise about what the model actually does: given some input, it predicts the text that should come next, based on what it learned in training. It has no hands and no memory of its own. Left alone, it is a very good text predictor sitting in a box, and nothing more.
So how does a text predictor get anything done in the real world? It writes text that asks for help.
Before the conversation even starts, the model is told which tools exist, say a get_weather tool that takes a city and a time. When the model decides it needs the forecast, it does not reach out to the internet, because it cannot. What it does instead is return a structured message, usually JSON, that amounts to "call get_weather with Lagos and Saturday afternoon."
Something else is listening for that message. It reads the request, calls the real weather service, and hands the result back to the model, which picks up where it left off. That something is the agent harness, the software wrapped around the model. The division of labor is the part worth holding onto: the model decides what to do, and the harness does it. Every single action an agent takes, from sending an email to editing a file, passes through that same handoff.
Everything the model can see at any one moment lives in its context window: the instructions, the conversation so far, the tool calls it has made, and the results that came back from them.
That window has a size limit, and the limit has grown a lot. When Simon Willison wrote about it in August 2025, Claude Sonnet 4 had just gained a 1M-token context window in beta, and other frontier models were pushing toward windows of that size too. But a large enterprise codebase or a stack of long documents still will not fit, and models tend to get less reliable well before you reach the advertised limit anyway. So a big part of building a good agent comes down to choosing what goes into that window and what stays out. That work has a name, context engineering, and it is more of the job than people expect.
Whatever goes into the window is organized as messages, and each message has a role:
- System sets the rules: who the agent is, how it should behave, what it should always or never do. For our assistant, that might be "You are a personal assistant. Check the calendar before you change anything, and tell me exactly what you changed."
- User is the input, whether it comes from a person or from another system.
- Assistant is what the model said back, including any tool requests it made.
Tool results go in as messages too. Line all of this up and you end up with a complete log of the interaction: the rules, what was asked, what the model said, what the tools returned, and what got asked next.
Here is a detail that catches people off guard: the model has no memory between calls. Send it a new question without the earlier messages attached and it has no idea what the two of you were talking about a moment ago.
An agent stays coherent across steps because the harness resends the entire conversation every time it calls the model. The model literally rereads the whole thing on every turn. That works right up until the history grows too long for the window, at which point the harness has to start dropping or summarizing older messages, and that is usually when an agent begins to forget things.
For facts that need to outlive a single conversation, or documents far too big to paste in, agents usually lean on a vector database. Your data gets converted into embeddings (numbers that capture meaning) and stored, and the agent is handed a tool that searches them. When it needs something, it pulls back just the relevant pieces instead of the whole pile.
This pattern is called retrieval-augmented generation, or RAG, and it is how an agent answers questions about your documents or recalls long-term facts while the context window is busy with the conversation in front of it. The thing to notice is that it is just another tool call. The model asks for a search, and the harness runs that search against the database. Nothing new, the same handoff as before.
Now put the pieces side by side:
- You start with a system prompt and a goal.
- The model reads the context and decides what to do next: call a tool, search its memory, or just answer.
- If it calls a tool, the harness runs it and adds the result to the context.
- The model reads that result and decides again.
The agent keeps cycling through decide, act, observe until it judges the goal met. That cycle is the agentic loop, and it is the engine of the whole thing. Most harnesses also cap how many times the loop can run, so an agent that keeps asking for tools cannot spin forever and burn through tokens with nothing to show for it.
Let us run the assistant for real. You ask it, "Will it rain during my football game on Saturday? If it will, move it to Sunday at the same time." Give it three tools to work with: find_event and update_event for your calendar, and get_weather for the forecast.
It starts with the harness building the context. It sends the model the system prompt ("You are a personal assistant..."), the descriptions of the three tools, and your request as a user message.
On the first turn, the model asks for the event. It cannot say anything about the weather until it knows when the game is, so rather than reply to you, it writes a tool request: call find_event for "football" on Saturday. Notice that nothing has actually been looked up yet. The model has only written down what it wants.
Then the harness acts. It sees the request, queries your calendar, and appends two messages to the conversation, the model's tool request and the result as a tool message. Say the result comes back as the game: Saturday, 4 p.m. to 6 p.m., in Lagos.
On the second turn, the model asks for the forecast. The harness has sent the whole conversation back, now with the event included, so the model finally has a time and a place to work with. It asks for get_weather for Lagos, Saturday 4 p.m. to 6 p.m. The harness calls the weather service and appends the result: an 80% chance of rain.
On the third turn, the model acts on what it found. Rain is likely, and your instruction was to move the game if it is, so the model asks for update_event to shift it to Sunday, 4 p.m. to 6 p.m. This is the first request that changes anything, which is exactly why a lot of harnesses pause here and ask you to confirm before they run it. Once it runs, the harness appends the result: the event was updated.
On the fourth turn, the loop ends. The model reads the confirmation, decides there is nothing left to do, and replies with plain text and no tool request at all: "Rain is likely on Saturday afternoon, so I moved your football game to Sunday, 4 p.m. to 6 p.m." A reply with no tool request is the signal that the model thinks it is finished, and the harness hands it back to you.
Every piece from earlier shows up in that run. The model only ever wrote text. The harness did the calendar lookups, the weather check, and the update. The context window held the instructions, your request, and every result along the way, and it was resent in full on each turn. And the loop shaped the plan as it went. The model never decided up front to make exactly three calls. It only asked for the forecast once it knew when the game was, and it only asked to move the game once it had seen the forecast. Hand it a dry forecast instead and the run would have ended a turn earlier, with something like "No rain expected, so I have left the game on Saturday."
Once you see an agent as a model, some tools, and a loop, the claims people make about them get a lot easier to weigh.
When an agent does something that genuinely impresses you, it is because the model made good decisions about which tool to reach for next, and because the harness handed it good tools and the right context to work from. When an agent falls over, the cause almost always sits in one of those same few places: the model picked the wrong tool or misread a result, a tool returned something useless, the context was missing something it needed or had grown too long, or the loop stopped too early or ran on too long.
It is also why two agents from different products can behave so differently on the exact same task. They might be running similar models underneath, but they give those models different tools, put different things in the context window, and run different loops around them. The parts are the same everywhere you look. How well each part is built is the whole difference between an agent you rely on and one that just frustrates you.