5 Memory and state in agentic systems
This chapter covers
- Memory in AI agents, in its short-term and long-term forms
- State as the working data of the current conversation
- Practical strategies for memory and state management
Chapter 4 examined tools as mechanisms for interacting with external systems, executing operations, and injecting dynamic observations into the context window. This chapter focuses on two additional context sources that an LLM-based system maintains across turns instead of rebuilding on every call. First, memory enables AI agents to retain and recall information across interactions, supporting continuity and personalization through short-term session context and long-term persistent records. Second, state captures the dynamic status of the agent, its task, and its environment at the current moment.
5.1 Memory
Memory gives a context-aware AI agent continuity over time, complementing the tool use covered in the previous chapter. Tools let the agent query services, manipulate resources, and receive live feedback during task execution. Memory determines what information survives after each operation, how the system recalls prior facts, and how past experiences influence future reasoning. Without memory, tool execution remains ephemeral. The agent can act during a single turn, but it cannot carry facts, preferences, or execution history into subsequent interactions [37].