langgraph-persistence
Skill1.3k starsChanged 2 months agoMITView on GitHub
INVOKE THIS SKILL when your LangGraph needs to persist state, remember conversations, travel through history, or configure subgraph checkpointer scoping. Covers checkpointers, thread_id, time travel, Store, and subgraph persistence modes.
- Reads credentials
4 other projects use a version of this, 3 of them edited.
Trending
Quiet since October.thin dataabout the whole repository
Most recently taken up by
- zoujindouGithub/agent-skillsedited, first seen Sep 2, 2026
- HarambeeAI/bayes-shiptheir own version, first seen Apr 15, 2026
- Harmeet10000/skillsedited, first seen Mar 15, 2026
- langchain-ai/skills-benchmarksedited, first seen Mar 2, 2026
Who's talking about langchain-ai/langchain-skills
- sudosubin/agents.nix“claude-code-plugins.github.langchain-ai.langchain-skills: init at 0.1.0”GitHub · Oct 4, 2026
- langchain-ai/langsmith-skills“Add online evaluation engineering skill”GitHub · Oct 2, 2026
- sudosubin/agents.nix“agent-skills.github.langchain-ai.langchain-skills: init at 0.1.0”GitHub · Sep 29, 2026
- langchain-ai/langchain-plugins“langchain-skills license?”GitHub · Sep 23, 2026
- penguinboy1108/AI_Engineering_Playbook“Monthly engineering audit — 2026-09-07”GitHub · Sep 6, 2026
The biggest 5 of 11 mentions linking to the repository that our crawl found. Each line is their own headline.
See all 11
Talked about on GitHub (11 times).
On GitHub · 11
- Oct 4, 2026claude-code-plugins.github.langchain-ai.langchain-skills: init at 0.1.0 — sudosubin/agents.nix0 reactions
- Oct 2, 2026Add online evaluation engineering skill — langchain-ai/langsmith-skills0 reactions
- Sep 29, 2026agent-skills.github.langchain-ai.langchain-skills: init at 0.1.0 — sudosubin/agents.nix0 reactions
- Sep 23, 2026langchain-skills license? — langchain-ai/langchain-plugins0 reactions · 2 comments
- Sep 6, 2026Monthly engineering audit — 2026-09-07 — penguinboy1108/AI_Engineering_Playbook0 reactions
6 more on GitHub
- May 20, 2026Duplicate concepts should collapse into one — janikmu/raidar0 reactions
- May 9, 2026set up LangGraph project — ks6088ts-labs/concierge0 reactions
- Apr 21, 2026SKILL Requests — TBice123123/langchain-dev-utils0 reactions
- Mar 20, 2026Prebuilt LangChain/LangSmith skills / install command — langchain-ai/deepagents0 reactions · 5 comments
- Mar 19, 2026feat: add langchain skills repo links to more docs pages [closes DOC-846] — langchain-ai/docs0 reactions · 2 comments
- Mar 10, 2026Add Claude Code plugin manifest and marketplace — langchain-ai/langsmith-skills0 reactions
Other versions4 projects use a version of this.
Word for word · 0
None found.
Edited · 3
- langchain-ai/skills-benchmarks★ 11899% same
- Harmeet10000/skills★ 799% same
- zoujindouGithub/agent-skills★ 149% same
Wrote their own version · 1
- HarambeeAI/bayes-ship★ 1same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository22 other files it gives its agents.
- config/AGENTS.mdAGENTS.md
- deep-agents-coreSkill
- deep-agents-memorySkill
- deep-agents-orchestrationSkill
- deepagents-python-quickstartSkill
- deepagents-typescript-quickstartSkill
- ecosystem-primerSkill
- eval-engineeringSkill
- langchain-dependenciesSkill
- langchain-fundamentalsSkill
- langchain-middlewareSkill
- langchain-python-quickstartSkill
- langchain-ragSkill
- langchain-typescript-quickstartSkill
- langgraph-cliSkill
- langgraph-decision-modelsSkill
- langgraph-fundamentalsSkill
- langgraph-human-in-the-loopSkill
- langgraph-python-quickstartSkill
- langgraph-typescript-quickstartSkill
- managed-deep-agentsSkill
- swarmSkill
The file
We split this skill into the rules it gives an agent
9 rules. 5 are common, 0 are distinctive, and 4 are very specific to this project.
5
Common
Most of the 3 edited versions we read keep these.
0
Distinctive
This author's own choices. Worth a look.
4
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 249
When compiling a subgraph, the checkpointer parameter controls persistence behavior.
- Very specific: line 314
When multiple different stateful subgraphs run in parallel, wrap each in its own StateGraph with a unique node name for stable namespace …
- Common: line 373
Use a Store for cross-thread memory to share user preferences across conversations.
- Common: line 448
Always provide thread_id in config to enable state persistence.
- Common: line 480
Use PostgresSaver instead of InMemorySaver for production persistence.
- Common: line 494
Use PostgresSaver instead of MemorySaver for production persistence.
- Common: line 511
Use Overwrite to replace state values instead of passing through reducers.
- Very specific: line 580
Use InMemorySaver in production — data lost on restart.
- Very specific: line 583
Run the same stateful subgraph (checkpointer=True) in parallel within one node — namespace conflict
“Common” is measured: kept by at least 6 in 10 of the 3 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
<overview>
LangGraph's persistence layer enables durable execution by checkpointing graph state:- Checkpointer: Saves/loads graph state at every super-step
- Thread ID: Identifies separate checkpoint sequences (conversations)
- Store: Cross-thread memory for user preferences, facts
Two memory types:
- Short-term (checkpointer): Thread-scoped conversation history
- Long-term (store): Cross-thread user preferences, facts
</overview>
<checkpointer-selection>| Checkpointer | Use Case | Production Ready |
InMemorySaver | Testing, development | No |
SqliteSaver | Local development | Partial |
PostgresSaver | Production | Yes |
</checkpointer-selection>Checkpointer Setup
<ex-basic-persistence>
<python>
Set up a basic graph with in-memory checkpointing and thread-based state persistence.from langgraph.checkpoint.memory import InMemorySaver
from langgraph.graph import StateGraph, START, END
from typing_extensions import TypedDict, Annotated
import operator
class State(TypedDict):
messages: Annotated[list, operator.add]
def add_message(state: State) -> dict:
return {"messages": ["Bot response"]}
checkpointer = InMemorySaver()
graph = (
StateGraph(State)
.add_node("respond", add_message)
.add_edge(START, "respond")
.add_edge("respond", END)
.compile(checkpointer=checkpointer) # Pass at compile time
)
# ALWAYS provide thread_id
config = {"configurable": {"thread_id": "conversation-1"}}
result1 = graph.invoke({"messages": ["Hello"]}, config)
print(len(result1["messages"])) # 2
result2 = graph.invoke({"messages": ["How are you?"]}, config)
print(len(result2["messages"])) # 4 (previous + new)</python>
<typescript>
Set up a basic graph with in-memory checkpointing and thread-based state persistence.import { MemorySaver, StateGraph, StateSchema, MessagesValue, START, END } from "@langchain/langgraph";
import { HumanMessage } from "@langchain/core/messages";
const State = new StateSchema({ messages: MessagesValue });
const addMessage = async (state: typeof State.State) => {
return { messages: [{ role: "assistant", content: "Bot response" }] };
};
const checkpointer = new MemorySaver();
const graph = new StateGraph(State)
.addNode("respond", addMessage)
.addEdge(START, "respond")
.addEdge("respond", END)
.compile({ checkpointer });
// ALWAYS provide thread_id
const config = { configurable: { thread_id: "conversation-1" } };
const result1 = await graph.invoke({ messages: [new HumanMessage("Hello")] }, config);
console.log(result1.messages.length); // 2
const result2 = await graph.invoke({ messages: [new HumanMessage("How are you?")] }, config);
console.log(result2.messages.length); // 4 (previous + new)</typescript>
</ex-basic-persistence><ex-production-postgres>
<python>
Configure PostgreSQL-backed checkpointing for production deployments.import os
from langgraph.checkpoint.postgres import PostgresSaver
# Run once during deployment (not at application startup):
# PostgresSaver.from_conn_string(os.environ["DATABASE_URL"]).setup()
with PostgresSaver.from_conn_string(os.environ["DATABASE_URL"]) as checkpointer:
graph = builder.compile(checkpointer=checkpointer)</python>
<typescript>
Configure PostgreSQL-backed checkpointing for production deployments.import { PostgresSaver } from "@langchain/langgraph-checkpoint-postgres";
// Run once during deployment (not at application startup):
// await PostgresSaver.fromConnString(process.env.DATABASE_URL!).setup();
const checkpointer = PostgresSaver.fromConnString(process.env.DATABASE_URL!);
const graph = builder.compile({ checkpointer });</typescript>
</ex-production-postgres>Thread Management
<ex-separate-threads>
<python>
Demonstrate isolated state between different thread IDs.# Different threads maintain separate state
alice_config = {"configurable": {"thread_id": "user-alice"}}
bob_config = {"configurable": {"thread_id": "user-bob"}}
graph.invoke({"messages": ["Hi from Alice"]}, alice_config)
graph.invoke({"messages": ["Hi from Bob"]}, bob_config)
# Alice's state is isolated from Bob's</python>
<typescript>
Demonstrate isolated state between different thread IDs.// Different threads maintain separate state
const aliceConfig = { configurable: { thread_id: "user-alice" } };
const bobConfig = { configurable: { thread_id: "user-bob" } };
await graph.invoke({ messages: [new HumanMessage("Hi from Alice")] }, aliceConfig);
await graph.invoke({ messages: [new HumanMessage("Hi from Bob")] }, bobConfig);
// Alice's state is isolated from Bob's</typescript>
</ex-separate-threads>State History & Time Travel
<ex-resume-from-checkpoint>
<python>
Time travel: browse checkpoint history and replay or fork from a past state.config = {"configurable": {"thread_id": "session-1"}}
result = graph.invoke({"messages": ["start"]}, config)
# Browse checkpoint history
states = list(graph.get_state_history(config))
# Replay from a past checkpoint
past = states[-2]
result = graph.invoke(None, past.config) # None = resume from checkpoint
# Or fork: update state at a past checkpoint, then resume
fork_config = graph.update_state(past.config, {"messages": ["edited"]})
result = graph.invoke(None, fork_config)</python>
<typescript>
Time travel: browse checkpoint history and replay or fork from a past state.const config = { configurable: { thread_id: "session-1" } };
const result = await graph.invoke({ messages: ["start"] }, config);
// Browse checkpoint history (async iterable, collect to array)
const states: Awaited<ReturnType<typeof graph.getState>>[] = [];
for await (const state of graph.getStateHistory(config)) {
states.push(state);
}
// Replay from a past checkpoint
const past = states[states.length - 2];
const replayed = await graph.invoke(null, past.config); // null = resume from checkpoint
// Or fork: update state at a past checkpoint, then resume
const forkConfig = await graph.updateState(past.config, { messages: ["edited"] });
const forked = await graph.invoke(null, forkConfig);</typescript>
</ex-resume-from-checkpoint><ex-update-state>
<python>
Manually update graph state before resuming execution.config = {"configurable": {"thread_id": "session-1"}}
# Modify state before resuming
graph.update_state(config, {"data": "manually_updated"})
# Resume with updated state
result = graph.invoke(None, config)</python>
<typescript>
Manually update graph state before resuming execution.const config = { configurable: { thread_id: "session-1" } };
// Modify state before resuming
await graph.updateState(config, { data: "manually_updated" });
// Resume with updated state
const result = await graph.invoke(null, config);</typescript>
</ex-update-state>Subgraph Checkpointer Scoping
When compiling a subgraph, the checkpointer parameter controls persistence behavior. This is critical for subgraphs that use interrupts, need multi-turn memory, or run in parallel.
<subgraph-checkpointer-scoping-table>| Feature | checkpointer=False | None (default) | True |
| Interrupts (HITL) | No | Yes | Yes |
| Multi-turn memory | No | No | Yes |
| Multiple calls (different subgraphs) | Yes | Yes | Warning (namespace conflicts possible) |
| Multiple calls (same subgraph) | Yes | Yes | No |
| State inspection | No | Warning (current invocation only) | Yes |
</subgraph-checkpointer-scoping-table><subgraph-checkpointer-when-to-use>When to use each mode
checkpointer=False— Subgraph doesn't need interrupts or persistence. Simplest option, no checkpoint overhead.None(default / omitcheckpointer) — Subgraph needsinterrupt()but not multi-turn memory. Each invocation starts fresh but can pause/resume. Parallel execution works because each invocation gets a unique namespace.checkpointer=True— Subgraph needs to remember state across invocations (multi-turn conversations). Each call picks up where the last left off.
</subgraph-checkpointer-when-to-use><warning-stateful-subgraphs-parallel>Warning: Stateful subgraphs (checkpointer=True) do NOT support calling the same subgraph instance multiple times within a single node — the calls write to the same checkpoint namespace and conflict.
</warning-stateful-subgraphs-parallel><ex-subgraph-checkpointer-modes>
<python>
Choose the right checkpointer mode for your subgraph.# No interrupts needed — opt out of checkpointing
subgraph = subgraph_builder.compile(checkpointer=False)
# Need interrupts but not cross-invocation persistence (default)
subgraph = subgraph_builder.compile()
# Need cross-invocation persistence (stateful)
subgraph = subgraph_builder.compile(checkpointer=True)</python>
<typescript>
Choose the right checkpointer mode for your subgraph.// No interrupts needed — opt out of checkpointing
const subgraph = subgraphBuilder.compile({ checkpointer: false });
// Need interrupts but not cross-invocation persistence (default)
const subgraph = subgraphBuilder.compile();
// Need cross-invocation persistence (stateful)
const subgraph = subgraphBuilder.compile({ checkpointer: true });</typescript>
</ex-subgraph-checkpointer-modes><parallel-subgraph-namespacing>Parallel subgraph namespacing
When multiple different stateful subgraphs run in parallel, wrap each in its own StateGraph with a unique node name for stable namespace isolation:
<python>from langgraph.graph import MessagesState, StateGraph
def create_sub_agent(model, *, name, **kwargs):
"""Wrap an agent with a unique node name for namespace isolation."""
agent = create_agent(model=model, name=name, **kwargs)
return (
StateGraph(MessagesState)
.add_node(name, agent) # unique name -> stable namespace
.add_edge("__start__", name)
.compile()
)
fruit_agent = create_sub_agent(
"gpt-4.1-mini", name="fruit_agent",
tools=[fruit_info], prompt="...", checkpointer=True,
)
veggie_agent = create_sub_agent(
"gpt-4.1-mini", name="veggie_agent",
tools=[veggie_info], prompt="...", checkpointer=True,
)</python>
<typescript>import { StateGraph, StateSchema, MessagesValue, START } from "@langchain/langgraph";
function createSubAgent(model: string, { name, ...kwargs }: { name: string; [key: string]: any }) {
const agent = createAgent({ model, name, ...kwargs });
return new StateGraph(new StateSchema({ messages: MessagesValue }))
.addNode(name, agent) // unique name -> stable namespace
.addEdge(START, name)
.compile();
}
const fruitAgent = createSubAgent("gpt-4.1-mini", {
name: "fruit_agent", tools: [fruitInfo], prompt: "...", checkpointer: true,
});
const veggieAgent = createSubAgent("gpt-4.1-mini", {
name: "veggie_agent", tools: [veggieInfo], prompt: "...", checkpointer: true,
});</typescript>Note: Subgraphs added as nodes (via add_node) already get name-based namespaces automatically and don't need this wrapper.
</parallel-subgraph-namespacing>Long-Term Memory (Store)
<ex-long-term-memory-store>
<python>
Use a Store for cross-thread memory to share user preferences across conversations.from langgraph.store.memory import InMemoryStore
store = InMemoryStore()
# Save user preference (available across ALL threads)
store.put(("alice", "preferences"), "language", {"preference": "short responses"})
# Node with store — access via runtime
from langgraph.runtime import Runtime
def respond(state, runtime: Runtime):
prefs = runtime.store.get((state["user_id"], "preferences"), "language")
return {"response": f"Using preference: {prefs.value}"}
# Compile with BOTH checkpointer and store
graph = builder.compile(checkpointer=checkpointer, store=store)
# Both threads access same long-term memory
graph.invoke({"user_id": "alice"}, {"configurable": {"thread_id": "thread-1"}})
graph.invoke({"user_id": "alice"}, {"configurable": {"thread_id": "thread-2"}}) # Same preferences!</python>
<typescript>
Use a Store for cross-thread memory to share user preferences across conversations.import { MemoryStore } from "@langchain/langgraph";
const store = new MemoryStore();
// Save user preference (available across ALL threads)
await store.put(["alice", "preferences"], "language", { preference: "short responses" });
// Node with store — access via runtime
const respond = async (state: typeof State.State, runtime: any) => {
const item = await runtime.store?.get(["alice", "preferences"], "language");
return { response: `Using preference: ${item?.value?.preference}` };
};
// Compile with BOTH checkpointer and store
const graph = builder.compile({ checkpointer, store });
// Both threads access same long-term memory
await graph.invoke({ userId: "alice" }, { configurable: { thread_id: "thread-1" } });
await graph.invoke({ userId: "alice" }, { configurable: { thread_id: "thread-2" } }); // Same preferences!</typescript>
</ex-long-term-memory-store><ex-store-operations>
<python>
Basic store operations: put, get, search, and delete.from langgraph.store.memory import InMemoryStore
store = InMemoryStore()
store.put(("user-123", "facts"), "location", {"city": "San Francisco"}) # Put
item = store.get(("user-123", "facts"), "location") # Get
results = store.search(("user-123", "facts"), filter={"city": "San Francisco"}) # Search
store.delete(("user-123", "facts"), "location") # Delete</python>
</ex-store-operations>Fixes
<fix-thread-id-required>
<python>
Always provide thread_id in config to enable state persistence.# WRONG: No thread_id - state NOT persisted!
graph.invoke({"messages": ["Hello"]})
graph.invoke({"messages": ["What did I say?"]}) # Doesn't remember!
# CORRECT: Always provide thread_id
config = {"configurable": {"thread_id": "session-1"}}
graph.invoke({"messages": ["Hello"]}, config)
graph.invoke({"messages": ["What did I say?"]}, config) # Remembers!</python>
<typescript>
Always provide thread_id in config to enable state persistence.// WRONG: No thread_id - state NOT persisted!
await graph.invoke({ messages: [new HumanMessage("Hello")] });
await graph.invoke({ messages: [new HumanMessage("What did I say?")] }); // Doesn't remember!
// CORRECT: Always provide thread_id
const config = { configurable: { thread_id: "session-1" } };
await graph.invoke({ messages: [new HumanMessage("Hello")] }, config);
await graph.invoke({ messages: [new HumanMessage("What did I say?")] }, config); // Remembers!</typescript>
</fix-thread-id-required><fix-inmemory-not-for-production>
<python>
Use PostgresSaver instead of InMemorySaver for production persistence.# WRONG: Data lost on process restart
checkpointer = InMemorySaver() # In-memory only!
# CORRECT: Use persistent storage for production
from langgraph.checkpoint.postgres import PostgresSaver
with PostgresSaver.from_conn_string("postgresql://...") as checkpointer:
checkpointer.setup() # only needed on first use to create tables
graph = builder.compile(checkpointer=checkpointer)</python>
<typescript>
Use PostgresSaver instead of MemorySaver for production persistence.// WRONG: Data lost on process restart
const checkpointer = new MemorySaver(); // In-memory only!
// CORRECT: Use persistent storage for production
import { PostgresSaver } from "@langchain/langgraph-checkpoint-postgres";
const checkpointer = PostgresSaver.fromConnString("postgresql://...");
await checkpointer.setup(); // only needed on first use to create tables</typescript>
</fix-inmemory-not-for-production><fix-update-state-with-reducers>
<python>
Use Overwrite to replace state values instead of passing through reducers.from langgraph.types import Overwrite
# State with reducer: items: Annotated[list, operator.add]
# Current state: {"items": ["A", "B"]}
# update_state PASSES THROUGH reducers
graph.update_state(config, {"items": ["C"]}) # Result: ["A", "B", "C"] - Appended!
# To REPLACE instead, use Overwrite
graph.update_state(config, {"items": Overwrite(["C"])}) # Result: ["C"] - Replaced</python>
<typescript>
Use Overwrite to replace state values instead of passing through reducers.import { Overwrite } from "@langchain/langgraph";
// State with reducer: items uses concat reducer
// Current state: { items: ["A", "B"] }
// updateState PASSES THROUGH reducers
await graph.updateState(config, { items: ["C"] }); // Result: ["A", "B", "C"] - Appended!
// To REPLACE instead, use Overwrite
await graph.updateState(config, { items: new Overwrite(["C"]) }); // Result: ["C"] - Replaced</typescript>
</fix-update-state-with-reducers><fix-store-injection>
<python>
Access store via the Runtime object in graph nodes.# WRONG: Store not available in node
def my_node(state):
store.put(...) # NameError! store not defined
# CORRECT: Access store via runtime
from langgraph.runtime import Runtime
def my_node(state, runtime: Runtime):
runtime.store.put(...) # Correct store instance</python>
<typescript>
Access store via runtime parameter in graph nodes.// WRONG: Store not available in node
const myNode = async (state) => {
store.put(...); // ReferenceError!
};
// CORRECT: Access store via runtime
const myNode = async (state, runtime) => {
await runtime.store?.put(...); // Correct store instance
};</typescript>
</fix-store-injection><boundaries>
### What You Should NOT Do- Use
InMemorySaverin production — data lost on restart; usePostgresSaver - Forget
thread_id— state won't persist without it - Expect
update_stateto bypass reducers — it passes through them; useOverwriteto replace - Run the same stateful subgraph (
checkpointer=True) in parallel within one node — namespace conflict - Access store directly in a node — use
runtime.storevia theRuntimeparam</boundaries>
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

