tl  tr
  Home | Tutorials | Articles | Videos | Products | Tools | Search
Interviews | Open Source | Tag Cloud | Follow Us | Bookmark | Contact   
 Agentic AI > LangGraph > LangGraph with Long-Term Memory

LangGraph with Long-Term Memory

Author: Venkata Sudhakar

LangGraph's short-term memory (checkpointers) persists state within a single conversation thread. Long-term memory goes further - it stores facts, preferences, and summaries that persist across threads and sessions. For ShopMax India, long-term memory means the agent remembers a customer's preferred delivery address, past complaints, and product interests across multiple separate conversations.

The recommended pattern is to use a Store alongside your checkpointer. The InMemoryStore (or a database-backed store in production) holds named namespaces of key-value memories. Nodes can read from and write to this store using store.get() and store.put(). The store is passed to the compiled graph and is accessible in every node via the config.

The following example shows a ShopMax India agent that remembers a customer's preferred city across separate invocations using the store.


It gives the following output,

Got it! I have saved Hyderabad as your preferred delivery city.
Your preferred delivery city is Hyderabad. How can I help you today?

For production use at ShopMax India, replace InMemoryStore with a database-backed store such as PostgresStore or RedisStore so memories persist after server restarts. Structure namespaces by user ID and memory type (preferences, history, complaints) for easy retrieval and to keep customer data properly isolated.


 
  


  
bl  br