An LLM agent has four places where information can live, and it helps to keep them apart.
The context window. Everything in the current prompt: instructions, the conversation, tool results. It is exact and immediately usable, but bounded and re-read at every step, so it costs money and latency in proportion to its length. Models also do not use all positions equally well; a study of multi-document question answering and key-value retrieval found accuracy was often highest when the relevant information was at the start or end of a long context and lower in the middle (Liu et al., 2024).
An external store with retrieval. Text or structured records saved outside the model and fetched on demand. The standard pattern, retrieval-augmented generation, combines a retriever with a generator (Lewis et al., 2020). In an agent, the store holds past events, user facts, or notes, and a retrieval step puts a few of them into the prompt.
Summaries and notes the agent writes for itself. Compressed versions of experience: a running summary, a list of lessons, a profile. They cost context but little else, and they lose detail. Generative-agent architectures add periodic reflections that distil many records into higher-level statements stored back in memory (Park et al., 2023).
The model’s weights. What training put there. It is not edited at run time in the usual deployment, and Chapters 20 and 21 cover what happens when it is.
Systems often combine these in tiers: a small “working” context, a larger store that the agent pages from and into, as in the operating-system analogy of MemGPT (Packer et al., 2023). The tiers are a design choice; what matters for measurement is which operations the agent performs: write, retrieve, update, forget.
Continue with the book
Explore the full treatment, worked examples, and exercises in Next-Generation AI, Explained and Evaluated.
Companion article for Next-Generation AI, Explained and Evaluated, published by Choral Software. Article text and original examples © 2026 Choral Software. All rights reserved.
