技能创建器
skill-creator
创建、改进和评估自定义技能,把专业流程转化为可重复使用的 AI 能力。
persistence【数据与研究】Choose and wire LangGraph persistence: checkpoint savers, stores, thread config, SQLite/Postgres backends, and safe serde settings.
独立 GitHub 快照 · 自动分类 · 以原作者文档为准
Use this sub-skill when a task asks an agent to persist LangGraph state, resume a graph thread, choose a checkpoint backend, add long-term memory, debug checkpoint configuration, or harden checkpoint serialization.
invoke, stream, batch, ainvoke, or astream calls.thread_id config.checkpoint_id, checkpoint_ns, pending writes, or time travel.InMemoryStore or semantic memory search.PostgresSaver, SqliteSaver, async saver imports, psycopg row factories, missing setup, or msgpack deserialization warnings.For graph compilation and runtime invocation patterns, pair this with graph-runtime. For agent templates and tool-calling agents that need memory, pair with prebuilt-agents. For deployment-managed checkpointers, pair with the cli-deployment sibling sub-skill when present. For hosted thread APIs, pair with the sdk-clients sibling sub-skill when present.
builder.compile(checkpointer=...).builder.compile(store=...) when graph nodes access a store.InMemorySaver from langgraph.checkpoint.memory for debugging and tests only.SqliteSaver from langgraph.checkpoint.sqlite for lightweight local sync persistence.AsyncSqliteSaver from langgraph.checkpoint.sqlite.aio for async SQLite graph execution.PostgresSaver from langgraph.checkpoint.postgres for durable sync production persistence.AsyncPostgresSaver from langgraph.checkpoint.postgres.aio for async production persistence.{"configurable": {"thread_id": "user-or-session-id"}}."checkpoint_id": "..."."checkpoint_ns": "..." when isolating checkpoint streams inside one thread.LANGGRAPH_STRICT_MSGPACK=true in the runtime environment.JsonPlusSerializer(allowed_msgpack_modules=[("package.module", "ClassName")]) to the saver.thread_id before changing application logic.from langgraph.checkpoint.memory import InMemorySaver
checkpointer = InMemorySaver()
graph = builder.compile(checkpointer=checkpointer)
config = {"configurable": {"thread_id": "debug-thread"}}
result = graph.invoke(input_state, config)
InMemorySaver(*, serde=None, factory=defaultdict) stores checkpoints in process memory. Do not recommend it for production because data is lost when the process exits.
from langgraph.checkpoint.sqlite import SqliteSaver
with SqliteSaver.from_conn_string("checkpoints.sqlite") as checkpointer:
graph = builder.compile(checkpointer=checkpointer)
graph.invoke(input_state, {"configurable": {"thread_id": "local-user-1"}})
Use sync SqliteSaver only with sync graph methods. For ainvoke, astream, or async apps, import AsyncSqliteSaver from langgraph.checkpoint.sqlite.aio; it requires aiosqlite.
from langgraph.checkpoint.postgres import PostgresSaver
with PostgresSaver.from_conn_string(DB_URI) as checkpointer:
checkpointer.setup()
graph = builder.compile(checkpointer=checkpointer)
graph.invoke(input_state, {"configurable": {"thread_id": "customer-123"}})
Call setup() the first time a Postgres checkpoint database is used so migrations and checkpoint tables exist. For manual psycopg connections, use autocommit=True and row_factory=dict_row.
from langgraph.store.memory import InMemoryStore
store = InMemoryStore()
store.put(("users", "123"), "prefs", {"theme": "dark"})
item = store.get(("users", "123"), "prefs")
InMemoryStore(*, index=None) supports namespaced key-value storage and optional semantic search. It is in-memory and process-local; use it for tests, demos, and memory logic development before selecting a durable store backend.
InMemoryStore namespaces, filters, optional vector search, and async methods.InMemorySaver, thread config, and checkpoint listing.python skills/langgraph/sub-skills/persistence/scripts/smoke_memory_checkpoint.py --help to confirm the bundled script is discoverable.python skills/langgraph/sub-skills/persistence/scripts/smoke_memory_checkpoint.py in an environment with langgraph installed.thread_id when continuity is expected.langgraph-checkpoint-sqlite installed and async SQLite apps also have aiosqlite.langgraph-checkpoint-postgres, psycopg connectivity, setup(), and correct row factory settings.InMemorySaver or InMemoryStore as durable production persistence.thread_id when compiling with a checkpointer.autocommit=True and row_factory=dict_row.