LangMemLangMem 0.0.30 · LangGraph 1.2 · Python 3.10+
Dashboard
0%
1
Curious builder0 XP earned · 300 to level 2
0 daysFinish a lesson to begin
Badge collection0 of 6 unlocked
19 small wins to finish your pathNext lesson →

LangMem logoLangMem overview

LangMem is a Python library from LangChain that gives AI agents long-term memory: a model reads a conversation, decides what is worth keeping, and LangMem stores it so a later conversation can find it.

Last updated: 30 Sep, 2026 · LangMem 0.0.30

LangMem is open source under the MIT licence and published on PyPI as langmem. This course uses version 0.0.30, an early release whose API can still change, so every install below pins it. Its README describes three jobs: extract important information from conversations, optimize an agent's behaviour by refining its prompt, and maintain long-term memory. Its functions work with any storage system, and it also integrates natively with LangGraph's store.

A chat model forgets everything when a conversation ends. The next conversation starts from zero, so a support assistant asks a returning customer for their name, their order and their contact preference all over again. LangMem is the layer that carries those facts across conversations.

The three memory types LangMem manages

LangMem's conceptual guide sorts agent memory into three types, borrowed from how human memory is described:

Memory typeWhat it holdsSupport assistant exampleLangMem feature
SemanticFacts and preferencesAsha prefers email; order A-1001 arrived brokenMemory managers with collections or profiles
EpisodicPast experiences, with what workedOffering a voucher calmed a customer about a late parcelA memory manager with an episode schema
ProceduralHow the agent behaves"Always reply on the channel the customer asked for"Prompt optimizers that rewrite the system prompt

Core API and stateful integration

LangMem is built in two layers. The core API is a set of functions with no storage: a memory manager takes a conversation and the memories you already have, and returns the new state; a prompt optimizer takes a prompt and feedback, and returns a better prompt. The stateful layer uses LangGraph's store: a store manager searches, saves and deletes memories for you, and two memory tools let an agent save and search on its own.

How a memory is made
A conversation endsor pausesA model reads itwith the memories it hasThe model calls toolscreate or patchLangMem saves the resultin the customer's namespaceA later chat searchesthe store, by meaning
Hover or tap a piece to see what it is and which lesson built it.
Follow a memory

Pick one to watch it run, step by step.

Hot path and background memory

Memories can be formed at two moments. In the hot path, the agent calls a memory tool during the conversation, so a memory exists straight away, at the cost of a slower reply. In the background, a separate call reads the conversation after it ends or goes quiet, so the user never waits. The course builds both, then combines them in the final project.

The support assistant this course builds

One example grows through every lesson: a support assistant for an online shop. Asha writes in about order A-1001, which arrived broken, and asks to be emailed. The assistant extracts that, keeps it current when she changes her mind, stores it under her user id, and finds it again in a new conversation days later. The last lesson assembles the whole assistant and shows what it remembers, and what it cannot remember for a customer it has never met.

Everything in this course, and where it is going
First memoriesMemory typesStoring memoriesBeyond extractiona memory managerthe extraction requestchat modelscollectionsupdates and deletesprofilesepisodesthe storesemantic searchstore managersan agent that remembersbackground memoryrunning summariesprompt optimizationthe support assistant
Hover or tap a piece to see what it is and which lesson built it.

Models and keys used for every run

Chat calls go to openai/gpt-oss-120b on Groq, and the store's semantic search uses Google's gemini-embedding-2; both have free keys, set up in Installation and setup. Model output changes from run to run, so your replies will be worded differently from the ones shown.

Five lessons play clips from the Agentic Memory module of the AI Security Course video, where semantic, episodic and procedural memory, vector store memory and summary memory are explained. The video builds each one by hand in plain Python; each lesson then shows the LangMem feature that does the same job.

Before you start

  • Python 3.10 or later.
  • Lists, dictionaries and Pydantic models in Python.
  • What a chat model and a tool call are. The LangChain course covers both; the agent lessons use LangChain's create_agent.
Back toAll frameworks

Every expert started right here.