Agents for everyone · Chapter 4 of 8
Memory and context
What an agent can see at each step is limited, so what it keeps, drops and writes down decides what it knows.
Goals
- Fill the context until the earliest messages drop out.To do
- Save the right fact so the agent answers correctly later.To do
- Pass the check.To do
Step 1 of 4: The read
What the model reads
Each time the model decides a step, it reads one block of text called the context: your request, the conversation so far and what the tools returned. That is all it has. If something is not in the context, the model does not know it for that step.
A desk with limited room
The context has a size limit, counted in tokens. A token is a piece of a word: a short word is about one token, and in English one token is about four characters. Limits differ between models, from a few thousand tokens to a million or more, but there is always one.
Think of the context as a desk. Only so much paper fits on it at once.
When the desk is full
A long conversation fills the desk. Then something has to go: the oldest messages are dropped, or several are replaced by a short summary. Whatever is dropped, the agent no longer knows, even if you told it earlier.
Memory: a notebook beside the desk
Memory is something different. It is notes the agent writes somewhere outside the context, such as a file, and reads back when they are needed. A note survives when the desk is cleared, but only if the agent saved it, and only the part it chose to write down.
More is not always better
A crowded context takes longer to read, costs more and can bury the one fact that matters. Good agents keep on the desk what the next step needs, and write the rest in the notebook.
Step 2 of 4: Try it: A desk with limited room
A desk with limited room
Fill the desk until the oldest messages drop off, and see what the agent forgets. Then start again, save one fact in the notebook and ask again.
Mode:SimulatedSimulated: the conversation, the answers and the desk's small limit are scripted, and no AI runs. Token counts are estimated from the text shown (characters ÷ 4).
Step 3 of 4: Check
Check
Next: Question 2 of 3
Step 4 of 4: What you can do now
What you can do now
- Explain what a context is and why it has a limit.
- Say what happens when it fills up.
- Tell context from memory, and say why saving the right facts matters.