2.1 THE AGENT

Anatomy

A model plus memory it reads and writes, actions it can take, and a procedure that picks the next one. The map for this section.

AUTHOR LEA DANG WORDS 1,293 READ 6 MIN SECTIONS 4

Ask what an agent is and you get either a definition that fits on a sticker or one that fills a whiteboard. The sticker version is close enough to build on: an agent is a language model plus a harness.

The model is the part you don’t build. It takes text, returns text, and keeps nothing between calls, which is most of what the previous section was about. Everything else people mean when they say “agent” lives in the harness, the code wrapped around the model. Swap the model and you get a better or worse agent. Swap the harness and you get a different one.

“Everything else” is a lousy drawing, though, and the best replacement comes from a 2023 paper, Cognitive Architectures for Language Agents, CoALA for short. Its authors took a split that cognitive scientists have been refining for decades and fitted it to language models: an agent has memory it reads and writes, actions it can take, and a procedure that picks which action comes next. This section is built on that split, and this chapter is the map.

From model to agent

The quickest way to see the three parts is to add them one at a time.

A · A MODELTEXT INTEXT OUTTEXT IN, TEXT OUTB · A LANGUAGE AGENTTHE WORLDACTOBSERVE+ A LOOP WITH THE WORLDC · A COGNITIVE AGENTTHE WORLDACTOBSERVEMEMORYread and written+ STATE IT WORKS ON ITSELF

On its own (A), a model is a function. Text goes in, text comes out, and the next call starts from zero.

Put it in a loop with the world (B) and it’s an agent. The harness reads the model’s output as an action, carries it out, turns whatever happened into text, and hands that back on the next call. Act, observe, repeat. The earliest agents stopped here, and plenty of useful ones still do.

Give it state it works on itself (C) and the paper calls it a cognitive agent. Now the model can do things that never touch the world: think in notes it keeps, look something up in what it already knows, write down what it learned so the next run starts ahead. That’s the agent this section is about, and the next drawing is panel C with the lid off.

The three parts

Read it top to bottom: what the agent keeps for the long term, what it holds right now, and the world it acts on.

EXPERIENCE2.4 · episodicKNOWLEDGE2.5 · semanticSKILLS2.6 · proceduralmodelCONTEXT2.2 · this decisionTRANSCRIPT2.3 · this runACTOBSERVEPEOPLEdialogueSOFTWAREdigitalTHINGSphysicalLONG-TERM MEMORYRETRIEVAL · 2.8LEARNING · 2.10WORKING MEMORYREASONING · 2.9TOOLS · 2.7THE WORLD

The numbers say where each piece lives. Five are boxes and four are arrows. The last five chapters of the section aren’t on this drawing at all, because they’re about deciding which arrow fires next.

Memory

Working memory, the middle band, is two chapters. Context (2.2) is everything the agent holds for the decision in front of it, and the slice of that the model actually gets to see. The transcript (2.3) is the run so far, which is the biggest thing working memory holds. Above them, three stores reach further back: experience (2.4) is earlier runs, knowledge (2.5) is what’s true, and skills (2.6) are how to do things.

Two placements are worth a second look. The transcript sits in working memory however long it gets, because a conversation in progress is something the agent is holding, not something it remembers. It only becomes an episode, the kind of thing experience keeps, once the run is over. And the model itself is up in skills: the paper files its weights as procedural memory, know-how the agent can call but can’t read.

That also settles the argument about what an agent’s “state” is. It’s one of these, or the world outside them. Ask which.

Action

An agent can do four things, and three of them never leave its head. Tools (2.7) are the one that does: an API, a file, a browser, a message to a person, each going out as an action and coming back as an observation.

The other three are directions of travel on the drawing. Retrieval (2.8) reads long-term memory into working memory. Reasoning (2.9) reads working memory and writes something better back, a plan, say, or a summary. Learning (2.10) writes working memory out to long-term memory, so the next run doesn’t start from scratch.

Learning is the arrow most agents leave out, and that’s often the right call. An agent that can’t learn is easy to test. One that can rewrite its own skills is the riskiest thing on the page.

Decision

Something has to pick which arrow fires, and in the paper that’s the decision procedure. It runs as a cycle.

PLANNING · 2.13PROPOSEone move or severalEVALUATEscore eachSELECTkeep oneEXECUTEact, or learnor propose againwhat comes back starts the next cycleTHE LOOP · 2.11

Each turn of the cycle plans and then executes. Planning proposes one move or several, judges them and keeps one, or bins the lot and proposes again. Execution runs the winner, which is either an action on the world or a write to memory, and what comes back starts the next turn.

The loop (2.11) is the cycle itself, including the part nobody writes down, which is how it stops. A state graph (2.12) is the same procedure written as code you can read. Planning (2.13) opens up the first three boxes. Steering (2.14) and orchestration (2.15) are a person or another agent taking part in the decision, and they go a little past the paper, which models one agent on its own and meets people and other agents only as someone to talk to.

Where the line falls

The drawing puts a hard border between the agent and the world, and the paper admits it isn’t always obvious where that border runs. A copy of Wikipedia the agent keeps to itself is memory. Live Wikipedia, which anyone can edit, is the world. Running code in a sandbox the agent owns is closer to reasoning, while running it on a machine other people use is an action.

The paper’s test is control. If the agent is the only one who can change something, it’s memory. If anyone or anything else can, it’s the world, and the only way in is a tool. The same test splits one agent from several: steps built for each other belong to one agent, while steps that are useful on their own can be agents of their own.

A few things look like parts and aren’t, and they live elsewhere in the manual. Structured output is the shape of a single response, a layer below all of this, so it’s in the model section. The surface an agent runs on, a terminal or a phone call or anything between, is the world as a person meets it, so it opens the application section. Which model runs each turn is a cost question, and it lives there too.

Using this as a router

Treat the drawing as an index. When a design question has you stuck, find where it sits on the page. On a box, you’re deciding what to keep. On an arrow, you’re deciding what’s allowed to move. In the cycle, you’re deciding who gets to choose.

The paper turns the same split into a design method, and it’s a good one. List the memories the job needs. Decide, for each one, whether the agent may read it, write it, or both: a shop assistant should write down what each customer bought, read the catalogue without editing it, and never touch its own code. Then pick the simplest decision procedure that does the job. Most real agents end up simpler than this drawing, which is what the drawing is for: you can see exactly what you left out.