Quickstart
Install
pip install "open-postgres-checkpointer[binary]"
# or
uv add "open-postgres-checkpointer[binary]"
[binary] installs psycopg's bundled libpq. If the machine already has PostgreSQL's libpq
installed, you can install bare open-postgres-checkpointer (or [c] for psycopg's C extension);
importing the saver with no libpq available fails with ImportError: no pq wrapper available.
To install the current source instead:
uv add "open-postgres-checkpointer @ git+https://github.com/davidallada/open-postgres-checkpointer"
Basic usage
On a database upstream's saver already uses, read Adopting the saver first: once patches are on, upstream's saver cannot read the threads this one writes.
from open_postgres_checkpointer import AsyncOpenPostgresCheckpointer
async with AsyncOpenPostgresCheckpointer.from_conn_string(DB_URI) as saver:
await saver.setup() # once, from one process
graph = builder.compile(checkpointer=saver)
await graph.ainvoke(inputs, {"configurable": {"thread_id": "t1"}})
Code with no event loop of its own uses the sync saver, OpenPostgresCheckpointer, the same way
with with and graph.invoke.
List threads
alist_threads pages through threads newest first by their latest root checkpoint, filtered
on its metadata; see its API entry for what the filter matches:
from open_postgres_checkpointer import alist_threads
page = [t async for t in alist_threads(saver, filter={"user_id": "u1"}, limit=20)]
more = [t async for t in alist_threads(saver, filter={"user_id": "u1"}, before=page[-1].config, limit=20)]
Develop
just install # uv sync + git hooks
just test # unit tests
just lint && just typecheck
See CONTRIBUTING.md for the full workflow.