Back to writing

What is inside an AI agent

AI agents come with a lot of vocabulary, and the words are often used loosely. Here is what each piece means, in the order you meet them when you open one up.

LLM: the model

A large language model (LLM) is the engine. It reads text and predicts what comes next, which is how it answers questions, summarises documents and writes code. On its own it only produces text: it cannot open a file, run a command or remember yesterday’s conversation. What it knows comes from training, and from whatever you put in front of it right now.

Harness and the agentic loop

The harness is everything wrapped around the model: the instructions it starts with, the tools it may call, the permissions it has, and the code that actually runs those calls. Claude Code and Codex are harnesses. The same model can behave quite differently inside different ones.

The harness is what lets a model act, and the agentic loop is how it acts. The model reads the context and picks the next step, which is either an answer or a tool call. The harness runs the tool and puts the result back into the context, and the model decides again. This repeats until the task is done or someone stops it.

AI agent

An AI agent is the combination: a model running inside a harness, using the loop and its tools to pursue a goal. That is why “agent” says more about the system than about the model. Two agents built on the same model can be very different, depending on the tools they have and the rules they follow.

MCP and RAG: tools and knowledge

Tools and knowledge are the two things an agent most often needs more of. The Model Context Protocol (MCP) is an open standard for connecting an AI application to tools and data through small servers. An MCP server for a ticket tracker, a browser or a design file can work with any app that speaks the protocol, so the connection is built once.

Retrieval-augmented generation (RAG) is about knowledge. Before the model answers, the system searches your documents, finds the relevant passages and adds them to the prompt. The answer then rests on your material instead of the model’s memory. The two solve different problems and combine well: an agent can reach a tool through MCP and a document store through RAG.

LangChain: a toolkit

LangChain is an open-source framework for building applications around LLMs. It offers ready-made pieces such as prompt templates, model wrappers, retrievers, tools and agents, so you do not write the same plumbing for every project. It is a way to build the parts above rather than another part of the picture. You can build an agent without it, and many people do.

Summary: the whole picture

In one line: an agent is an LLM inside a harness, running a loop with tools. MCP and RAG feed it tools and knowledge, and LangChain is one way to build it.

LangChain: a toolkit for building agents like thisAI agenta goal, pursued with toolsHarnessprompt · tools · permissionsLLMtext in, text outAgentic loop1 think, pick a step2 call a tool3 read the resultrepeat until doneMCPtools and data,through serversRAGfinds your docs,adds them to the prompt
The pieces, nested the way they work. The model is the smallest part; most of what makes an agent useful is around it.
TermWhat it isFor example
LLMThe model that predicts textClaude, GPT
HarnessThe runtime around the model: prompt, tools, permissionsClaude Code, Codex
Agentic loopThink, call a tool, read the result, repeatFixing a failing test step by step
AI agentLLM, harness, tools and loop pursuing a goalA coding agent working on a ticket
MCPA standard way to connect tools and dataServers for Jira, a browser, Figma
RAGSearch your documents, add them to the promptAnswering from a company wiki
LangChainA framework for building LLM applicationsPrompt templates, retrievers

Working on something similar? Let's talk