liveBook · Manning

Memory

As explained in Build Python Web Apps with Streamlit

Application memory is the transient information retained by a running application while it executes.

Application memory is the transient information retained while an application runs. Without it, a rerun can reset variables such as a task list, while a chatbot forgets earlier messages. section 4.4 section 10.3.1

A conversational graph retains state by combining two pieces:

  • A checkpointer such as LangGraph’s MemorySaver stores graph state in memory. section 10.3.1
  • A consistent thread ID identifies related invocations, allowing the graph to resume with that thread’s previous state. section 10.3.1

Remembering a follow-up message

A support chatbot initially answers one message. When the user asks a follow-up, passing the same thread ID lets the graph recall the earlier conversation instead of treating the follow-up as a new execution. section 10.3.1

from langgraph.checkpoint.memory import MemorySaver
from langgraph.graph import START, END, StateGraph, MessagesState
...

class SupportAgentGraph:
  def __init__(self, llm):
    self.llm = llm

    self.config = {"configurable": {"thread_id": "1"}}...
...
  def build_graph(self):
    memory = MemorySaver()
    builder = StateGraph(MessagesState)
    ...
    return builder.compile(checkpointer=memory)

  def invoke(self, human_message_text):
    ...
    return self.graph.invoke(state, self.config)

The implementation listing shows MemorySaver, graph compilation with a checkpointer, thread configuration, and invocation with that configuration. section 10.3.1

How Build Python Web Apps with Streamlit covers it

How deep it goes
Explains state loss, in-memory checkpointing, and thread-based recall, while deferring durable database persistence to alternative checkpointers.
Examples
Uses a task list, a follow-up chatbot message, MemorySaver, and thread ID 1 as concrete examples.
What it assumes
Explains state loss from zero before building persistence with LangGraph primitives.
What you can do after
Apply it via LangGraph by compiling a graph with MemorySaver and invoking it with a consistent thread ID.
How it connects
Connects application state with Streamlit reruns, LangGraph checkpointers, thread IDs, and conversation context.

Also explained in

Compare how 14 books explain memory →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Build Python Web Apps with Streamlit. The section links point to the parts of the book it draws on.