mirror of
https://github.com/langchain-ai/langgraph.git
synced 2026-08-20 06:35:46 +02:00
806878a421
Bumps the all-dependencies group in /libs/checkpoint-postgres with 2 updates: [psycopg](https://github.com/psycopg/psycopg) and [ruff](https://github.com/astral-sh/ruff). Updates `psycopg` from 3.3.2 to 3.3.3 <details> <summary>Changelog</summary> <p><em>Sourced from <a href="https://github.com/psycopg/psycopg/blob/master/docs/news.rst">psycopg's changelog</a>.</em></p> <blockquote> <p>.. currentmodule:: psycopg</p> <p>.. index:: single: Release notes single: News</p> <h1><code>psycopg</code> release notes</h1> <h2>Current release</h2> <p>Psycopg 3.3.3 ^^^^^^^^^^^^^</p> <ul> <li>Retain <code>Error.pgconn</code> when raising a single exception for multiple connection attempt errors (🎫<code>[#1246](https://github.com/psycopg/psycopg/issues/1246)</code>).</li> <li>Return a proper error when server sends <code>ErrorResponse</code> for a <code>Sync</code> after a <code>Parse</code> (🎫<code>[#1260](https://github.com/psycopg/psycopg/issues/1260)</code>).</li> </ul> <p>Psycopg 3.3.2 ^^^^^^^^^^^^^</p> <p>Fix race condition in adapters at startup (🎫<code>[#1230](https://github.com/psycopg/psycopg/issues/1230)</code>).</p> <p>Psycopg 3.3.1 ^^^^^^^^^^^^^</p> <p>Fix iteration on server-side cursors (🎫<code>[#1226](https://github.com/psycopg/psycopg/issues/1226)</code>).</p> <h2>Psycopg 3.3.0</h2> <p>.. rubric:: New top-level features</p> <ul> <li>Add :ref:<code>template strings queries \<template-strings></code> (🎫<code>[#1054](https://github.com/psycopg/psycopg/issues/1054)</code>).</li> <li>More flexible :ref:<code>composite adaptation<adapt-composite></code>: it is now possible to adapt Python objects to PostgreSQL composites and back even if they are not sequences or if they take keyword arguments (🎫<code>[#932](https://github.com/psycopg/psycopg/issues/932)</code>, 🎫<code>[#1202](https://github.com/psycopg/psycopg/issues/1202)</code>).</li> <li>Cursors are now iterators_, not just iterables_. This means you can call <code>next</code>\ <code>(cur)</code> or <code>anext</code>\ <code>(cur)</code>, which is useful as a :ref:<code>type-safe expression <typing-fetchone></code> (🎫<code>[#1064](https://github.com/psycopg/psycopg/issues/1064)</code>).</li> <li>Add <code>Cursor.set_result()</code> and <code>Cursor.results()</code> to move across the result sets of queries executed though <code>~Cursor.executemany()</code> or <code>~Cursor.execute()</code> with multiple statements (🎟️<code>[#1080](https://github.com/psycopg/psycopg/issues/1080), [#1170](https://github.com/psycopg/psycopg/issues/1170)</code>).</li> <li>Add :ref:<code>transaction-status</code> to report the status during and after a <code>~Connection.transaction()</code> block (🎫<code>[#969](https://github.com/psycopg/psycopg/issues/969)</code>).</li> </ul> <!-- raw HTML omitted --> </blockquote> <p>... (truncated)</p> </details> <details> <summary>Commits</summary> <ul> <li><a href="https://github.com/psycopg/psycopg/commit/1a8f65a371da3c691111cd4a81141f2cb698eafa"><code>1a8f65a</code></a> chore: bump psycopg package version to 3.3.3</li> <li><a href="https://github.com/psycopg/psycopg/commit/db3c43584320ab5d97e49378e5c9dc09a560b031"><code>db3c435</code></a> Merge pull request <a href="https://redirect.github.com/psycopg/psycopg/issues/1260">#1260</a> from ggevay/sync-error-fix</li> <li><a href="https://github.com/psycopg/psycopg/commit/0237586c415ece15102742f5941874c29fb1221c"><code>0237586</code></a> Fix ValueError when server sends ErrorResponse during Sync after Parse</li> <li><a href="https://github.com/psycopg/psycopg/commit/cb97ef7063520cb8a0cb5236bb9791f8dc4cc454"><code>cb97ef7</code></a> docs: fix typos</li> <li><a href="https://github.com/psycopg/psycopg/commit/09c89180f94606dc70475ed863e135f021a11038"><code>09c8918</code></a> Merge pull request <a href="https://redirect.github.com/psycopg/psycopg/issues/1256">#1256</a> from veeceey/fix/tstrings-error-msg-and-docs-improve...</li> <li><a href="https://github.com/psycopg/psycopg/commit/9e74d9646cc3fcbb9d8940182dcdb41119c3fda7"><code>9e74d96</code></a> fix: fix error message incorrectly generated by Claude AI</li> <li><a href="https://github.com/psycopg/psycopg/commit/0db9d8bb76c48e70dffd48776406fd3ffdc89b5a"><code>0db9d8b</code></a> fix: correct typo in tstrings error message and fix sql.rst docs</li> <li><a href="https://github.com/psycopg/psycopg/commit/86a0e1b2bbf30c564c59bf3497d499e2f220ce0f"><code>86a0e1b</code></a> chore(deps): bump pypa/cibuildwheel in the actions group</li> <li><a href="https://github.com/psycopg/psycopg/commit/f5d90fa2a7836c1268c1d43d0d77c431434ad191"><code>f5d90fa</code></a> Merge pull request <a href="https://redirect.github.com/psycopg/psycopg/issues/1233">#1233</a> from lysnikolaou/pgconn-critical-section</li> <li><a href="https://github.com/psycopg/psycopg/commit/d7dc6c7cacc2832fffa0d7e607b5fc171424571d"><code>d7dc6c7</code></a> Merge critical section and nogil blocks into one context manager</li> <li>Additional commits viewable in <a href="https://github.com/psycopg/psycopg/compare/3.3.2...3.3.3">compare view</a></li> </ul> </details> <br /> Updates `ruff` from 0.15.1 to 0.15.2 <details> <summary>Release notes</summary> <p><em>Sourced from <a href="https://github.com/astral-sh/ruff/releases">ruff's releases</a>.</em></p> <blockquote> <h2>0.15.2</h2> <h2>Release Notes</h2> <p>Released on 2026-02-19.</p> <h3>Preview features</h3> <ul> <li> <p>Expand the default rule set (<a href="https://redirect.github.com/astral-sh/ruff/pull/23385">#23385</a>)</p> <p>In preview, Ruff now enables a significantly expanded default rule set of 412 rules, up from the stable default set of 59 rules. The new rules are mostly a superset of the stable defaults, with the exception of these rules, which are removed from the preview defaults:</p> <ul> <li><a href="https://docs.astral.sh/ruff/rules/multiple-imports-on-one-line"><code>multiple-imports-on-one-line</code></a> (<code>E401</code>)</li> <li><a href="https://docs.astral.sh/ruff/rules/module-import-not-at-top-of-file"><code>module-import-not-at-top-of-file</code></a> (<code>E402</code>)</li> <li><a href="https://docs.astral.sh/ruff/rules/module-import-not-at-top-of-file"><code>module-import-not-at-top-of-file</code></a> (<code>E701</code>)</li> <li><a href="https://docs.astral.sh/ruff/rules/multiple-statements-on-one-line-semicolon"><code>multiple-statements-on-one-line-semicolon</code></a> (<code>E702</code>)</li> <li><a href="https://docs.astral.sh/ruff/rules/useless-semicolon"><code>useless-semicolon</code></a> (<code>E703</code>)</li> <li><a href="https://docs.astral.sh/ruff/rules/none-comparison"><code>none-comparison</code></a> (<code>E711</code>)</li> <li><a href="https://docs.astral.sh/ruff/rules/true-false-comparison"><code>true-false-comparison</code></a> (<code>E712</code>)</li> <li><a href="https://docs.astral.sh/ruff/rules/not-in-test"><code>not-in-test</code></a> (<code>E713</code>)</li> <li><a href="https://docs.astral.sh/ruff/rules/not-is-test"><code>not-is-test</code></a> (<code>E714</code>)</li> <li><a href="https://docs.astral.sh/ruff/rules/type-comparison"><code>type-comparison</code></a> (<code>E721</code>)</li> <li><a href="https://docs.astral.sh/ruff/rules/lambda-assignment"><code>lambda-assignment</code></a> (<code>E731</code>)</li> <li><a href="https://docs.astral.sh/ruff/rules/ambiguous-variable-name"><code>ambiguous-variable-name</code></a> (<code>E741</code>)</li> <li><a href="https://docs.astral.sh/ruff/rules/ambiguous-class-name"><code>ambiguous-class-name</code></a> (<code>E742</code>)</li> <li><a href="https://docs.astral.sh/ruff/rules/ambiguous-function-name"><code>ambiguous-function-name</code></a> (<code>E743</code>)</li> <li><a href="https://docs.astral.sh/ruff/rules/undefined-local-with-import-star"><code>undefined-local-with-import-star</code></a> (<code>F403</code>)</li> <li><a href="https://docs.astral.sh/ruff/rules/undefined-local-with-import-star-usage"><code>undefined-local-with-import-star-usage</code></a> (<code>F405</code>)</li> <li><a href="https://docs.astral.sh/ruff/rules/undefined-local-with-nested-import-star-usage"><code>undefined-local-with-nested-import-star-usage</code></a> (<code>F406</code>)</li> <li><a href="https://docs.astral.sh/ruff/rules/forward-annotation-syntax-error"><code>forward-annotation-syntax-error</code></a> (<code>F722</code>)</li> </ul> <p>If you use preview and prefer the old defaults, you can restore them with configuration like:</p> <pre lang="toml"><code> # ruff.toml <p>[lint] select = ["E4", "E7", "E9", "F"]</p> <h1>pyproject.toml</h1> <p>[tool.ruff.lint] select = ["E4", "E7", "E9", "F"] </code></pre></p> <p>If you do give them a try, feel free to share your feedback in the <a href="https://github.com/astral-sh/ruff/discussions/23203">GitHub discussion</a>!</p> </li> <li> <p>[<code>flake8-pyi</code>] Also check string annotations (<code>PYI041</code>) (<a href="https://redirect.github.com/astral-sh/ruff/pull/19023">#19023</a>)</p> </li> </ul> <h3>Bug fixes</h3> <!-- raw HTML omitted --> </blockquote> <p>... (truncated)</p> </details> <details> <summary>Changelog</summary> <p><em>Sourced from <a href="https://github.com/astral-sh/ruff/blob/main/CHANGELOG.md">ruff's changelog</a>.</em></p> <blockquote> <h2>0.15.2</h2> <p>Released on 2026-02-19.</p> <h3>Preview features</h3> <ul> <li> <p>Expand the default rule set (<a href="https://redirect.github.com/astral-sh/ruff/pull/23385">#23385</a>)</p> <p>In preview, Ruff now enables a significantly expanded default rule set of 412 rules, up from the stable default set of 59 rules. The new rules are mostly a superset of the stable defaults, with the exception of these rules, which are removed from the preview defaults:</p> <ul> <li><a href="https://docs.astral.sh/ruff/rules/multiple-imports-on-one-line"><code>multiple-imports-on-one-line</code></a> (<code>E401</code>)</li> <li><a href="https://docs.astral.sh/ruff/rules/module-import-not-at-top-of-file"><code>module-import-not-at-top-of-file</code></a> (<code>E402</code>)</li> <li><a href="https://docs.astral.sh/ruff/rules/module-import-not-at-top-of-file"><code>module-import-not-at-top-of-file</code></a> (<code>E701</code>)</li> <li><a href="https://docs.astral.sh/ruff/rules/multiple-statements-on-one-line-semicolon"><code>multiple-statements-on-one-line-semicolon</code></a> (<code>E702</code>)</li> <li><a href="https://docs.astral.sh/ruff/rules/useless-semicolon"><code>useless-semicolon</code></a> (<code>E703</code>)</li> <li><a href="https://docs.astral.sh/ruff/rules/none-comparison"><code>none-comparison</code></a> (<code>E711</code>)</li> <li><a href="https://docs.astral.sh/ruff/rules/true-false-comparison"><code>true-false-comparison</code></a> (<code>E712</code>)</li> <li><a href="https://docs.astral.sh/ruff/rules/not-in-test"><code>not-in-test</code></a> (<code>E713</code>)</li> <li><a href="https://docs.astral.sh/ruff/rules/not-is-test"><code>not-is-test</code></a> (<code>E714</code>)</li> <li><a href="https://docs.astral.sh/ruff/rules/type-comparison"><code>type-comparison</code></a> (<code>E721</code>)</li> <li><a href="https://docs.astral.sh/ruff/rules/lambda-assignment"><code>lambda-assignment</code></a> (<code>E731</code>)</li> <li><a href="https://docs.astral.sh/ruff/rules/ambiguous-variable-name"><code>ambiguous-variable-name</code></a> (<code>E741</code>)</li> <li><a href="https://docs.astral.sh/ruff/rules/ambiguous-class-name"><code>ambiguous-class-name</code></a> (<code>E742</code>)</li> <li><a href="https://docs.astral.sh/ruff/rules/ambiguous-function-name"><code>ambiguous-function-name</code></a> (<code>E743</code>)</li> <li><a href="https://docs.astral.sh/ruff/rules/undefined-local-with-import-star"><code>undefined-local-with-import-star</code></a> (<code>F403</code>)</li> <li><a href="https://docs.astral.sh/ruff/rules/undefined-local-with-import-star-usage"><code>undefined-local-with-import-star-usage</code></a> (<code>F405</code>)</li> <li><a href="https://docs.astral.sh/ruff/rules/undefined-local-with-nested-import-star-usage"><code>undefined-local-with-nested-import-star-usage</code></a> (<code>F406</code>)</li> <li><a href="https://docs.astral.sh/ruff/rules/forward-annotation-syntax-error"><code>forward-annotation-syntax-error</code></a> (<code>F722</code>)</li> </ul> <p>If you use preview and prefer the old defaults, you can restore them with configuration like:</p> <pre lang="toml"><code> # ruff.toml <p>[lint] select = ["E4", "E7", "E9", "F"]</p> <h1>pyproject.toml</h1> <p>[tool.ruff.lint] select = ["E4", "E7", "E9", "F"] </code></pre></p> <p>If you do give them a try, feel free to share your feedback in the <a href="https://github.com/astral-sh/ruff/discussions/23203">GitHub discussion</a>!</p> </li> </ul> <!-- raw HTML omitted --> </blockquote> <p>... (truncated)</p> </details> <details> <summary>Commits</summary> <ul> <li><a href="https://github.com/astral-sh/ruff/commit/9d18ee9115f9cbb4c21478baa7c1fa2b46e0759c"><code>9d18ee9</code></a> Hard code workflow name and <code>cancel-in-progress</code> only for PRs (<a href="https://redirect.github.com/astral-sh/ruff/issues/23431">#23431</a>)</li> <li><a href="https://github.com/astral-sh/ruff/commit/7cc15f024b931fe56365f40de3fab01219c092c4"><code>7cc15f0</code></a> Bump 0.15.2 (<a href="https://redirect.github.com/astral-sh/ruff/issues/23430">#23430</a>)</li> <li><a href="https://github.com/astral-sh/ruff/commit/d1b544393ae9cddd8e48ebee8dbfd54bda89f375"><code>d1b5443</code></a> Add extension mapping to configuration file options (<a href="https://redirect.github.com/astral-sh/ruff/issues/23384">#23384</a>)</li> <li><a href="https://github.com/astral-sh/ruff/commit/222574af90c5c0ca8f84c8385cf30c7c10ac2496"><code>222574a</code></a> Expand the default rule set (<a href="https://redirect.github.com/astral-sh/ruff/issues/23385">#23385</a>)</li> <li><a href="https://github.com/astral-sh/ruff/commit/1465b5de3829549b45397e9587b83ab7ac6d26d0"><code>1465b5d</code></a> [<code>flake8-async</code>] Fix <code>in_async_context</code> logic (<a href="https://redirect.github.com/astral-sh/ruff/issues/23426">#23426</a>)</li> <li><a href="https://github.com/astral-sh/ruff/commit/410902fa401afda969cc000f13be341896e6868e"><code>410902f</code></a> [<code>pyupgrade</code>] Fix handling of <code>typing.{io,re}</code> (<code>UP035</code>) (<a href="https://redirect.github.com/astral-sh/ruff/issues/23131">#23131</a>)</li> <li><a href="https://github.com/astral-sh/ruff/commit/729610acd9e19f57526e8ca40f355626154826bb"><code>729610a</code></a> [ty] Fall back to ambiguous for large control flow graphs (<a href="https://redirect.github.com/astral-sh/ruff/issues/23399">#23399</a>)</li> <li><a href="https://github.com/astral-sh/ruff/commit/1425c185b0a47be87112762f65b5bf7e323fb950"><code>1425c18</code></a> [ty] Add code folding support</li> <li><a href="https://github.com/astral-sh/ruff/commit/97acaaea5f993f33d3f5bb27c5db760a2f3d1e8a"><code>97acaae</code></a> [ty] Fix stack overflow for self-referential <code>TypeOf</code> in annotations (<a href="https://redirect.github.com/astral-sh/ruff/issues/23407">#23407</a>)</li> <li><a href="https://github.com/astral-sh/ruff/commit/1f380c82584a6dab7e8715bc7dd5ae187da1e69a"><code>1f380c8</code></a> [ty] Update tests <code>reveal_type</code> and <code>Never</code> (<a href="https://redirect.github.com/astral-sh/ruff/issues/23418">#23418</a>)</li> <li>Additional commits viewable in <a href="https://github.com/astral-sh/ruff/compare/0.15.1...0.15.2">compare view</a></li> </ul> </details> <br /> 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>
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
PostgresSaverorAsyncPostgresSaver, make sure to includeautocommit=Trueandrow_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 defaulttuple_rowfactory returns tuples that only support index-based access (e.g.,row[0]), which will causeTypeErrorexceptions 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)]