Skip to content

Instantly share code, notes, and snippets.

@donbr
Created January 29, 2026 18:35
Show Gist options
  • Select an option

  • Save donbr/484e72b61c9de790bbc59c00fa0c2fc3 to your computer and use it in GitHub Desktop.

Select an option

Save donbr/484e72b61c9de790bbc59c00fa0c2fc3 to your computer and use it in GitHub Desktop.
LangGraph memory mechanisms (mechanism × persistence)

LangGraph memory mechanisms (mechanism × persistence)

1. Execution / short-term memory (checkpointers)

Mechanism Purpose In-memory / local DB-persisted Notes
MemorySaver Persist graph state per step (thread continuity) ✅ Yes ❌ No Notebook/dev only; lost on process restart
PostgresSaver Durable execution state ❌ No ✅ Postgres Required for resumable workflows, HITL, failures
(others) (Future / custom savers) Checkpointer interface is pluggable

What it stores

  • Full graph state
  • Current node
  • Messages / flags / intermediate state

Key idea

Checkpointers persist execution, not knowledge.


2. Long-term / cross-thread memory (Store API)

Mechanism Purpose In-memory / local DB-persisted Notes
InMemoryStore Cross-thread memory items ✅ Yes ❌ No Process-local KV store
PostgresStore Durable memory items ❌ No ✅ Postgres Production default
(custom store) S3, Redis, etc. Depends Depends Implement BaseStore

What it stores

  • Arbitrary key/value objects
  • Namespaced by tuples (e.g. (user_id, "profile"))
  • Optional embedding indexes

Key idea

Stores persist agent memory, not execution flow.


3. Semantic memory (Store + embeddings)

Mechanism Purpose In-memory / local DB-persisted Notes
InMemoryStore + embeddings Semantic recall ✅ Yes ❌ No Embeddings live in RAM
PostgresStore + embeddings Durable semantic memory ❌ No ✅ Postgres Requires vector support
External vector DB (pattern) Large-scale semantic memory ❌ No ✅ External LangGraph does not mandate one

What it stores

  • Text or structured blobs
  • Vector embeddings
  • Retrieved via store.search()

Key idea

Semantic memory is a capability of the store, not a separate primitive.


4. Episodic memory (pattern, not a primitive)

Mechanism Purpose In-memory / local DB-persisted Notes
Store-backed episodes Recall past interactions ✅ Yes (InMemoryStore) ✅ Yes (PostgresStore) Pattern implemented on top of Store
Few-shot injection Condition LLM behavior N/A N/A Prompt-time use only

What it stores

  • Past interactions
  • Outcomes / feedback
  • Free-form or structured episode records

Key idea

Episodic memory is modeled data + retrieval, not a LangGraph primitive.


5. Procedural memory (pattern, not a primitive)

Mechanism Purpose In-memory / local DB-persisted Notes
Store-backed instructions Agent behavior policy ✅ Yes ✅ Yes Often versioned text blobs
Reflection node Self-modification N/A N/A Writes updated policy to Store

What it stores

  • Instructions
  • Policies
  • Strategy hints

Key idea

Procedural memory is policy state, externalized via Store.


Cross-cutting summary (the important part)

Where memory actually lives

Memory category Lives inside graph? Lives outside graph?
Graph definition ❌ (pure code)
Execution state ✅ (checkpointer)
Agent memory ✅ (store)
Domain knowledge ❌ (should live elsewhere, e.g. Graphiti)

LangGraph graphs are stateless. All memory is external.


Minimal production guidance (rule of thumb)

Use case Required components
Chat continuity PostgresSaver
User profiles / preferences PostgresStore
Semantic RAG PostgresStore or external vector DB
Learning from experience PostgresStore
World model / facts Graphiti (separate system)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment