mirror of
https://github.com/langchain-ai/langgraph.git
synced 2026-08-25 09:02:25 +02:00
8c0e498eaf
Bumps the minor-and-patch group with 3 updates in the /libs/prebuilt directory: [psycopg-binary](https://github.com/psycopg/psycopg), [ruff](https://github.com/astral-sh/ruff) and [mypy](https://github.com/python/mypy). Updates `psycopg-binary` from 3.3.3 to 3.3.4 <details> <summary>Changelog</summary> <p><em>Sourced from <a href="https://github.com/psycopg/psycopg/blob/master/docs/news.rst">psycopg-binary'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.4 ^^^^^^^^^^^^^</p> <ul> <li>Fix possible spurious connection timeout in systems with very long uptimes in C extension (🎫<code>[#1280](https://github.com/psycopg/psycopg/issues/1280)</code>).</li> <li>Fix client-side adaptation of enums whose name require quotes (🎫<code>[#1298](https://github.com/psycopg/psycopg/issues/1298)</code>).</li> <li>Consistently populate <code>~Cursor.statusmessage</code> after <code>~Cursor.executemany()</code> (🎫<code>[#1302](https://github.com/psycopg/psycopg/issues/1302)</code>).</li> </ul> <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> </ul> <!-- raw HTML omitted --> </blockquote> <p>... (truncated)</p> </details> <details> <summary>Commits</summary> <ul> <li><a href="https://github.com/psycopg/psycopg/commit/83f110367cdd249cc0a352e2246ecea9e878e5a0"><code>83f1103</code></a> chore: bump psycopg_pool package version to 3.3.1</li> <li><a href="https://github.com/psycopg/psycopg/commit/18287707f56a2b4f0817d9c23d137f5d69db6e31"><code>1828770</code></a> chore: bump psycopg package version to 3.3.4</li> <li><a href="https://github.com/psycopg/psycopg/commit/8be14bbc18f74de7652606d2777e0950ec804cc0"><code>8be14bb</code></a> Merge pull request <a href="https://redirect.github.com/psycopg/psycopg/issues/1301">#1301</a> from oliverhaas/fix/sync-pool-open-race</li> <li><a href="https://github.com/psycopg/psycopg/commit/aee0bf2659db77c31154acf583baf0a98675c192"><code>aee0bf2</code></a> fix(pool): fix race in the construction of the sync ConnectionPool lock</li> <li><a href="https://github.com/psycopg/psycopg/commit/bc4d30375557fc32f2a91c2f8b75a5d21711ea89"><code>bc4d303</code></a> chore(deps): bump the actions group across 1 directory with 4 updates</li> <li><a href="https://github.com/psycopg/psycopg/commit/785379f196fc17473d312451a1fd4a06ef8dc895"><code>785379f</code></a> fix: retain statusmessage after executemany with returning=False</li> <li><a href="https://github.com/psycopg/psycopg/commit/8882a73871e65727549657085922d043a106127c"><code>8882a73</code></a> perf: do less if X in Y: return Y[X] for cache-like patterns</li> <li><a href="https://github.com/psycopg/psycopg/commit/2f785395c189e709da5fa74a02d3797bfb9db6a4"><code>2f78539</code></a> Merge pull request <a href="https://redirect.github.com/psycopg/psycopg/issues/1299">#1299</a> from dvarrazzo/fix-camel-enum</li> <li><a href="https://github.com/psycopg/psycopg/commit/37ef1dc4e6d19dc4af062d45a63243cb96a261c2"><code>37ef1dc</code></a> test: skip test on crdb depending on precise regtype behaviour</li> <li><a href="https://github.com/psycopg/psycopg/commit/7f2f1d159df881260e3086fd61ea71343ca98e58"><code>7f2f1d1</code></a> fix: fix client-side representation of enums requiring quotes</li> <li>Additional commits viewable in <a href="https://github.com/psycopg/psycopg/compare/3.3.3...3.3.4">compare view</a></li> </ul> </details> <br /> Updates `ruff` from 0.15.9 to 0.15.12 <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.12</h2> <h2>Release Notes</h2> <p>Released on 2026-04-24.</p> <h3>Preview features</h3> <ul> <li>Implement <code>#ruff:file-ignore</code> file-level suppressions (<a href="https://redirect.github.com/astral-sh/ruff/pull/23599">#23599</a>)</li> <li>Implement <code>#ruff:ignore</code> logical-line suppressions (<a href="https://redirect.github.com/astral-sh/ruff/pull/23404">#23404</a>)</li> <li>Revert preview changes to displayed diagnostic severity in LSP (<a href="https://redirect.github.com/astral-sh/ruff/pull/24789">#24789</a>)</li> <li>[<code>airflow</code>] Implement <code>task-branch-as-short-circuit</code> (<code>AIR004</code>) (<a href="https://redirect.github.com/astral-sh/ruff/pull/23579">#23579</a>)</li> <li>[<code>flake8-bugbear</code>] Fix <code>break</code>/<code>continue</code> handling in <code>loop-iterator-mutation</code> (<code>B909</code>) (<a href="https://redirect.github.com/astral-sh/ruff/pull/24440">#24440</a>)</li> <li>[<code>pylint</code>] Fix <code>PLC2701</code> for type parameter scopes (<a href="https://redirect.github.com/astral-sh/ruff/pull/24576">#24576</a>)</li> </ul> <h3>Rule changes</h3> <ul> <li>[<code>pandas-vet</code>] Suggest <code>.array</code> as well in <code>PD011</code> (<a href="https://redirect.github.com/astral-sh/ruff/pull/24805">#24805</a>)</li> </ul> <h3>CLI</h3> <ul> <li>Respect default Unix permissions for cache files (<a href="https://redirect.github.com/astral-sh/ruff/pull/24794">#24794</a>)</li> </ul> <h3>Documentation</h3> <ul> <li>[<code>pylint</code>] Fix <code>PLR0124</code> description not to claim self-comparison always returns the same value (<a href="https://redirect.github.com/astral-sh/ruff/pull/24749">#24749</a>)</li> <li>[<code>pyupgrade</code>] Expand docs on reusable <code>TypeVar</code>s and scoping (<code>UP046</code>) (<a href="https://redirect.github.com/astral-sh/ruff/pull/24153">#24153</a>)</li> <li>Improve rules table accessibility (<a href="https://redirect.github.com/astral-sh/ruff/pull/24711">#24711</a>)</li> </ul> <h3>Contributors</h3> <ul> <li><a href="https://github.com/dylwil3"><code>@dylwil3</code></a></li> <li><a href="https://github.com/AlexWaygood"><code>@AlexWaygood</code></a></li> <li><a href="https://github.com/woodruffw"><code>@woodruffw</code></a></li> <li><a href="https://github.com/avasis-ai"><code>@avasis-ai</code></a></li> <li><a href="https://github.com/Dev-iL"><code>@Dev-iL</code></a></li> <li><a href="https://github.com/denyszhak"><code>@denyszhak</code></a></li> <li><a href="https://github.com/ShipItAndPray"><code>@ShipItAndPray</code></a></li> <li><a href="https://github.com/anishgirianish"><code>@anishgirianish</code></a></li> <li><a href="https://github.com/augustelalande"><code>@augustelalande</code></a></li> <li><a href="https://github.com/amyreese"><code>@amyreese</code></a></li> <li><a href="https://github.com/majiayu000"><code>@majiayu000</code></a></li> </ul> <h2>Install ruff 0.15.12</h2> <h3>Install prebuilt binaries via shell script</h3> <pre lang="sh"><code>curl --proto '=https' --tlsv1.2 -LsSf https://releases.astral.sh/github/ruff/releases/download/0.15.12/ruff-installer.sh | sh </code></pre> <!-- 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.12</h2> <p>Released on 2026-04-24.</p> <h3>Preview features</h3> <ul> <li>Implement <code>#ruff:file-ignore</code> file-level suppressions (<a href="https://redirect.github.com/astral-sh/ruff/pull/23599">#23599</a>)</li> <li>Implement <code>#ruff:ignore</code> logical-line suppressions (<a href="https://redirect.github.com/astral-sh/ruff/pull/23404">#23404</a>)</li> <li>Revert preview changes to displayed diagnostic severity in LSP (<a href="https://redirect.github.com/astral-sh/ruff/pull/24789">#24789</a>)</li> <li>[<code>airflow</code>] Implement <code>task-branch-as-short-circuit</code> (<code>AIR004</code>) (<a href="https://redirect.github.com/astral-sh/ruff/pull/23579">#23579</a>)</li> <li>[<code>flake8-bugbear</code>] Fix <code>break</code>/<code>continue</code> handling in <code>loop-iterator-mutation</code> (<code>B909</code>) (<a href="https://redirect.github.com/astral-sh/ruff/pull/24440">#24440</a>)</li> <li>[<code>pylint</code>] Fix <code>PLC2701</code> for type parameter scopes (<a href="https://redirect.github.com/astral-sh/ruff/pull/24576">#24576</a>)</li> </ul> <h3>Rule changes</h3> <ul> <li>[<code>pandas-vet</code>] Suggest <code>.array</code> as well in <code>PD011</code> (<a href="https://redirect.github.com/astral-sh/ruff/pull/24805">#24805</a>)</li> </ul> <h3>CLI</h3> <ul> <li>Respect default Unix permissions for cache files (<a href="https://redirect.github.com/astral-sh/ruff/pull/24794">#24794</a>)</li> </ul> <h3>Documentation</h3> <ul> <li>[<code>pylint</code>] Fix <code>PLR0124</code> description not to claim self-comparison always returns the same value (<a href="https://redirect.github.com/astral-sh/ruff/pull/24749">#24749</a>)</li> <li>[<code>pyupgrade</code>] Expand docs on reusable <code>TypeVar</code>s and scoping (<code>UP046</code>) (<a href="https://redirect.github.com/astral-sh/ruff/pull/24153">#24153</a>)</li> <li>Improve rules table accessibility (<a href="https://redirect.github.com/astral-sh/ruff/pull/24711">#24711</a>)</li> </ul> <h3>Contributors</h3> <ul> <li><a href="https://github.com/dylwil3"><code>@dylwil3</code></a></li> <li><a href="https://github.com/AlexWaygood"><code>@AlexWaygood</code></a></li> <li><a href="https://github.com/woodruffw"><code>@woodruffw</code></a></li> <li><a href="https://github.com/avasis-ai"><code>@avasis-ai</code></a></li> <li><a href="https://github.com/Dev-iL"><code>@Dev-iL</code></a></li> <li><a href="https://github.com/denyszhak"><code>@denyszhak</code></a></li> <li><a href="https://github.com/ShipItAndPray"><code>@ShipItAndPray</code></a></li> <li><a href="https://github.com/anishgirianish"><code>@anishgirianish</code></a></li> <li><a href="https://github.com/augustelalande"><code>@augustelalande</code></a></li> <li><a href="https://github.com/amyreese"><code>@amyreese</code></a></li> <li><a href="https://github.com/majiayu000"><code>@majiayu000</code></a></li> </ul> <h2>0.15.11</h2> <p>Released on 2026-04-16.</p> <h3>Preview features</h3> <ul> <li>[<code>ruff</code>] Ignore <code>RUF029</code> when function is decorated with <code>asynccontextmanager</code> (<a href="https://redirect.github.com/astral-sh/ruff/pull/24642">#24642</a>)</li> <li>[<code>airflow</code>] Implement <code>airflow-xcom-pull-in-template-string</code> (<code>AIR201</code>) (<a href="https://redirect.github.com/astral-sh/ruff/pull/23583">#23583</a>)</li> <li>[<code>flake8-bandit</code>] Fix <code>S103</code> false positives and negatives in mask analysis (<a href="https://redirect.github.com/astral-sh/ruff/pull/24424">#24424</a>)</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/66f93cf7ed4d36325f35a452e4afa28268fbcd28"><code>66f93cf</code></a> Bump 0.15.12 (<a href="https://redirect.github.com/astral-sh/ruff/issues/24815">#24815</a>)</li> <li><a href="https://github.com/astral-sh/ruff/commit/476a4d02e8e3b6c157ac39979d8b698a1b6baa91"><code>476a4d0</code></a> [ty] Complete support for more detailed diagnostics on possibly unbound error...</li> <li><a href="https://github.com/astral-sh/ruff/commit/ed669eab30095d6c51fe6cdef6050fb01276bcb3"><code>ed669ea</code></a> Implement <code>#ruff:file-ignore</code> file-level suppressions (<a href="https://redirect.github.com/astral-sh/ruff/issues/23599">#23599</a>)</li> <li><a href="https://github.com/astral-sh/ruff/commit/e73d952e43feb51356ee740c5a973fce81396ff6"><code>e73d952</code></a> [ty] Include inferred type in <code>invalid-key</code> concise diagnostic for union/inte...</li> <li><a href="https://github.com/astral-sh/ruff/commit/80feb29b31cd98c093316df2e0407b0c70c01b55"><code>80feb29</code></a> [ty] report only dead annotation-only locals as unused (<a href="https://redirect.github.com/astral-sh/ruff/issues/24811">#24811</a>)</li> <li><a href="https://github.com/astral-sh/ruff/commit/0fbf2bc27336a3d17d39af52cf89b78dcda8c7c8"><code>0fbf2bc</code></a> Drop deprecated license classifier (<a href="https://redirect.github.com/astral-sh/ruff/issues/24808">#24808</a>)</li> <li><a href="https://github.com/astral-sh/ruff/commit/43b174cc7f2fcb0080bb1d4843cd4bf6b72bbe27"><code>43b174c</code></a> [ty] Infer lambda parameter types with <code>Callable</code> type context (<a href="https://redirect.github.com/astral-sh/ruff/issues/24317">#24317</a>)</li> <li><a href="https://github.com/astral-sh/ruff/commit/4f449ae4a2377569330a5ab94799d389357b5a3f"><code>4f449ae</code></a> [ty] Add error context for intersection types (<a href="https://redirect.github.com/astral-sh/ruff/issues/24772">#24772</a>)</li> <li><a href="https://github.com/astral-sh/ruff/commit/5b4e753acb46e96ad408e4904c15308e33efe307"><code>5b4e753</code></a> [ty] Add support for goto in literal enum member inlay hint (<a href="https://redirect.github.com/astral-sh/ruff/issues/24792">#24792</a>)</li> <li><a href="https://github.com/astral-sh/ruff/commit/e7cc76275a758ce1c636ea1c2d091fd576aac794"><code>e7cc762</code></a> [ty] Add error context for TypedDict assignments (<a href="https://redirect.github.com/astral-sh/ruff/issues/24790">#24790</a>)</li> <li>Additional commits viewable in <a href="https://github.com/astral-sh/ruff/compare/0.15.9...0.15.12">compare view</a></li> </ul> </details> <br /> Updates `mypy` from 1.20.0 to 1.20.2 <details> <summary>Changelog</summary> <p><em>Sourced from <a href="https://github.com/python/mypy/blob/master/CHANGELOG.md">mypy's changelog</a>.</em></p> <blockquote> <h3>Mypy 1.20.2</h3> <ul> <li>Use WAL with SQLite cache and fix close (Shantanu, PR <a href="https://redirect.github.com/python/mypy/pull/21154">21154</a>)</li> <li>Adjust SQLite journal mode (Ivan Levkivskyi, PR <a href="https://redirect.github.com/python/mypy/pull/21217">21217</a>)</li> <li>Correctly aggregate narrowing information on parent expressions (Shantanu, PR <a href="https://redirect.github.com/python/mypy/pull/21206">21206</a>)</li> <li>Fix regression related to generic callables (Shantanu, PR <a href="https://redirect.github.com/python/mypy/pull/21208">21208</a>)</li> <li>Fix regression by avoiding widening types in some contexts (Shantanu, PR <a href="https://redirect.github.com/python/mypy/pull/21242">21242</a>)</li> <li>Fix slicing in non-strict optional mode (Shantanu, PR <a href="https://redirect.github.com/python/mypy/pull/21282">21282</a>)</li> <li>mypyc: Fix match statement semantics for "or" pattern (Shantanu, PR <a href="https://redirect.github.com/python/mypy/pull/21156">21156</a>)</li> <li>mypyc: Fix issue with module dunder attributes (Piotr Sawicki, PR <a href="https://redirect.github.com/python/mypy/pull/21275">21275</a>)</li> <li>Initial support for Python 3.15.0a8 (Marc Mueller, PR <a href="https://redirect.github.com/python/mypy/pull/21255">21255</a>)</li> </ul> <h3>Acknowledgements</h3> <p>Thanks to all mypy contributors who contributed to this release:</p> <ul> <li>A5rocks</li> <li>Aaron Wieczorek</li> <li>Adam Turner</li> <li>Ali Hamdan</li> <li>asce</li> <li>BobTheBuidler</li> <li>Brent Westbrook</li> <li>Brian Schubert</li> <li>bzoracler</li> <li>Chris Burroughs</li> <li>Christoph Tyralla</li> <li>Colin Watson</li> <li>Donghoon Nam</li> <li>E. M. Bray</li> <li>Emma Smith</li> <li>Ethan Sarp</li> <li>George Ogden</li> <li>getzze</li> <li>grayjk</li> <li>Gregor Riepl</li> <li>Ivan Levkivskyi</li> <li>James Hilliard</li> <li>James Le Cuirot</li> <li>Jeremy Nimmer</li> <li>Joren Hammudoglu</li> <li>Kai (Kazuya Ito)</li> <li>kaushal trivedi</li> <li>Kevin Kannammalil</li> <li>Lukas Geiger</li> <li>Łukasz Langa</li> <li>Marc Mueller</li> <li>Michael R. Crusoe</li> <li>michaelm-openai</li> <li>Neil Schemenauer</li> <li>Piotr Sawicki</li> </ul> <!-- raw HTML omitted --> </blockquote> <p>... (truncated)</p> </details> <details> <summary>Commits</summary> <ul> <li><a href="https://github.com/python/mypy/commit/145a062651b5f9996b75ef32b7040bd2e885ed82"><code>145a062</code></a> Bump version to 1.20.2</li> <li><a href="https://github.com/python/mypy/commit/81cd49215c288eacb987de066f02daff2553b7c7"><code>81cd492</code></a> Fix slicing with nonstrict optional (<a href="https://redirect.github.com/python/mypy/issues/21282">#21282</a>)</li> <li><a href="https://github.com/python/mypy/commit/908d3441eecbaa2a6193165317177db834d7ca1a"><code>908d344</code></a> [mypyc] Set dunder attrs when adding module to sys.modules (<a href="https://redirect.github.com/python/mypy/issues/21275">#21275</a>)</li> <li><a href="https://github.com/python/mypy/commit/ba28610fac9d2b33be210ca8dcfe4bc47b7af424"><code>ba28610</code></a> Initial support for Python 3.15.0a8 (<a href="https://redirect.github.com/python/mypy/issues/21255">#21255</a>)</li> <li><a href="https://github.com/python/mypy/commit/7b0e09f48dbd3717ed008a273cd17e8e960c2037"><code>7b0e09f</code></a> Fix match statement semantics for "or" pattern (<a href="https://redirect.github.com/python/mypy/issues/21156">#21156</a>)</li> <li><a href="https://github.com/python/mypy/commit/92b74f226de62f7505f5ef5cb158e8ec9c58b8b7"><code>92b74f2</code></a> Avoid widening types in conditional_types (<a href="https://redirect.github.com/python/mypy/issues/21242">#21242</a>)</li> <li><a href="https://github.com/python/mypy/commit/0dcbfaa40b0e360a16baea9cf851955375d91b54"><code>0dcbfaa</code></a> Fix is_overlapping_types for generic callables (<a href="https://redirect.github.com/python/mypy/issues/21208">#21208</a>)</li> <li><a href="https://github.com/python/mypy/commit/210f518dede35292033ef0d387847406a0ccef8f"><code>210f518</code></a> Correctly aggregate narrowing information on parent expressions (<a href="https://redirect.github.com/python/mypy/issues/21206">#21206</a>)</li> <li><a href="https://github.com/python/mypy/commit/c34530e53a10e385d8b0f1af4baa88a596b5ceaa"><code>c34530e</code></a> Only set journal mode in coordinator (<a href="https://redirect.github.com/python/mypy/issues/21217">#21217</a>)</li> <li><a href="https://github.com/python/mypy/commit/79a3ec6d01b56a27c00e9b3320c2b1d4d73a77f9"><code>79a3ec6</code></a> Use WAL with SQLite cache, fix close (<a href="https://redirect.github.com/python/mypy/issues/21154">#21154</a>)</li> <li>Additional commits viewable in <a href="https://github.com/python/mypy/compare/v1.20.0...v1.20.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 Prebuilt
This library defines high-level APIs for creating and executing LangGraph agents and tools.
Important
This library is meant to be bundled with
langgraph, don't install it directly
Agents
langgraph-prebuilt provides an implementation of a tool-calling ReAct-style agent - create_react_agent:
pip install langchain-anthropic
from langchain_anthropic import ChatAnthropic
from langgraph.prebuilt import create_react_agent
# Define the tools for the agent to use
def search(query: str):
"""Call to surf the web."""
# This is a placeholder, but don't tell the LLM that...
if "sf" in query.lower() or "san francisco" in query.lower():
return "It's 60 degrees and foggy."
return "It's 90 degrees and sunny."
tools = [search]
model = ChatAnthropic(model="claude-3-7-sonnet-latest")
app = create_react_agent(model, tools)
# run the agent
app.invoke(
{"messages": [{"role": "user", "content": "what is the weather in sf"}]},
)
Tools
ToolNode
langgraph-prebuilt provides an implementation of a node that executes tool calls - ToolNode:
from langgraph.prebuilt import ToolNode
from langchain_core.messages import AIMessage
def search(query: str):
"""Call to surf the web."""
# This is a placeholder, but don't tell the LLM that...
if "sf" in query.lower() or "san francisco" in query.lower():
return "It's 60 degrees and foggy."
return "It's 90 degrees and sunny."
tool_node = ToolNode([search])
tool_calls = [{"name": "search", "args": {"query": "what is the weather in sf"}, "id": "1"}]
ai_message = AIMessage(content="", tool_calls=tool_calls)
# execute tool call
tool_node.invoke({"messages": [ai_message]})
ValidationNode
langgraph-prebuilt provides an implementation of a node that validates tool calls against a pydantic schema - ValidationNode:
from pydantic import BaseModel, field_validator
from langgraph.prebuilt import ValidationNode
from langchain_core.messages import AIMessage
class SelectNumber(BaseModel):
a: int
@field_validator("a")
def a_must_be_meaningful(cls, v):
if v != 37:
raise ValueError("Only 37 is allowed")
return v
validation_node = ValidationNode([SelectNumber])
validation_node.invoke({
"messages": [AIMessage("", tool_calls=[{"name": "SelectNumber", "args": {"a": 42}, "id": "1"}])]
})
Agent Inbox
The library contains schemas for using the Agent Inbox with LangGraph agents. Learn more about how to use Agent Inbox here.
from langgraph.types import interrupt
from langgraph.prebuilt.interrupt import HumanInterrupt, HumanResponse
def my_graph_function():
# Extract the last tool call from the `messages` field in the state
tool_call = state["messages"][-1].tool_calls[0]
# Create an interrupt
request: HumanInterrupt = {
"action_request": {
"action": tool_call['name'],
"args": tool_call['args']
},
"config": {
"allow_ignore": True,
"allow_respond": True,
"allow_edit": False,
"allow_accept": False
},
"description": _generate_email_markdown(state) # Generate a detailed markdown description.
}
# Send the interrupt request inside a list, and extract the first response
response = interrupt([request])[0]
if response['type'] == "response":
# Do something with the response
...