Framework deep dive: LangGraph memory and the 27 solutions
Nov 19, 2026 Β· Michael Chang Β· Status: β used in NurseOps Now (AI Assist (the app's chat helper for staff questions))
Show definitions in ( ) Β· hover a highlighted word for its meaning, click it for details Β· open with ?defs=1 to show definitions
Part of: Remembering the right things: state management in NurseOps Now Β· All 27 solutions Β· Other frameworks: AutoGen Β· CrewAI Β· LlamaIndex
Read in this order
- In plain words
- What it gives you for memory: from the current docs
- How to implement it (ServiceApps): code and output
- The 27 solutions with LangGraph: replace, complement or still yours
- Use both: what you still build
- In NurseOps Now, Trade-offs and Interview answer
In plain words
LangGraph (a tool for building AI workflows step by step) builds an AI app as a graph of steps (nodes) that share a state (everything the app must remember to continue correctly). Its memory story is two pieces: a checkpointer (the code that saves a checkpoint after each step) that saves each conversation (thread (one saved conversation, here one per user and case)) after every step, and a Store for long-term memories shared across conversations.
In plain terms: a notebook per conversation that saves itself after every line, plus a shared filing cabinet per user.
What it gives you for memory
From the official memory docs (LangGraph memory docs), checked on Nov 19, 2026:
- Short-term: messages in graph state (everything the app must remember to continue correctly), saved per
thread_id; trim withtrim_messages(by tokens (pieces of words the AI reads and writes; cost is per token)) or delete withRemoveMessage. - Persistence: checkpointers (the code that saves a checkpoint after each step)
InMemorySaver,SqliteSaver,PostgresSaver,MongoDBSaver,RedisSaver(and more);get_state,get_state_history, resume withinvoke(None, config);durabilitymodes;EncryptedSerializerfor encryption at rest (a common way for programs to talk over the web using URLs). - Long-term: Store (
InMemoryStore,PostgresStore,RedisStore, β¦) with tuple namespaces like(user_id, "memories"),put/get/search, optional semantic search with anindex. - Summarizing: LangMem's
SummarizationNode, or your ownsummarykey. - Deleting:
checkpointer.delete_thread(thread_id); no built-in TTL (the docs suggest a cron job).
How to implement it (ServiceApps)
Illustrative example: made-up data, no ServiceApps (a company platform for IT tickets, HR requests and help-center articles) instance. The code was run as shown; the model is a scripted stand-in, so no API key (a secret code that lets the app use a paid service) is needed.
The scenario. ServiceApps (a company platform for IT tickets, HR requests and help-center articles) Assist as a one-node graph: each conversation is a thread (one saved conversation, here one per user and case) (u42:INC0012345), the user's saved preference is in the Store, and only the last ~60 tokens (pieces of words the AI reads and writes; cost is per token) of chat are sent.
Steps.
- Compile the graph with a checkpointer (the code that saves a checkpoint after each step) (persistence) and a Store (long-term memory).
- Pass
thread_id(conversation) anduser_idin the config on every call. - In the node, trim the messages by tokens (pieces of words the AI reads and writes; cost is per token) and read the user's memories from the Store.
- Delete a conversation with
checkpointer.delete_thread().
The code (Python):
from langchain_core.messages import AIMessage, HumanMessage, trim_messages
from langchain_core.messages.utils import count_tokens_approximately
from langgraph.checkpoint.memory import InMemorySaver
from langgraph.graph import START, MessagesState, StateGraph
from langgraph.store.base import BaseStore
from langgraph.store.memory import InMemoryStore
RULES = "You are ServiceApps Assist. Cite KB numbers."
def respond(state: MessagesState, config, *, store: BaseStore):
user = config["configurable"]["user_id"]
window = trim_messages(state["messages"], strategy="last", token_counter=count_tokens_approximately,
max_tokens=60, start_on="human") # short-term limit (7.1)
prefs = [i.value["text"] for i in store.search((user, "memories"))] # long-term memory (7.3)
# a real node would call the model with RULES + prefs + window; here we report what it would send
return {"messages": [AIMessage(f"(would send {len(window)} of {len(state['messages'])} messages; memories: {prefs})")]}
builder = StateGraph(MessagesState)
builder.add_node("respond", respond)
builder.add_edge(START, "respond")
store = InMemoryStore()
graph = builder.compile(checkpointer=InMemorySaver(), store=store) # persistence + long-term store
store.put(("u42", "memories"), "pref-1", {"text": "prefers short bullet answers"})
cfg = {"configurable": {"thread_id": "u42:INC0012345", "user_id": "u42"}}
for q in ["My VPN shows error 809", "I'm on hotel Wi-Fi", "Still failing on my hotspot"]:
out = graph.invoke({"messages": [HumanMessage(q)]}, cfg)
print(f"{q!r:32} -> {out['messages'][-1].content}")
print("saved in thread:", len(graph.get_state(cfg).values["messages"]), "messages")
new = {"configurable": {"thread_id": "u42:general", "user_id": "u42"}}
print("new thread, same user:", graph.invoke({"messages": [HumanMessage("Hi")]}, new)["messages"][-1].content)
graph.checkpointer.delete_thread("u42:INC0012345")
print("after delete_thread:", graph.get_state(cfg).values.get("messages", []))
Output (from running the code above on Nov 19, 2026):
'My VPN shows error 809' -> (would send 1 of 1 messages; memories: ['prefers short bullet answers']) "I'm on hotel Wi-Fi" -> (would send 3 of 3 messages; memories: ['prefers short bullet answers']) 'Still failing on my hotspot' -> (would send 3 of 5 messages; memories: ['prefers short bullet answers']) saved in thread: 6 messages new thread, same user: (would send 1 of 1 messages; memories: ['prefers short bullet answers']) after delete_thread: []
What to watch for.
- Use
SqliteSaver/PostgresSaverin production;InMemorySaverloses everything on restart. - Mask personal data before it reaches state (everything the app must remember to continue correctly) or the Store; LangGraph (a tool for building AI workflows step by step) doesn't redact.
- Plan retention yourself: delete old threads (one saved conversation, here one per user and case) on a schedule.
The 27 solutions with LangGraph
π Replace = LangGraph (a tool for building AI workflows step by step) does it, you configure it (8 of 27). π€ Complement = use both: LangGraph (a tool for building AI workflows step by step) gives the mechanism, you add the rules (14). π Still yours = build it yourself (5). β = not a memory feature, so from general knowledge rather than the memory docs; check the current docs.
| Memory solution | With LangGraph | How | Solution |
|---|---|---|---|
| Three-Tier Memory: Short-Term (Context Window) (what the AI sees in the current call) | π€ Complement | Messages live (using the real Claude API (costs money), not a fake stand-in) in graph state (everything the app must remember to continue correctly) per thread (one saved conversation, here one per user and case); you trim them with trim_messages | Deep dive |
| Three-Tier Memory: Long-Term (Vector Store) (knowledge saved outside the model and searched when needed) | π Replace | Store (InMemoryStore, PostgresStore, β¦) with semantic search, per namespace | Deep dive |
| Three-Tier Memory: Episodic (Experience Log) (a record of what happened, step by step) | π€ Complement | get_state_history replays a thread (one saved conversation, here one per user and case)'s checkpoints (saved copies of a conversation's state); the audit log (a permanent record of who did what and when) is yours | Deep dive |
| Agentic Outcome: Token Budgets (keeping each call within a planned size) | π€ Complement | trim_messages(max_tokens=...); the budget per zone is yours | Deep dive |
| Agentic Outcome: Hybrid Memory Systems (recent chat in the window plus long-term search) | π Replace | Checkpointer (the code that saves a checkpoint after each step) (short-term) + Store (long-term) in one graph | Deep dive |
| Agentic Outcome: Strict State Serialization (saving state so work can pause, crash and resume without loss) | π Replace | Checkpointers (the code that saves a checkpoint after each step) save after every step; resume with invoke(None, config); durability modes | Deep dive |
| Token Counting Middleware (code that counts tokens before every AI call and acts when the window gets too full) | π€ Complement | trim_messages with a token_counter; thresholds (the cut-off a score must stay above) and actions are yours | Deep dive |
| Dynamic Context Loading (giving the AI tools to fetch data only when it needs it, instead of putting everything in the prompt) | π Replace | Tools (a function the AI can call, such as policy search) and tool (a function the AI can call, such as policy search) nodes are standard β | Deep dive |
| System Prompt Pinning (keeping the rules in a protected place that is sent on every call and never trimmed) | π€ Complement | You add the system prompt (the standing instructions that set the AI's rules and role) in your node, outside the trimmed history β | Deep dive |
| Textual Summarization (rewriting old conversation into short, dense notes) | π€ Complement | LangMem SummarizationNode, or a custom summary key | Deep dive |
| Rolling Summaries (a short running summary that replaces old conversation turns) | π€ Complement | LangMem SummarizationNode(max_tokens_before_summary=...) | Deep dive |
| Entity Extraction (pulling key facts (names, dates, IDs) out of text into a structured record) | π€ Complement | Write extracted facts to the Store yourself, or use LangMem | Deep dive |
| Vector Compression via RAG (storing text as vectors and pulling back only the parts that match) | π Replace | Store semantic search over saved memories | Deep dive |
| The Engineering Trade-off: Fidelity vs. Capacity (the trade-off between keeping every detail and fitting more in the window) | π Still yours | No hard/soft split; your exact facts belong in your own tables | Deep dive |
| The Hot/Cold State Architecture (splitting memory into what is in the current call (hot) and what is saved for later (cold)) | π€ Complement | Graph state (everything the app must remember to continue correctly) is hot; checkpointers (the code that saves a checkpoint after each step) and the Store are cold; you decide what goes where | Deep dive |
| Structured Storage (SQL/Postgres) (a database with fixed tables for exact facts) | π Still yours | PostgresSaver stores checkpoints (saved copies of a conversation's state), not your business tables | Deep dive |
| Semantic Storage (Vector DB like Pinecone, Weaviate, or Chroma) (a vector database that finds text by meaning) | π Replace | Store with an index (embeddings (text turned into numbers so similar meanings sit close together)), many backends | Deep dive |
| Session Caching (Redis/Key-Value) (saving a conversation's state so it can pause and resume) | π Replace | Checkpointers (the code that saves a checkpoint after each step) incl. RedisSaver, keyed by thread_id | Deep dive |
| The Rehydration Pattern (fetch saved state, keep only what's relevant, and put it back into the next call) | π€ Complement | Reload by thread_id, memories by namespace; filtering and injection (hidden text that tries to give the AI new orders) are yours | Deep dive |
| Sanitization layer (code that masks personal details and secrets before anything is saved) | π Still yours | No redaction; EncryptedSerializer encrypts checkpoints (saved copies of a conversation's state) at rest (a common way for programs to talk over the web using URLs) | Deep dive |
| TTL (time-to-live) expiration (deleting saved data automatically after a set time) | π Still yours | No built-in TTL in the docs; they suggest a cron job to delete old checkpoints (saved copies of a conversation's state) | Deep dive |
| GDPR Right to Be Forgotten (a person's right to have their stored data deleted (from the EU's GDPR law)) | π€ Complement | checkpointer.delete_thread(thread_id); Store items deleted by key | Deep dive |
| Engineering Fix: Recursive Goal Injection (repeating a short reminder of the rules before every AI answer) | π€ Complement | Add the reminder in the node that builds the prompt (the instructions and text given to the AI) β | Deep dive |
| Engineering Fix: Strict RAG and Citation Enforcement (answering only from retrieved sources, and flagging any answer without one) | π Still yours | Retrieval (finding the right section of the right policy) tools (a function the AI can call, such as policy search) yes; checking citations (pointers to the exact page and quote that support each claim) is yours β | Deep dive |
| Input Filtering: Relevance Pruning (checking and trimming a question before the AI sees it) | π€ Complement | Add a gate (an automatic check that blocks a change when scores drop) node before the model (as NurseOps Now does) β | Deep dive |
| Process Control: Self-Correction Loop (checking the AI's answer and sending it back once to fix what failed) | π€ Complement | Conditional edges loop back to the model; the check is yours β | Deep dive |
| Output Guardrails: Schema Enforcement (requiring the AI's answer to match a fixed shape, checked in code) | π Replace | Structured output with a Pydantic (a library that checks data fits a fixed form) model β | Deep dive |
Use both: what you still build
Still yours with LangGraph (a tool for building AI workflows step by step):
- The Engineering Trade-off: Fidelity vs. Capacity (the trade-off between keeping every detail and fitting more in the window): No hard/soft split; your exact facts belong in your own tables
- Structured Storage (SQL/Postgres) (a database with fixed tables for exact facts):
PostgresSaverstores checkpoints (saved copies of a conversation's state), not your business tables - Sanitization layer (code that masks personal details and secrets before anything is saved): No redaction;
EncryptedSerializerencrypts checkpoints (saved copies of a conversation's state) at rest (a common way for programs to talk over the web using URLs) - TTL (time-to-live) expiration (deleting saved data automatically after a set time): No built-in TTL in the docs; they suggest a cron job to delete old checkpoints (saved copies of a conversation's state)
- Engineering Fix: Strict RAG and Citation Enforcement (answering only from retrieved sources, and flagging any answer without one): Retrieval (finding the right section of the right policy) tools (a function the AI can call, such as policy search) yes; checking citations (pointers to the exact page and quote that support each claim) is yours
Use both (complement), with your rules on top:
- Three-Tier Memory: Short-Term (Context Window) (what the AI sees in the current call): Messages live (using the real Claude API (costs money), not a fake stand-in) in graph state (everything the app must remember to continue correctly) per thread (one saved conversation, here one per user and case); you trim them with
trim_messages - Three-Tier Memory: Episodic (Experience Log) (a record of what happened, step by step):
get_state_historyreplays a thread (one saved conversation, here one per user and case)'s checkpoints (saved copies of a conversation's state); the audit log (a permanent record of who did what and when) is yours - Agentic Outcome: Token Budgets (keeping each call within a planned size):
trim_messages(max_tokens=...); the budget per zone is yours - Token Counting Middleware (code that counts tokens before every AI call and acts when the window gets too full):
trim_messageswith atoken_counter; thresholds (the cut-off a score must stay above) and actions are yours - System Prompt Pinning (keeping the rules in a protected place that is sent on every call and never trimmed): You add the system prompt (the standing instructions that set the AI's rules and role) in your node, outside the trimmed history
- Textual Summarization (rewriting old conversation into short, dense notes): LangMem
SummarizationNode, or a customsummarykey - Rolling Summaries (a short running summary that replaces old conversation turns): LangMem
SummarizationNode(max_tokens_before_summary=...) - Entity Extraction (pulling key facts (names, dates, IDs) out of text into a structured record): Write extracted facts to the Store yourself, or use LangMem
- The Hot/Cold State Architecture (splitting memory into what is in the current call (hot) and what is saved for later (cold)): Graph state (everything the app must remember to continue correctly) is hot; checkpointers (the code that saves a checkpoint after each step) and the Store are cold; you decide what goes where
- The Rehydration Pattern (fetch saved state, keep only what's relevant, and put it back into the next call): Reload by
thread_id, memories by namespace; filtering and injection (hidden text that tries to give the AI new orders) are yours - GDPR Right to Be Forgotten (a person's right to have their stored data deleted (from the EU's GDPR law)):
checkpointer.delete_thread(thread_id); Store items deleted by key - Engineering Fix: Recursive Goal Injection (repeating a short reminder of the rules before every AI answer): Add the reminder in the node that builds the prompt (the instructions and text given to the AI)
- Input Filtering: Relevance Pruning (checking and trimming a question before the AI sees it): Add a gate (an automatic check that blocks a change when scores drop) node before the model (as NurseOps Now does)
- Process Control: Self-Correction Loop (checking the AI's answer and sending it back once to fix what failed): Conditional edges loop back to the model; the check is yours
In NurseOps Now
Used today: AI Assist (the app's chat helper for staff questions) compiles its LangGraph (a tool for building AI workflows step by step) graph with SqliteSaver (backend/app/services/assist.py), one thread per user and case (each nurse's conversation about each case is saved separately), cleared with delete_thread(). Masking (pii.py), the 10-turn window and SQL facts are NurseOps' own. The next step would be the Store for long-term per-user memory.
Trade-offs
- Most control and the best persistence story, but you write more of the flow yourself.
- Short-term limits and summaries are your code (or LangMem), not automatic.
Interview answer
"In LangGraph (a tool for building AI workflows step by step) I use a checkpointer (the code that saves a checkpoint after each step) for per-thread memory, which saves after every step so a conversation survives restarts, and the Store for long-term memories by user namespace. I trim by tokens (pieces of words the AI reads and writes; cost is per token) in the node, mask before saving, and delete threads (one saved conversation, here one per user and case) on a schedule because there's no built-in TTL."
All data in this post is made up.
Key terms
Every highlighted word in this post links here. Click β© Back to return to the spot you came from.
- agentic outcome: hybrid memory systems
- Recent chat in the window plus long-term search.Used in: The 27 solutions with LangGraphβ© Back to where you were
- agentic outcome: strict state serialization
- Saving state so work can pause, crash and resume without loss.Used in: The 27 solutions with LangGraphβ© Back to where you were
- agentic outcome: token budgets
- Keeping each call within a planned size.Used in: The 27 solutions with LangGraph, Use both: what you still buildβ© Back to where you were
- AI Assist
- The app's chat helper for staff questions.Used in: In NurseOps Nowβ© Back to where you were
- API key
- A secret code that lets the app use a paid service.Used in: How to implement it (ServiceApps)β© Back to where you were
- audit log
- A permanent record of who did what and when.Used in: The 27 solutions with LangGraph, Use both: what you still buildβ© Back to where you were
- checkpointer
- The code that saves a checkpoint after each step.Used in: In plain words, What it gives you for memory, How to implement it (ServiceApps), The 27 solutions with LangGraph, Use both: what you still build, Interview answerβ© Back to where you were
- checkpoints
- Saved copies of a conversation's state.Used in: The 27 solutions with LangGraph, Use both: what you still buildβ© Back to where you were
- citations
- Pointers to the exact page and quote that support each claim.Used in: The 27 solutions with LangGraph, Use both: what you still buildβ© Back to where you were
- dynamic context loading
- Giving the AI tools to fetch data only when it needs it, instead of putting everything in the prompt.Used in: The 27 solutions with LangGraphβ© Back to where you were
- embeddings
- Text turned into numbers so similar meanings sit close together.Used in: The 27 solutions with LangGraphβ© Back to where you were
- engineering fix: recursive goal injection
- Repeating a short reminder of the rules before every AI answer.Used in: The 27 solutions with LangGraph, Use both: what you still buildβ© Back to where you were
- engineering fix: strict rag and citation enforcement
- Answering only from retrieved sources, and flagging any answer without one.Used in: The 27 solutions with LangGraph, Use both: what you still buildβ© Back to where you were
- entity extraction
- Pulling key facts (names, dates, IDs) out of text into a structured record.Used in: The 27 solutions with LangGraph, Use both: what you still buildβ© Back to where you were
- gate
- An automatic check that blocks a change when scores drop.Used in: The 27 solutions with LangGraph, Use both: what you still buildβ© Back to where you were
- gdpr right to be forgotten
- A person's right to have their stored data deleted (from the EU's GDPR law).Used in: The 27 solutions with LangGraph, Use both: what you still buildβ© Back to where you were
- injection
- Hidden text that tries to give the AI new orders.Used in: The 27 solutions with LangGraph, Use both: what you still buildβ© Back to where you were
- input filtering: relevance pruning
- Checking and trimming a question before the AI sees it.Used in: The 27 solutions with LangGraph, Use both: what you still buildβ© Back to where you were
- LangGraph
- A tool for building AI workflows step by step.Used in: In plain words, How to implement it (ServiceApps), The 27 solutions with LangGraph, Use both: what you still build, In NurseOps Now, Interview answerβ© Back to where you were
- live
- Using the real Claude API (costs money), not a fake stand-in.Used in: The 27 solutions with LangGraph, Use both: what you still buildβ© Back to where you were
- one thread per user and case
- Each nurse's conversation about each case is saved separately.Used in: In NurseOps Nowβ© Back to where you were
- output guardrails: schema enforcement
- Requiring the AI's answer to match a fixed shape, checked in code.Used in: The 27 solutions with LangGraphβ© Back to where you were
- process control: self-correction loop
- Checking the AI's answer and sending it back once to fix what failed.Used in: The 27 solutions with LangGraph, Use both: what you still buildβ© Back to where you were
- prompt
- The instructions and text given to the AI.Used in: The 27 solutions with LangGraph, Use both: what you still buildβ© Back to where you were
- Pydantic
- A library that checks data fits a fixed form.Used in: The 27 solutions with LangGraphβ© Back to where you were
- REST
- A common way for programs to talk over the web using URLs.Used in: What it gives you for memory, The 27 solutions with LangGraph, Use both: what you still buildβ© Back to where you were
- retrieval
- Finding the right section of the right policy.Used in: The 27 solutions with LangGraph, Use both: what you still buildβ© Back to where you were
- rolling summaries
- A short running summary that replaces old conversation turns.Used in: The 27 solutions with LangGraph, Use both: what you still buildβ© Back to where you were
- sanitization layer
- Code that masks personal details and secrets before anything is saved.Used in: The 27 solutions with LangGraph, Use both: what you still buildβ© Back to where you were
- semantic storage (vector db like pinecone, weaviate, or chroma)
- A vector database that finds text by meaning.Used in: The 27 solutions with LangGraphβ© Back to where you were
- ServiceApps
- A company platform for IT tickets, HR requests and help-center articles.Used in: How to implement it (ServiceApps)β© Back to where you were
- session caching (redis/key-value)
- Saving a conversation's state so it can pause and resume.Used in: The 27 solutions with LangGraphβ© Back to where you were
- state
- Everything the app must remember to continue correctly.Used in: In plain words, What it gives you for memory, How to implement it (ServiceApps), The 27 solutions with LangGraph, Use both: what you still buildβ© Back to where you were
- structured storage (sql/postgres)
- A database with fixed tables for exact facts.Used in: The 27 solutions with LangGraph, Use both: what you still buildβ© Back to where you were
- system prompt
- The standing instructions that set the AI's rules and role.Used in: The 27 solutions with LangGraph, Use both: what you still buildβ© Back to where you were
- system prompt pinning
- Keeping the rules in a protected place that is sent on every call and never trimmed.Used in: The 27 solutions with LangGraph, Use both: what you still buildβ© Back to where you were
- textual summarization
- Rewriting old conversation into short, dense notes.Used in: The 27 solutions with LangGraph, Use both: what you still buildβ© Back to where you were
- the engineering trade-off: fidelity vs. capacity
- The trade-off between keeping every detail and fitting more in the window.Used in: The 27 solutions with LangGraph, Use both: what you still buildβ© Back to where you were
- the hot/cold state architecture
- Splitting memory into what is in the current call (hot) and what is saved for later (cold).Used in: The 27 solutions with LangGraph, Use both: what you still buildβ© Back to where you were
- the rehydration pattern
- Fetch saved state, keep only what's relevant, and put it back into the next call.Used in: The 27 solutions with LangGraph, Use both: what you still buildβ© Back to where you were
- thread
- One saved conversation, here one per user and case.Used in: In plain words, How to implement it (ServiceApps), The 27 solutions with LangGraph, Use both: what you still build, Interview answerβ© Back to where you were
- three-tier memory: episodic (experience log)
- A record of what happened, step by step.Used in: The 27 solutions with LangGraph, Use both: what you still buildβ© Back to where you were
- three-tier memory: long-term (vector store)
- Knowledge saved outside the model and searched when needed.Used in: The 27 solutions with LangGraphβ© Back to where you were
- three-tier memory: short-term (context window)
- What the AI sees in the current call.Used in: The 27 solutions with LangGraph, Use both: what you still buildβ© Back to where you were
- threshold
- The cut-off a score must stay above.Used in: The 27 solutions with LangGraph, Use both: what you still buildβ© Back to where you were
- token counting middleware
- Code that counts tokens before every AI call and acts when the window gets too full.Used in: The 27 solutions with LangGraph, Use both: what you still buildβ© Back to where you were
- tokens
- Pieces of words the AI reads and writes; cost is per token.Used in: What it gives you for memory, How to implement it (ServiceApps), Interview answerβ© Back to where you were
- tool
- A function the AI can call, such as policy search.Used in: The 27 solutions with LangGraph, Use both: what you still buildβ© Back to where you were
- ttl (time-to-live) expiration
- Deleting saved data automatically after a set time.Used in: The 27 solutions with LangGraph, Use both: what you still buildβ© Back to where you were
- vector compression via rag
- Storing text as vectors and pulling back only the parts that match.Used in: The 27 solutions with LangGraphβ© Back to where you were