Last Updated: June 7, 2026
Most language model APIs are stateless. Each request is evaluated from the messages and retrieved context you send with that request. If you want an agent to remember a user's preference, a tool failure, a prior decision, or the current state of a multi-step task, you have to design that memory yourself.
A memory system gives an agent controlled ways to store, retrieve, update, and discard information. Good memory is selective state management, not "save everything forever": keep what is useful, retrieve it at the right time, and avoid polluting the model's context with stale or irrelevant facts.
This chapter covers the memory layers used in production agents: short-term context, working memory, long-term semantic memory, episodic records of past runs, and consolidation policies that keep memory useful over time.