liveBook · Manning

Memory

As explained in AI Agents and Applications

Memory is stored information that an agent or application can retain and use across steps or interactions.

A chatbot without memory treats every question as a fresh request. After answering who renamed Poseidonia to Paestum, it may fail to understand “What did they do next?” because it cannot connect “they” to the Romans. Memory retains information from earlier interactions so an assistant can handle follow-ups and sustain a conversation. section 7.3.4 section 7.4.4

Choose the scope of memory before implementing it:

  • Short-term memory keeps context within one session, such as the town named in an earlier weather question. section 14.1.1
  • Long-term user memory persists across sessions for one person, such as preferred destinations. Long-term application memory persists information useful across users, such as travel updates. section 14.1.1

For a LangChain RAG chatbot, retrieve the chat history, insert it into the prompt, and update it after each exchange. LCEL connects that history with the retriever, prompt, and model. The resulting history lets the chatbot interpret a vague follow-up using an earlier answer rather than treating it as an isolated question. section 7.4.4

For a LangGraph agent, a checkpointer provides short-term conversational memory by saving agent state. Checkpoints are taken after node executions and can contain conversation history, tool outputs, and intermediate reasoning. They also support resuming a workflow after an interruption and branching from an earlier checkpoint. section 14.1 section 14.4

A follow-up that needs context

A travel assistant answers “What’s the weather like in Penzance?” When asked “What’s the weather in the same town now?”, it resolves “same town” to Penzance using conversation history. The example uses a mock weather service that returns random conditions, so different weather readings do not demonstrate a memory failure. section 14.1.5

Table 14.1 Type of memory in AI agents
Memory type
Scope
Persistence
Example (travel assistant)
Challenges
Short-term
Single user session
Until session ends
Remembering “same town” in a weather follow-up within one conversation
Limited continuity; lost when session closes
Long-term (user)
Across multiple sessions for one user
Weeks, months, or years
Remembering a user’s preferred Cornwall destinations or accommodation types
Privacy compliance and managing the persisted data
Long-term (application)
Across all users and sessions
Ongoing
Storing general travel updates (e.g., Cornwall event calendar, seasonal attraction schedules)
Keeping data fresh; avoiding outdated or incorrect information

Compare the persistence, travel-assistant use case, and operational challenge of each memory scope. Short-term context ends with the session; persistent memory raises data-management, freshness, and privacy concerns. section 14.3.1

Start with short-term memory when the immediate problem is conversational continuity. Persisting preferences or shared knowledge is a separate design task: long-term memory may need per-user stores, summarization or pruning, and privacy controls. It can improve personalization, but adds scaling and regulatory challenges. section 14.3.1

How AI Agents and Applications covers it

How deep it goes
Works through chat-history integration and LangGraph checkpoints for short-term memory; defers implementation of system-specific long-term memory.
Examples
Tests references to the Romans in a history chatbot and to Penzance in a weather follow-up.
What it assumes
Builds on an existing RAG chain or travel assistant while introducing why stateless interactions fail.
What you can do after
Apply it via LangChain chat history or LangGraph checkpoints to make an assistant retain short-term conversational context.
How it connects
Connects memory to RAG, chat history, prompts, LangGraph checkpoints, and agent state.

Also explained in

Compare how 14 books explain memory →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of AI Agents and Applications. The section links point to the parts of the book it draws on.