Files
langgraph/libs/checkpoint-postgres
dependabot[bot]GitHubdependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
e243a8fb61 chore(deps): bump anyio from 4.12.1 to 4.13.0 in /libs/checkpoint-postgres in the minor-and-patch group (#7288)
Bumps the minor-and-patch group in /libs/checkpoint-postgres with 1
update: [anyio](https://github.com/agronholm/anyio).

Updates `anyio` from 4.12.1 to 4.13.0
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a
href="https://github.com/agronholm/anyio/releases">anyio's
releases</a>.</em></p>
<blockquote>
<h2>4.13.0</h2>
<ul>
<li>Dropped support for Python 3.9</li>
<li>Added a <code>ttl</code> parameter to the
<code>anyio.functools.lru_cache</code> wrapper (<a
href="https://redirect.github.com/agronholm/anyio/pull/1073">#1073</a>;
PR by <a
href="https://github.com/Graeme22"><code>@​Graeme22</code></a>)</li>
<li>Widened the type annotations of file I/O streams to accept
<code>IO[bytes]</code> instead of just <code>BinaryIO</code> (<a
href="https://redirect.github.com/agronholm/anyio/issues/1078">#1078</a>)</li>
<li>Fixed <code>anyio.Path</code> not being compatible with Python 3.15
due to the removal of <code>pathlib.Path.is_reserved()</code> and the
addition of <code>pathlib.Path.__vfspath__()</code> (<a
href="https://redirect.github.com/agronholm/anyio/issues/1061">#1061</a>;
PR by <a
href="https://github.com/veeceey"><code>@​veeceey</code></a>)</li>
<li>Fixed the <code>BrokenResourceError</code> raised by the asyncio
<code>SocketStream</code> not having the original exception as its cause
(<a
href="https://redirect.github.com/agronholm/anyio/issues/1055">#1055</a>;
PR by <a
href="https://github.com/veeceey"><code>@​veeceey</code></a>)</li>
<li>Fixed the <code>TypeError</code> raised when using &quot;func&quot;
as a parameter name in <code>pytest.mark.parametrize</code> when using
the pytest plugin (<a
href="https://redirect.github.com/agronholm/anyio/pull/1068">#1068</a>;
PR by <a
href="https://github.com/JohnnyDeuss"><code>@​JohnnyDeuss</code></a>)</li>
<li>Fixed the pytest plugin not running tests that had the
<code>anyio</code> marker added programmatically via
<code>pytest_collection_modifyitems</code> (<a
href="https://redirect.github.com/agronholm/anyio/issues/422">#422</a>;
PR by <a
href="https://github.com/chbndrhnns"><code>@​chbndrhnns</code></a>)</li>
<li>Fixed cancellation exceptions leaking from a
<code>CancelScope</code> on asyncio when they are contained in an
exception group alongside non-cancellation exceptions (<a
href="https://redirect.github.com/agronholm/anyio/issues/1091">#1091</a>;
PR by <a
href="https://github.com/gschaffner"><code>@​gschaffner</code></a>)</li>
<li>Fixed <code>Condition.wait()</code> not passing on a notification
when the task is cancelled but already received a notification</li>
<li>Fixed inverted condition in the process pool shutdown phase which
would cause still-running pooled processes not to be terminated (<a
href="https://redirect.github.com/agronholm/anyio/pull/1074">#1074</a>;
PR by <a
href="https://github.com/bysiber"><code>@​bysiber</code></a>)</li>
</ul>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a
href="https://github.com/agronholm/anyio/commit/afbe93ca9d0c447adf26e9c1715ac20870622bf2"><code>afbe93c</code></a>
Bumped up the version</li>
<li><a
href="https://github.com/agronholm/anyio/commit/33bdf2e4b4f40c2df178123746147a6d2471808d"><code>33bdf2e</code></a>
Rearranged the changelog entries</li>
<li><a
href="https://github.com/agronholm/anyio/commit/19e09e25bc5a23dd78a577d8c3909dd377057c78"><code>19e09e2</code></a>
Fixed inverted condition in _forcibly_shutdown_process_pool_on_exit (<a
href="https://redirect.github.com/agronholm/anyio/issues/1074">#1074</a>)</li>
<li><a
href="https://github.com/agronholm/anyio/commit/9369d80b9e8292f2a892a9d5c73923c6a28aa08c"><code>9369d80</code></a>
Fixed Condition.wait() not handing over notification when cancelled</li>
<li><a
href="https://github.com/agronholm/anyio/commit/6f122abdc6f6b166c6b6ac27d36d55cdf8fa08e8"><code>6f122ab</code></a>
Fixed cancellation exceptions leaking from a <code>CancelScope</code> on
asyncio when th...</li>
<li><a
href="https://github.com/agronholm/anyio/commit/beaa45aff568a4020f2faf317321dd92f0e1f4a0"><code>beaa45a</code></a>
[pre-commit.ci] pre-commit autoupdate (<a
href="https://redirect.github.com/agronholm/anyio/issues/1097">#1097</a>)</li>
<li><a
href="https://github.com/agronholm/anyio/commit/602f6606dcf3f37702686a4f3e161328c537b07f"><code>602f660</code></a>
Widened type annotations to accept IO[bytes] in file streams</li>
<li><a
href="https://github.com/agronholm/anyio/commit/b5dcd45170701a756ba634197398f05d4710cab3"><code>b5dcd45</code></a>
Added note about erasing the template</li>
<li><a
href="https://github.com/agronholm/anyio/commit/d68670b3b4e0917d4caff2de082e03220f3e05a1"><code>d68670b</code></a>
[pre-commit.ci] pre-commit autoupdate (<a
href="https://redirect.github.com/agronholm/anyio/issues/1090">#1090</a>)</li>
<li><a
href="https://github.com/agronholm/anyio/commit/fc17a22dd948e6a3d90d99908813f0010dfc3d2c"><code>fc17a22</code></a>
tweak to_thread docs about abandon_on_cancel (<a
href="https://redirect.github.com/agronholm/anyio/issues/1088">#1088</a>)</li>
<li>Additional commits viewable in <a
href="https://github.com/agronholm/anyio/compare/4.12.1...4.13.0">compare
view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=anyio&package-manager=uv&previous-version=4.12.1&new-version=4.13.0)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't
alter it yourself. You can also trigger a rebase manually by commenting
`@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits
that have been made to it
- `@dependabot show <dependency name> ignore conditions` will show all
of the ignore conditions of the specified dependency
- `@dependabot ignore <dependency name> major version` will close this
group update PR and stop Dependabot creating any more for the specific
dependency's major version (unless you unignore this specific
dependency's major version or upgrade to it yourself)
- `@dependabot ignore <dependency name> minor version` will close this
group update PR and stop Dependabot creating any more for the specific
dependency's minor version (unless you unignore this specific
dependency's minor version or upgrade to it yourself)
- `@dependabot ignore <dependency name>` will close this group update PR
and stop Dependabot creating any more for the specific dependency
(unless you unignore this specific dependency or upgrade to it yourself)
- `@dependabot unignore <dependency name>` will remove all of the ignore
conditions of the specified dependency
- `@dependabot unignore <dependency name> <ignore condition>` will
remove the ignore condition of the specified dependency and ignore
conditions


</details>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-03-25 11:39:23 -07:00
..
2026-03-18 13:31:46 -07:00
2026-03-18 13:31:46 -07:00

LangGraph Checkpoint Postgres

Implementation of LangGraph CheckpointSaver that uses Postgres.

Dependencies

By default langgraph-checkpoint-postgres installs psycopg (Psycopg 3) without any extras. However, you can choose a specific installation that best suits your needs here (for example, psycopg[binary]).

Usage

Important

When using Postgres checkpointers for the first time, make sure to call .setup() method on them to create required tables. See example below.

Important

When manually creating Postgres connections and passing them to PostgresSaver or AsyncPostgresSaver, make sure to include autocommit=True and row_factory=dict_row (from psycopg.rows import dict_row). See a full example in this how-to guide.

Why these parameters are required:

  • autocommit=True: Required for the .setup() method to properly commit the checkpoint tables to the database. Without this, table creation may not be persisted.
  • row_factory=dict_row: Required because the PostgresSaver implementation accesses database rows using dictionary-style syntax (e.g., row["column_name"]). The default tuple_row factory returns tuples that only support index-based access (e.g., row[0]), which will cause TypeError exceptions when the checkpointer tries to access columns by name.

Example of incorrect usage:

# ❌ This will fail with TypeError during checkpointer operations
with psycopg.connect(DB_URI) as conn:  # Missing autocommit=True and row_factory=dict_row
    checkpointer = PostgresSaver(conn)
    checkpointer.setup()  # May not persist tables properly
    # Any operation that reads from database will fail with:
    # TypeError: tuple indices must be integers or slices, not str
from langgraph.checkpoint.postgres import PostgresSaver

write_config = {"configurable": {"thread_id": "1", "checkpoint_ns": ""}}
read_config = {"configurable": {"thread_id": "1"}}

DB_URI = "postgres://postgres:postgres@localhost:5432/postgres?sslmode=disable"
with PostgresSaver.from_conn_string(DB_URI) as checkpointer:
    # call .setup() the first time you're using the checkpointer
    checkpointer.setup()
    checkpoint = {
        "v": 4,
        "ts": "2024-07-31T20:14:19.804150+00:00",
        "id": "1ef4f797-8335-6428-8001-8a1503f9b875",
        "channel_values": {
            "my_key": "meow",
            "node": "node"
        },
        "channel_versions": {
            "__start__": 2,
            "my_key": 3,
            "start:node": 3,
            "node": 3
        },
        "versions_seen": {
            "__input__": {},
            "__start__": {
            "__start__": 1
            },
            "node": {
            "start:node": 2
            }
        },
    }

    # store checkpoint
    checkpointer.put(write_config, checkpoint, {}, {})

    # load checkpoint
    checkpointer.get(read_config)

    # list checkpoints
    list(checkpointer.list(read_config))

Async

from langgraph.checkpoint.postgres.aio import AsyncPostgresSaver

async with AsyncPostgresSaver.from_conn_string(DB_URI) as checkpointer:
    checkpoint = {
        "v": 4,
        "ts": "2024-07-31T20:14:19.804150+00:00",
        "id": "1ef4f797-8335-6428-8001-8a1503f9b875",
        "channel_values": {
            "my_key": "meow",
            "node": "node"
        },
        "channel_versions": {
            "__start__": 2,
            "my_key": 3,
            "start:node": 3,
            "node": 3
        },
        "versions_seen": {
            "__input__": {},
            "__start__": {
            "__start__": 1
            },
            "node": {
            "start:node": 2
            }
        },
    }

    # store checkpoint
    await checkpointer.aput(write_config, checkpoint, {}, {})

    # load checkpoint
    await checkpointer.aget(read_config)

    # list checkpoints
    [c async for c in checkpointer.alist(read_config)]