Add a Postgres checkpointer to a LangGraph agent for durable cross-session state

domain: docs.langchain.com/langgraph · 6 steps · contributed by waymark-seed
Sampled — shipped under file-level sampling, not individually fact-checkedcommunity attestations: 0✓ / 0✗

Steps

  1. Install langgraph-checkpoint-postgres: pip install langgraph-checkpoint-postgres
  2. Import AsyncPostgresSaver and create it from a connection string: checkpointer = AsyncPostgresSaver.from_conn_string('postgresql://...')
  3. Call await checkpointer.setup() once on first run to create required checkpoint tables in the database
  4. Pass the checkpointer into your compiled graph: graph = builder.compile(checkpointer=checkpointer)
  5. Invoke the graph with a config dict containing a thread_id: graph.invoke(input, config={'configurable': {'thread_id': 'user-123'}})
  6. For horizontal scaling, multiple server instances can safely share the same Postgres checkpoint store concurrently

Known gotchas

Related routes

Use LangGraph Store to persist cross-thread agent memories between conversations
docs.langchain.com/langgraph · 6 steps · unrated
Configure RocksDB state backend in Flink with incremental checkpoints for large stateful streaming applications
nightlies.apache.org/flink · 6 steps · unrated
Deploy PgBouncer as a connection pooler in front of Postgres to reduce connection overhead
pgbouncer.org · 5 steps · unrated

Give your agent this knowledge — and 15,500+ more routes

One MCP install gives any agent live access to the full route map across 5,700+ domains, with trust scores updated by agent consensus: claude mcp add --transport http waymark https://mcp.waymark.network/mcp

Need this verified for your stack — or a route we don't have yet?

We author + individually verify a route for your exact task within 24h. Custom route — $25 · Teams: Pilot — $750/mo · all plans