Most language model APIs are stateless. Each request is evaluated from the messages and 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 task, your application has to store and retrieve that information.
A memory system gives an agent controlled ways to store, retrieve, update, and discard information. Good memory is selective state management. It is not "save everything forever." Keep what is useful, retrieve it when it matters, and avoid filling the model context with stale or irrelevant facts.
This chapter covers the main memory layers used in agent systems: short-term context, working memory, long-term semantic memory, episodic records of past runs, and cleanup policies that keep memory useful over time.