Compare commits

..
Author SHA1 Message Date
Sydney Runkleandopen-swe[bot] <open-swe@users.noreply.github.com> 1cc5f1fd48 fix(langgraph): use package metadata for API version check
Revert the optional `langgraph_api.__version__` import path in favor of the
cleaner `importlib.metadata.version("langgraph-api")` check for DeltaChannel
API compatibility. This avoids importing the optional API package at compile
time while preserving the same version boundary.

Co-authored-by: open-swe[bot] <open-swe@users.noreply.github.com>
2026-06-17 17:11:56 +00:00
Sydney Runkleandopen-swe[bot] <open-swe@users.noreply.github.com> 289b4d4d78 fix(langgraph): read langgraph_api.__version__ for delta support
Use the version constant exported by `langgraph-api` instead of package
metadata for the DeltaChannel API compatibility check. This keeps the check
aligned with the API package itself while still avoiding a hard dependency
when `langgraph-api` is absent.

Co-authored-by: open-swe[bot] <open-swe@users.noreply.github.com>
2026-06-17 17:01:34 +00:00
Sydney Runkleandopen-swe[bot] <open-swe@users.noreply.github.com> 30d1571f73 fix(langgraph): require langgraph-api>=0.10.0 for DeltaChannel
Raise for API versions below 0.10.0 so prereleases such as 0.10.0rc1 are
not accepted by the delta-channel compatibility check. Verified against real
langgraph-api releases: 0.9.0 raises and 0.10.0 compiles.

Co-authored-by: open-swe[bot] <open-swe@users.noreply.github.com>
2026-06-17 16:50:12 +00:00
Sydney Runkleandopen-swe[bot] <open-swe@users.noreply.github.com> 8cbd400a11 fix(langgraph): require langgraph-api>=0.9.0 for DeltaChannel
Use a `>=` bound (raise below 0.9.0) and simplify the check: drop the
module-level constant and the early-return ladder. Verified end-to-end
against real langgraph-api releases — 0.8.6 raises, 0.10.0 compiles.

Co-authored-by: open-swe[bot] <open-swe@users.noreply.github.com>
2026-06-15 11:30:27 +00:00
Sydney Runkleandopen-swe[bot] <open-swe@users.noreply.github.com> 9752282073 fix(langgraph): check langgraph-api version for DeltaChannel support
Replace the checkpointer-capability heuristic with a direct `langgraph-api`
version check: `DeltaChannel` reconstruction needs server-side support added
in `langgraph-api>0.9.0`. `StateGraph.compile` now raises a `RuntimeError`
when a delta-channel graph is compiled under an older API server, and is a
no-op when `langgraph-api` is not installed (local execution).

Co-authored-by: open-swe[bot] <open-swe@users.noreply.github.com>
2026-06-11 21:15:18 +00:00
Sydney Runkleandopen-swe[bot] <open-swe@users.noreply.github.com> 4e4bf1a204 feat(langgraph): warn when checkpointer lacks DeltaChannel support
A graph using `DeltaChannel` reconstructs state via the saver's
`get_delta_channel_history` API (added in `langgraph-checkpoint>=4.1.0`).
Savers from older packages lack it and fail at runtime. `StateGraph.compile`
now warns at compile time so users know to upgrade `langgraph-checkpoint`.

Co-authored-by: open-swe[bot] <open-swe@users.noreply.github.com>
2026-06-10 20:55:45 +00:00
56 changed files with 646 additions and 1662 deletions
+1 -1
View File
@@ -24,7 +24,7 @@ runs:
using: composite
steps:
- name: Install uv and set the python version
uses: astral-sh/setup-uv@37802adc94f370d6bfd71619e3f0bf239e1f3b78 # v7.6.0
uses: astral-sh/setup-uv@v7
with:
python-version: ${{ inputs.python-version }}
enable-cache: ${{ inputs.enable-cache }}
+1 -1
View File
@@ -37,7 +37,7 @@ jobs:
run:
working-directory: libs/cli
steps:
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
- uses: actions/checkout@v6
- name: Get changed files
id: changed-files
if: github.event_name != 'workflow_dispatch'
+1 -1
View File
@@ -31,7 +31,7 @@ jobs:
- "3.12"
name: "lint #${{ matrix.python-version }}"
steps:
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
- uses: actions/checkout@v6
- name: Get changed files
id: changed-files
if: github.event_name != 'workflow_dispatch'
+1 -1
View File
@@ -23,7 +23,7 @@ jobs:
env:
HAS_LANGSMITH_API_KEY: ${{ secrets.LANGSMITH_API_KEY != '' }}
steps:
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
- uses: actions/checkout@v6
- name: Set up Python
uses: ./.github/actions/uv_setup
+1 -1
View File
@@ -25,7 +25,7 @@ jobs:
name: "test #${{ matrix.python-version }}"
steps:
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
- uses: actions/checkout@v6
- name: Set up Python ${{ matrix.python-version }}
uses: ./.github/actions/uv_setup
with:
+1 -1
View File
@@ -23,7 +23,7 @@ jobs:
working-directory: libs/langgraph
name: "test #${{ matrix.python-version }}"
steps:
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
- uses: actions/checkout@v6
- name: Set up Python ${{ matrix.python-version }}
uses: ./.github/actions/uv_setup
with:
+4 -4
View File
@@ -23,7 +23,7 @@ jobs:
version: ${{ steps.check-version.outputs.version }}
steps:
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
- uses: actions/checkout@v6
- name: Set up Python ${{ env.PYTHON_VERSION }}
uses: ./.github/actions/uv_setup
@@ -48,7 +48,7 @@ jobs:
working-directory: ${{ inputs.working-directory }}
- name: Upload build
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
uses: actions/upload-artifact@v7
with:
name: test-dist
path: ${{ inputs.working-directory }}/dist/
@@ -74,9 +74,9 @@ jobs:
id-token: write
steps:
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
- uses: actions/checkout@v6
- uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
- uses: actions/download-artifact@v8
with:
name: test-dist
path: ${{ inputs.working-directory }}/dist/
+2 -2
View File
@@ -17,7 +17,7 @@ jobs:
run:
working-directory: libs/langgraph
steps:
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
- uses: actions/checkout@v6
- run: SHA=$(git rev-parse HEAD) && echo "SHA=$SHA" >> $GITHUB_ENV
- name: Set up Python 3.11
uses: ./.github/actions/uv_setup
@@ -30,7 +30,7 @@ jobs:
- name: Run benchmarks
run: OUTPUT=out/benchmark-baseline.json make -s benchmark
- name: Save outputs
uses: actions/cache/save@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
uses: actions/cache/save@v5
with:
key: ${{ runner.os }}-benchmark-baseline-${{ env.SHA }}
path: |
+3 -3
View File
@@ -15,7 +15,7 @@ jobs:
run:
working-directory: libs/langgraph
steps:
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
- uses: actions/checkout@v6
- id: files
name: Get changed files
uses: Ana06/get-changed-files@25f79e676e7ea1868813e21465014798211fad8c # v2.3.0
@@ -30,7 +30,7 @@ jobs:
- name: Install dependencies
run: uv sync --group test
- name: Download baseline
uses: actions/cache/restore@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
uses: actions/cache/restore@v5
with:
key: ${{ runner.os }}-benchmark-baseline
restore-keys: |
@@ -57,7 +57,7 @@ jobs:
echo EOF
} >> "$GITHUB_OUTPUT"
- name: Annotation
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
uses: actions/github-script@v9
env:
CHANGED_FILES: ${{ steps.files.outputs.added_modified_renamed }}
BENCHMARK_OUTPUT: ${{ steps.benchmark.outputs.OUTPUT }}
+4 -4
View File
@@ -30,7 +30,7 @@ jobs:
deps: ${{ steps.filter.outputs.deps || 'true' }}
sdk_py: ${{ steps.filter.outputs.sdk_py || 'true' }}
steps:
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
- uses: actions/checkout@v6
- uses: dorny/paths-filter@fbd0ab8f3e69293af611ebaee6363fc25e6d187d # v4
if: github.event_name != 'workflow_dispatch'
id: filter
@@ -112,9 +112,9 @@ jobs:
name: "Check SDK methods matching"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
- uses: actions/checkout@v6
- name: Set up Python
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
uses: actions/setup-python@v6
with:
python-version: "3.11"
- name: Run check_sdk_methods script
@@ -130,7 +130,7 @@ jobs:
python-version:
- "3.13"
steps:
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
- uses: actions/checkout@v6
- name: Set up Python ${{ matrix.python-version }}
uses: ./.github/actions/uv_setup
with:
+5 -5
View File
@@ -26,10 +26,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
uses: actions/checkout@v6
- name: Setup Python
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
uses: actions/setup-python@v6
with:
python-version: '3.11'
@@ -37,13 +37,13 @@ jobs:
run: python docs/generate_redirects.py
- name: Setup Pages
uses: actions/configure-pages@45bfe0192ca1faeb007ade9deae92b16b8254a0d # v6.0.0
uses: actions/configure-pages@v6
- name: Upload artifact
uses: actions/upload-pages-artifact@fc324d3547104276b827a68afc52ff2a11cc49c9 # v5.0.0
uses: actions/upload-pages-artifact@v5
with:
path: 'docs/_site'
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@cd2ce8fcbc39b97be8ca5fce6e763baed58fa128 # v5.0.0
uses: actions/deploy-pages@v5
+8 -8
View File
@@ -25,7 +25,7 @@ jobs:
tag: ${{ steps.check-version.outputs.tag }}
steps:
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
- uses: actions/checkout@v6
- name: Set up Python
uses: ./.github/actions/uv_setup
@@ -51,7 +51,7 @@ jobs:
working-directory: ${{ inputs.working-directory }}
- name: Upload build
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
uses: actions/upload-artifact@v7
with:
name: dist
path: ${{ inputs.working-directory }}/dist/
@@ -87,7 +87,7 @@ jobs:
outputs:
release-body: ${{ steps.generate-release-body.outputs.release-body }}
steps:
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
- uses: actions/checkout@v6
with:
repository: langchain-ai/langgraph
path: langgraph
@@ -158,7 +158,7 @@ jobs:
- test-pypi-publish
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
- uses: actions/checkout@v6
# We explicitly *don't* set up caching here. This ensures our tests are
# maximally sensitive to catching breakage.
@@ -262,7 +262,7 @@ jobs:
working-directory: ${{ inputs.working-directory }}
steps:
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
- uses: actions/checkout@v6
- name: Set up Python
uses: ./.github/actions/uv_setup
@@ -272,7 +272,7 @@ jobs:
enable-cache: false
working-directory: ${{ inputs.working-directory }}
- uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
- uses: actions/download-artifact@v8
with:
name: dist
path: ${{ inputs.working-directory }}/dist/
@@ -304,7 +304,7 @@ jobs:
working-directory: ${{ inputs.working-directory }}
steps:
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
- uses: actions/checkout@v6
- name: Set up Python
uses: ./.github/actions/uv_setup
@@ -314,7 +314,7 @@ jobs:
enable-cache: false
working-directory: ${{ inputs.working-directory }}
- uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
- uses: actions/download-artifact@v8
with:
name: dist
path: ${{ inputs.working-directory }}/dist/
+1 -1
View File
@@ -26,7 +26,7 @@ jobs:
steps:
- name: Find and reopen matching PRs
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
uses: actions/github-script@v9
with:
script: |
const { owner, repo } = context.repo;
+4 -4
View File
@@ -50,7 +50,7 @@ jobs:
steps:
- name: Check for issue link and assignee
id: check-link
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
uses: actions/github-script@v9
with:
script: |
const { owner, repo } = context.repo;
@@ -283,7 +283,7 @@ jobs:
if: >-
env.ENFORCE_ISSUE_LINK == 'true' &&
(steps.check-link.outputs.has-link != 'true' || steps.check-link.outputs.is-assigned != 'true')
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
uses: actions/github-script@v9
with:
script: |
const { owner, repo } = context.repo;
@@ -312,7 +312,7 @@ jobs:
if: >-
env.ENFORCE_ISSUE_LINK == 'true' &&
steps.check-link.outputs.has-link == 'true' && steps.check-link.outputs.is-assigned == 'true'
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
uses: actions/github-script@v9
with:
script: |
const { owner, repo } = context.repo;
@@ -366,7 +366,7 @@ jobs:
if: >-
env.ENFORCE_ISSUE_LINK == 'true' &&
(steps.check-link.outputs.has-link != 'true' || steps.check-link.outputs.is-assigned != 'true')
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
uses: actions/github-script@v9
with:
script: |
const { owner, repo } = context.repo;
+7 -7
View File
@@ -55,7 +55,7 @@ jobs:
steps:
- name: Generate GitHub App token
id: app-token
uses: actions/create-github-app-token@bcd2ba49218906704ab6c1aa796996da409d3eb1 # v3.2.0
uses: actions/create-github-app-token@v3
with:
app-id: ${{ secrets.ORG_MEMBERSHIP_APP_ID }}
private-key: ${{ secrets.ORG_MEMBERSHIP_APP_PRIVATE_KEY }}
@@ -63,7 +63,7 @@ jobs:
- name: Check if contributor is external
if: steps.app-token.outcome == 'success'
id: check-membership
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
uses: actions/github-script@v9
with:
github-token: ${{ steps.app-token.outputs.token }}
script: |
@@ -102,7 +102,7 @@ jobs:
- name: Apply contributor tier label
if: steps.check-membership.outputs.is-external == 'true'
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
uses: actions/github-script@v9
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
@@ -155,7 +155,7 @@ jobs:
- name: Add external label
if: steps.check-membership.outputs.is-external == 'true'
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
uses: actions/github-script@v9
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
@@ -168,7 +168,7 @@ jobs:
- name: Add internal label
if: steps.check-membership.outputs.is-external == 'false'
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
uses: actions/github-script@v9
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
@@ -190,13 +190,13 @@ jobs:
steps:
- name: Generate GitHub App token
id: app-token
uses: actions/create-github-app-token@bcd2ba49218906704ab6c1aa796996da409d3eb1 # v3.2.0
uses: actions/create-github-app-token@v3
with:
app-id: ${{ secrets.ORG_MEMBERSHIP_APP_ID }}
private-key: ${{ secrets.ORG_MEMBERSHIP_APP_PRIVATE_KEY }}
- name: Backfill labels
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
uses: actions/github-script@v9
with:
github-token: ${{ steps.app-token.outputs.token }}
script: |
+5 -5
View File
@@ -40,7 +40,7 @@ jobs:
steps:
- name: Generate GitHub App token
id: app-token
uses: actions/create-github-app-token@bcd2ba49218906704ab6c1aa796996da409d3eb1 # v3.2.0
uses: actions/create-github-app-token@v3
with:
app-id: ${{ secrets.ORG_MEMBERSHIP_APP_ID }}
private-key: ${{ secrets.ORG_MEMBERSHIP_APP_PRIVATE_KEY }}
@@ -48,7 +48,7 @@ jobs:
- name: Check if contributor is external
if: steps.app-token.outcome == 'success'
id: check-membership
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
uses: actions/github-script@v9
with:
github-token: ${{ steps.app-token.outputs.token }}
script: |
@@ -90,7 +90,7 @@ jobs:
# event fires and triggers require_issue_link.yml.
- name: Apply contributor tier label
if: steps.check-membership.outputs.is-external == 'true'
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
uses: actions/github-script@v9
with:
# Use App token so the "labeled" event propagates to downstream
# workflows (e.g. require_issue_link.yml).
@@ -145,7 +145,7 @@ jobs:
- name: Add external label
if: steps.check-membership.outputs.is-external == 'true'
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
uses: actions/github-script@v9
with:
# Use App token so the "labeled" event propagates to downstream
# workflows (e.g. require_issue_link.yml). Events created by the
@@ -161,7 +161,7 @@ jobs:
- name: Add internal label
if: steps.check-membership.outputs.is-external == 'false'
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
uses: actions/github-script@v9
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
+1 -1
View File
@@ -16,7 +16,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
- uses: actions/checkout@v6
- name: Set up uv
uses: ./.github/actions/uv_setup
+1 -9
View File
@@ -1,11 +1,3 @@
# LangGraph examples
This directory is retained purely for archival purposes and is no longer updated.
## 🤔 What is this?
The examples previously found here have been moved to the consolidated LangChain documentation. This directory remains available for historical reference, but new examples and usage guidance are published in the docs.
## 📖 Documentation
For up-to-date LangGraph examples, tutorials, and guides, see the [LangGraph Docs](https://docs.langchain.com/oss/python/langgraph/overview). Get started with the [LangGraph Quickstart](https://docs.langchain.com/oss/python/langgraph/quickstart).
This directory is retained purely for archival purposes and is no longer updated. The examples previously found here have been moved to the newly [consolidated LangChain documentation](https://docs.langchain.com/oss/python/langgraph/overview). Please refer to the LangChain docs for the most up-to-date examples and usage guidelines for LangGraph.
+5 -27
View File
@@ -1,27 +1,15 @@
# LangGraph Checkpoint Conformance
# langgraph-checkpoint-conformance
[![PyPI - Version](https://img.shields.io/pypi/v/langgraph-checkpoint-conformance?label=%20)](https://pypi.org/project/langgraph-checkpoint-conformance/#history)
[![PyPI - License](https://img.shields.io/pypi/l/langgraph-checkpoint-conformance)](https://opensource.org/licenses/MIT)
[![PyPI - Downloads](https://img.shields.io/pepy/dt/langgraph-checkpoint-conformance)](https://pypistats.org/packages/langgraph-checkpoint-conformance)
[![Twitter](https://img.shields.io/twitter/url/https/twitter.com/langchain_oss.svg?style=social&label=Follow%20%40LangChain)](https://x.com/langchain_oss)
Conformance test suite for [LangGraph](https://github.com/langchain-ai/langgraph) checkpointer implementations.
To help you ship LangGraph apps to production faster, check out [LangSmith](https://www.langchain.com/langsmith).
[LangSmith](https://www.langchain.com/langsmith) is a unified developer platform for building, testing, and monitoring LLM applications.
Validates that a `BaseCheckpointSaver` subclass correctly implements the checkpoint storage contract — blob round-trips, metadata preservation, namespace isolation, incremental channel updates, and more.
## Quick Install
## Installation
```bash
uv add langgraph-checkpoint-conformance
pip install langgraph-checkpoint-conformance
```
## 🤔 What is this?
This library provides a conformance test suite for [LangGraph](https://github.com/langchain-ai/langgraph) checkpointer implementations. It validates that a `BaseCheckpointSaver` subclass correctly implements the checkpoint storage contract — blob round-trips, metadata preservation, namespace isolation, incremental channel updates, and more.
## 📖 Documentation
For full documentation, see the [API reference](https://reference.langchain.com/python/langgraph/). For conceptual guides on persistence and memory, see the [LangGraph Docs](https://docs.langchain.com/oss/python/langgraph/overview).
## Quick start
Register your checkpointer with `@checkpointer_test` and run `validate()`:
@@ -122,13 +110,3 @@ async def pg_checkpointer():
async with PostgresSaver.from_conn_string(CONN_STRING) as saver:
yield saver
```
## 📕 Releases & Versioning
See our [Releases](https://docs.langchain.com/oss/python/release-policy) and [Versioning](https://docs.langchain.com/oss/python/versioning) policies.
## 💁 Contributing
As an open-source project in a rapidly developing field, we are extremely open to contributions, whether it be in the form of a new feature, improved infrastructure, or better documentation.
For detailed information on how to contribute, see the [Contributing Guide](https://docs.langchain.com/oss/python/contributing/overview).
+3 -33
View File
@@ -1,28 +1,10 @@
# LangGraph Checkpoint Postgres
[![PyPI - Version](https://img.shields.io/pypi/v/langgraph-checkpoint-postgres?label=%20)](https://pypi.org/project/langgraph-checkpoint-postgres/#history)
[![PyPI - License](https://img.shields.io/pypi/l/langgraph-checkpoint-postgres)](https://opensource.org/licenses/MIT)
[![PyPI - Downloads](https://img.shields.io/pepy/dt/langgraph-checkpoint-postgres)](https://pypistats.org/packages/langgraph-checkpoint-postgres)
[![Twitter](https://img.shields.io/twitter/url/https/twitter.com/langchain_oss.svg?style=social&label=Follow%20%40LangChain)](https://x.com/langchain_oss)
Implementation of LangGraph CheckpointSaver that uses Postgres.
To help you ship LangGraph apps to production faster, check out [LangSmith](https://www.langchain.com/langsmith).
[LangSmith](https://www.langchain.com/langsmith) is a unified developer platform for building, testing, and monitoring LLM applications.
## Dependencies
## Quick Install
```bash
uv add langgraph-checkpoint-postgres
```
## 🤔 What is this?
This library provides a Postgres implementation of LangGraph's checkpoint saver. Use it when you want LangGraph state persistence backed by Postgres for durable, long-running workflows and agents.
By default, `langgraph-checkpoint-postgres` installs `psycopg` (Psycopg 3) without any extras. You can choose a specific installation that best suits your needs in the [Psycopg installation docs](https://www.psycopg.org/psycopg3/docs/basic/install.html), for example `psycopg[binary]`.
## 📖 Documentation
For full documentation, see the [API reference](https://reference.langchain.com/python/langgraph.checkpoint.postgres). For conceptual guides on persistence and memory, see the [LangGraph Docs](https://docs.langchain.com/oss/python/langgraph/overview).
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](https://www.psycopg.org/psycopg3/docs/basic/install.html) (for example, `psycopg[binary]`).
## Security
@@ -38,12 +20,10 @@ For full documentation, see the [API reference](https://reference.langchain.com/
> 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](https://langchain-ai.github.io/langgraph/how-tos/persistence_postgres/).
>
> **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:**
>
> ```python
> # ❌ This will fail with TypeError during checkpointer operations
> with psycopg.connect(DB_URI) as conn: # Missing autocommit=True and row_factory=dict_row
@@ -138,13 +118,3 @@ async with AsyncPostgresSaver.from_conn_string(DB_URI) as checkpointer:
# list checkpoints
[c async for c in checkpointer.alist(read_config)]
```
## 📕 Releases & Versioning
See our [Releases](https://docs.langchain.com/oss/python/release-policy) and [Versioning](https://docs.langchain.com/oss/python/versioning) policies.
## 💁 Contributing
As an open-source project in a rapidly developing field, we are extremely open to contributions, whether it be in the form of a new feature, improved infrastructure, or better documentation.
For detailed information on how to contribute, see the [Contributing Guide](https://docs.langchain.com/oss/python/contributing/overview).
+1 -31
View File
@@ -1,26 +1,6 @@
# LangGraph SQLite Checkpoint
[![PyPI - Version](https://img.shields.io/pypi/v/langgraph-checkpoint-sqlite?label=%20)](https://pypi.org/project/langgraph-checkpoint-sqlite/#history)
[![PyPI - License](https://img.shields.io/pypi/l/langgraph-checkpoint-sqlite)](https://opensource.org/licenses/MIT)
[![PyPI - Downloads](https://img.shields.io/pepy/dt/langgraph-checkpoint-sqlite)](https://pypistats.org/packages/langgraph-checkpoint-sqlite)
[![Twitter](https://img.shields.io/twitter/url/https/twitter.com/langchain_oss.svg?style=social&label=Follow%20%40LangChain)](https://x.com/langchain_oss)
To help you ship LangGraph apps to production faster, check out [LangSmith](https://www.langchain.com/langsmith).
[LangSmith](https://www.langchain.com/langsmith) is a unified developer platform for building, testing, and monitoring LLM applications.
## Quick Install
```bash
uv add langgraph-checkpoint-sqlite
```
## 🤔 What is this?
This library provides a SQLite implementation of LangGraph's checkpoint saver, with both sync and async support via `aiosqlite`. Use it when you want LangGraph state persistence backed by SQLite for local development, testing, or lightweight deployments.
## 📖 Documentation
For full documentation, see the [API reference](https://reference.langchain.com/python/langgraph.checkpoint.sqlite). For conceptual guides on persistence and memory, see the [LangGraph Docs](https://docs.langchain.com/oss/python/langgraph/overview).
Implementation of LangGraph CheckpointSaver that uses SQLite DB (both sync and async, via `aiosqlite`)
## Security
@@ -111,13 +91,3 @@ async with AsyncSqliteSaver.from_conn_string(":memory:") as checkpointer:
# list checkpoints
[c async for c in checkpointer.alist(read_config)]
```
## 📕 Releases & Versioning
See our [Releases](https://docs.langchain.com/oss/python/release-policy) and [Versioning](https://docs.langchain.com/oss/python/versioning) policies.
## 💁 Contributing
As an open-source project in a rapidly developing field, we are extremely open to contributions, whether it be in the form of a new feature, improved infrastructure, or better documentation.
For detailed information on how to contribute, see the [Contributing Guide](https://docs.langchain.com/oss/python/contributing/overview).
+2 -32
View File
@@ -1,26 +1,6 @@
# LangGraph Checkpoint
[![PyPI - Version](https://img.shields.io/pypi/v/langgraph-checkpoint?label=%20)](https://pypi.org/project/langgraph-checkpoint/#history)
[![PyPI - License](https://img.shields.io/pypi/l/langgraph-checkpoint)](https://opensource.org/licenses/MIT)
[![PyPI - Downloads](https://img.shields.io/pepy/dt/langgraph-checkpoint)](https://pypistats.org/packages/langgraph-checkpoint)
[![Twitter](https://img.shields.io/twitter/url/https/twitter.com/langchain_oss.svg?style=social&label=Follow%20%40LangChain)](https://x.com/langchain_oss)
To help you ship LangGraph apps to production faster, check out [LangSmith](https://www.langchain.com/langsmith).
[LangSmith](https://www.langchain.com/langsmith) is a unified developer platform for building, testing, and monitoring LLM applications.
## Quick Install
```bash
uv add langgraph-checkpoint
```
## 🤔 What is this?
This library defines the base interface for LangGraph checkpointers. Checkpointers provide a persistence layer for LangGraph: they save graph state at every superstep, enabling human-in-the-loop, memory between interactions, durable execution, and more.
## 📖 Documentation
For full documentation, see the [API reference](https://reference.langchain.com/python/langgraph.checkpoint). For conceptual guides on persistence and memory, see the [LangGraph Docs](https://docs.langchain.com/oss/python/langgraph/overview).
This library defines the base interface for LangGraph checkpointers. Checkpointers provide a persistence layer for LangGraph. They allow you to interact with and manage the graph's state. When you use a graph with a checkpointer, the checkpointer saves a _checkpoint_ of the graph state at every superstep, enabling several powerful capabilities like human-in-the-loop, "memory" between interactions and more.
## Key concepts
@@ -44,7 +24,7 @@ You must pass these when invoking the graph as part of the configurable part of
### Serde
`langgraph-checkpoint` also defines protocol for serialization/deserialization (serde) and provides a default implementation (`langgraph.checkpoint.serde.jsonplus.JsonPlusSerializer`) that handles a wide variety of types, including LangChain and LangGraph primitives, datetimes, enums and more.
`langgraph_checkpoint` also defines protocol for serialization/deserialization (serde) and provides an default implementation (`langgraph.checkpoint.serde.jsonplus.JsonPlusSerializer`) that handles a wide variety of types, including LangChain and LangGraph primitives, datetimes, enums and more.
> [!IMPORTANT]
> **Checkpoint deserialization security:** By default the serializer allows any Python type found in checkpoint data. New applications should set the environment variable `LANGGRAPH_STRICT_MSGPACK=true` or pass an explicit `allowed_msgpack_modules` list to `JsonPlusSerializer` to restrict deserialization to known-safe types.
@@ -109,13 +89,3 @@ checkpointer.get(read_config)
# list checkpoints
list(checkpointer.list(read_config))
```
## 📕 Releases & Versioning
See our [Releases](https://docs.langchain.com/oss/python/release-policy) and [Versioning](https://docs.langchain.com/oss/python/versioning) policies.
## 💁 Contributing
As an open-source project in a rapidly developing field, we are extremely open to contributions, whether it be in the form of a new feature, improved infrastructure, or better documentation.
For detailed information on how to contribute, see the [Contributing Guide](https://docs.langchain.com/oss/python/contributing/overview).
+29 -60
View File
@@ -1,47 +1,29 @@
# LangGraph CLI
[![PyPI - Version](https://img.shields.io/pypi/v/langgraph-cli?label=%20)](https://pypi.org/project/langgraph-cli/#history)
[![PyPI - License](https://img.shields.io/pypi/l/langgraph-cli)](https://opensource.org/licenses/MIT)
[![PyPI - Downloads](https://img.shields.io/pepy/dt/langgraph-cli)](https://pypistats.org/packages/langgraph-cli)
[![Twitter](https://img.shields.io/twitter/url/https/twitter.com/langchain_oss.svg?style=social&label=Follow%20%40LangChain)](https://x.com/langchain_oss)
The official command-line interface for LangGraph, providing tools to create, develop, and deploy LangGraph applications.
To help you ship LangGraph apps to production faster, check out [LangSmith](https://www.langchain.com/langsmith).
[LangSmith](https://www.langchain.com/langsmith) is a unified developer platform for building, testing, and monitoring LLM applications.
## Quick Install
## Installation
Install via pip:
```bash
uv add langgraph-cli
pip install langgraph-cli
```
## 🤔 What is this?
The LangGraph CLI is the official command-line interface for LangGraph. It provides tools to create, develop, build, and run LangGraph applications locally or in Docker.
## 📖 Documentation
For full documentation, see the [LangGraph CLI reference](https://reference.langchain.com/python/langgraph-cli). For conceptual guides and tutorials, see the [LangGraph Docs](https://docs.langchain.com/oss/python/langgraph/overview).
For development mode with hot reloading:
```bash
uv add "langgraph-cli[inmem]"
pip install "langgraph-cli[inmem]"
```
## Commands
### `langgraph new` 🌱
Create a new LangGraph project from a template.
Create a new LangGraph project from a template
```bash
langgraph new [PATH] --template TEMPLATE_NAME
```
### `langgraph dev` 🏃‍♀️
Run LangGraph API server in development mode with hot reloading.
Run LangGraph API server in development mode with hot reloading
```bash
langgraph dev [OPTIONS]
--host TEXT Host to bind to (default: 127.0.0.1)
@@ -53,9 +35,7 @@ langgraph dev [OPTIONS]
```
### `langgraph up` 🚀
Launch LangGraph API server in Docker.
Launch LangGraph API server in Docker
```bash
langgraph up [OPTIONS]
-p, --port INTEGER Port to expose (default: 8123)
@@ -67,9 +47,7 @@ langgraph up [OPTIONS]
```
### `langgraph build`
Build a Docker image for your LangGraph application.
Build a Docker image for your LangGraph application
```bash
langgraph build -t IMAGE_TAG [OPTIONS]
--platform TEXT Target platforms (e.g., linux/amd64,linux/arm64)
@@ -78,9 +56,7 @@ langgraph build -t IMAGE_TAG [OPTIONS]
```
### `langgraph dockerfile`
Generate a Dockerfile for custom deployments.
Generate a Dockerfile for custom deployments
```bash
langgraph dockerfile SAVE_PATH [OPTIONS]
-c, --config FILE Config file path
@@ -92,18 +68,18 @@ The CLI uses a `langgraph.json` configuration file with these key settings:
```json
{
"dependencies": ["langchain_openai", "./your_package"],
"dependencies": ["langchain_openai", "./your_package"], // Required: Package dependencies
"graphs": {
"my_graph": "./your_package/file.py:graph"
"my_graph": "./your_package/file.py:graph" // Required: Graph definitions
},
"env": "./.env",
"python_version": "3.11",
"pip_config_file": "./pip.conf",
"dockerfile_lines": []
"env": "./.env", // Optional: Environment variables
"python_version": "3.11", // Optional: Python version (3.11/3.12)
"pip_config_file": "./pip.conf", // Optional: pip configuration
"dockerfile_lines": [] // Optional: Additional Dockerfile commands
}
```
See the [full documentation](https://reference.langchain.com/python/langgraph-cli) for detailed configuration options.
See the [full documentation](https://langchain-ai.github.io/langgraph/cloud/reference/cli/) for detailed configuration options.
## Development
@@ -111,26 +87,19 @@ To develop the CLI itself:
1. Clone the repository
2. Navigate to the CLI directory: `cd libs/cli`
3. Install development dependencies: `uv sync`
3. Install development dependencies: `uv pip install`
4. Make your changes to the CLI code
5. Test your changes:
```bash
# Run CLI commands directly
uv run langgraph --help
# Or use the examples
cd examples
uv pip install
uv run langgraph dev # or other commands
```
```bash
# Run CLI commands directly
uv run langgraph --help
## License
# Or use the examples
cd examples
uv sync
uv run langgraph dev # or other commands
```
## 📕 Releases & Versioning
See our [Releases](https://docs.langchain.com/oss/python/release-policy) and [Versioning](https://docs.langchain.com/oss/python/versioning) policies.
## 💁 Contributing
As an open-source project in a rapidly developing field, we are extremely open to contributions, whether it be in the form of a new feature, improved infrastructure, or better documentation.
For detailed information on how to contribute, see the [Contributing Guide](https://docs.langchain.com/oss/python/contributing/overview).
This project is licensed under the terms specified in the repository's LICENSE file.
+1 -5
View File
@@ -10,7 +10,7 @@ This template demonstrates a simple chatbot implemented using [LangGraph.js](htt
The core logic, defined in `src/agent/graph.ts`, showcases a straightforward chatbot that responds to user queries while maintaining context from previous messages.
## 🤔 What is this?
## What it does
The simple chatbot:
@@ -20,10 +20,6 @@ The simple chatbot:
This template provides a foundation that can be easily customized and extended to create more complex conversational agents.
## 📖 Documentation
For JavaScript and TypeScript documentation, see the [LangGraph.js docs](https://docs.langchain.com/oss/javascript/langgraph/overview). LangGraph Studio also integrates with [LangSmith](https://smith.langchain.com/) for tracing and collaboration with teammates.
## Getting Started
Assuming you have already [installed LangGraph Studio](https://github.com/langchain-ai/langgraph-studio?tab=readme-ov-file#download), to set up:
+1 -1
View File
@@ -1 +1 @@
__version__ = "0.4.30"
__version__ = "0.4.28"
+1 -46
View File
@@ -159,14 +159,7 @@ OPT_POSTGRES_URI = click.option(
OPT_API_VERSION = click.option(
"--api-version",
type=str,
help=(
"API server version to use for the base image. If unspecified, the "
"latest stable version will be used. Compatible ranges like "
"~=0.11.0.dev5 stay on 0.11.0.dev5 while only newer dev builds exist, "
"then resolve to the newest matching rc or stable release, for example "
"0.11.0rc1 or 0.11.0. Stable-floating ranges like >~=0.11.0.dev5 "
"can also pick up future stable releases, for example 0.12.0."
),
help="API server version to use for the base image. If unspecified, the latest version will be used.",
)
OPT_ENGINE_RUNTIME_MODE = click.option(
@@ -731,30 +724,6 @@ def dockerfile(
default="WARNING",
help="Set the log level for the API server.",
)
@click.option(
"--ssl-certfile",
type=click.Path(
exists=True,
file_okay=True,
dir_okay=False,
resolve_path=True,
path_type=pathlib.Path,
),
default=None,
help="Path to an SSL certificate file for serving the development server over HTTPS.",
)
@click.option(
"--ssl-keyfile",
type=click.Path(
exists=True,
file_okay=True,
dir_okay=False,
resolve_path=True,
path_type=pathlib.Path,
),
default=None,
help="Path to an SSL key file for serving the development server over HTTPS.",
)
@cli.command(
"dev",
help="🏃‍♀️‍➡️ Run LangGraph API server in development mode with hot reloading and debugging support",
@@ -773,20 +742,8 @@ def dev(
allow_blocking: bool,
tunnel: bool,
server_log_level: str,
ssl_certfile: pathlib.Path | None,
ssl_keyfile: pathlib.Path | None,
):
"""CLI entrypoint for running the LangGraph API server."""
if (ssl_certfile is None) != (ssl_keyfile is None):
raise click.UsageError(
"Both --ssl-certfile and --ssl-keyfile must be provided to enable HTTPS."
)
if ssl_certfile and ssl_keyfile and tunnel:
raise click.UsageError(
"Cannot use --tunnel with SSL options. Please choose either to serve over HTTPS or to expose via a tunnel, but not both."
)
try:
from langgraph_api.cli import run_server # type: ignore
except ImportError:
@@ -857,8 +814,6 @@ def dev(
server_level=server_log_level,
checkpointer=config_json.get("checkpointer"),
disable_persistence=config_json.get("disable_persistence", False),
ssl_certfile=ssl_certfile,
ssl_keyfile=ssl_keyfile,
)
+1 -162
View File
@@ -9,7 +9,6 @@ from collections import Counter
from typing import Literal, NamedTuple
import click
import httpx
from langgraph_cli.schemas import Config, Distros
from langgraph_cli.uv_lock import python_config_to_docker_uv_lock
@@ -42,31 +41,6 @@ _API_VERSION_PATTERN = re.compile(
r"(?:\.(?P<patch>\d+))?"
r"(?:(?:\.|)(?:[A-Za-z][0-9A-Za-z]*))?$"
)
_API_VERSION_RANGE_PATTERN = re.compile(r"^(?P<operator>~=|>~=)\s*(?P<version>.+)$")
_API_VERSION_PART_PATTERN = re.compile(
r"^(?P<major>\d+)"
r"(?:\.(?P<minor>\d+))?"
r"(?:\.(?P<patch>\d+))?"
r"(?:(?:\.|)(?P<pre>dev|rc)(?P<pre_n>\d+))?$"
)
class _ParsedApiVersion(NamedTuple):
release: tuple[int, ...]
prerelease: str | None
prerelease_number: int
class _ApiVersionRange(NamedTuple):
floor: _ParsedApiVersion
allow_future_stable: bool
_PRERELEASE_ORDER = {
"dev": 0,
"rc": 1,
None: 2,
}
def has_disallowed_build_command_content(command: str) -> bool:
@@ -167,133 +141,6 @@ def _parse_api_version_parts(version_str: str) -> tuple[int, ...]:
return tuple(int(part) for part in match.groups() if part is not None)
def _parse_api_version(version_str: str) -> _ParsedApiVersion:
match = _API_VERSION_PART_PATTERN.fullmatch(version_str)
if not match:
raise ValueError("Version must be major or major.minor or major.minor.patch.")
release = tuple(
int(part)
for part in (
match.group("major"),
match.group("minor"),
match.group("patch"),
)
if part is not None
)
prerelease = match.group("pre")
prerelease_number = int(match.group("pre_n") or 0)
return _ParsedApiVersion(release, prerelease, prerelease_number)
def _api_version_sort_key(
version: _ParsedApiVersion,
) -> tuple[tuple[int, ...], int, int]:
return (
version.release,
_PRERELEASE_ORDER[version.prerelease],
version.prerelease_number,
)
def _api_version_upper_bound(version: _ParsedApiVersion) -> tuple[int, ...]:
release = version.release
if len(release) <= 2:
return (release[0] + 1,)
return (release[0], release[1] + 1)
def _is_compatible_api_version_candidate(
candidate: _ParsedApiVersion,
version_range: _ApiVersionRange,
upper_bound: tuple[int, ...],
) -> bool:
floor = version_range.floor
if _api_version_sort_key(candidate) < _api_version_sort_key(floor):
return False
outside_compatible_range = candidate.release[: len(upper_bound)] >= upper_bound
if outside_compatible_range and not version_range.allow_future_stable:
return False
if outside_compatible_range and candidate.prerelease is not None:
return False
if floor.prerelease == "dev" and candidate.prerelease == "dev":
return candidate == floor
return True
def _ensure_compatible_api_version_base_image(base_image: str) -> None:
if ":" in base_image:
raise click.UsageError(
"Compatible api_version ranges cannot be used with a tagged base_image."
)
def _get_pypi_versions(package_name: str) -> list[str]:
try:
response = httpx.get(
f"https://pypi.org/pypi/{package_name}/json",
timeout=10,
)
response.raise_for_status()
except httpx.HTTPError as exc:
raise click.UsageError(
f"Failed to fetch PyPI versions for {package_name}: {exc}"
) from None
payload = response.json()
releases = payload.get("releases", {})
if not isinstance(releases, dict):
raise click.UsageError(
f"Failed to fetch PyPI versions for {package_name}: invalid response."
)
return [version for version in releases if isinstance(version, str)]
def _resolve_compatible_api_version(
api_version: str,
base_image: str,
version_distro_tag: str,
) -> str:
match = _API_VERSION_RANGE_PATTERN.fullmatch(api_version)
if not match:
return api_version
floor_str = match.group("version").strip()
try:
floor = _parse_api_version(floor_str)
except ValueError:
raise click.UsageError(
f"Invalid compatible api_version range: {api_version}.\n\n"
"Use a compatible version range, e.g.:\n"
' "api_version": "~=0.11.0.dev5"\n'
"or a stable-floating range, e.g.:\n"
' "api_version": ">~=0.11.0.dev5"'
) from None
version_range = _ApiVersionRange(
floor=floor,
allow_future_stable=match.group("operator") == ">~=",
)
_ensure_compatible_api_version_base_image(base_image)
pypi_versions = _get_pypi_versions("langgraph-api")
candidates: list[tuple[_ParsedApiVersion, str]] = []
upper_bound = _api_version_upper_bound(floor)
for candidate_str in pypi_versions:
try:
candidate = _parse_api_version(candidate_str)
except ValueError:
continue
if _is_compatible_api_version_candidate(candidate, version_range, upper_bound):
candidates.append((candidate, candidate_str))
if not candidates:
raise click.UsageError(
f"No PyPI releases match compatible api_version range {api_version!r} "
f"for {base_image} with {version_distro_tag!r}."
)
return max(candidates, key=lambda item: _api_version_sort_key(item[0]))[1]
def _is_node_graph(spec: str | dict) -> bool:
"""Check if a graph is a Node.js graph based on the file extension."""
if isinstance(spec, dict):
@@ -347,12 +194,7 @@ def validate_config(config: Config) -> Config:
)
if api_version:
try:
compatible_match = _API_VERSION_RANGE_PATTERN.fullmatch(api_version)
parts = _parse_api_version_parts(
compatible_match.group("version").strip()
if compatible_match
else api_version
)
parts = _parse_api_version_parts(api_version)
if len(parts) > 3:
raise ValueError(
"Version must be major or major.minor or major.minor.patch."
@@ -1588,9 +1430,6 @@ def docker_tag(
# Prepend API version if provided
if api_version:
api_version = _resolve_compatible_api_version(
api_version, base_image, f"{language}{version_distro_tag}"
)
full_tag = f"{api_version}-{language}{version_distro_tag}"
elif "/langgraph-server" in base_image and version_distro_tag not in base_image:
return f"{base_image}-{language}{version_distro_tag}"
+1 -1
View File
@@ -23,7 +23,7 @@ dependencies = [
path = "langgraph_cli/__init__.py"
[project.optional-dependencies]
inmem = [
"langgraph-api>=0.5.35,<0.12.0 ; python_version >= '3.11'",
"langgraph-api>=0.5.35,<0.12.0a0 ; python_version >= '3.11'",
"langgraph-runtime-inmem>=0.7 ; python_version >= '3.11'",
]
-25
View File
@@ -320,31 +320,6 @@ def test_top_level_help_truncates_command_descriptions_to_single_line() -> None:
assert "[Beta] List LangSmith Deployments." in deploy_list_line
def test_dev_command_requires_ssl_certfile_and_keyfile_together(tmp_path) -> None:
config_path = tmp_path / "langgraph.json"
config_path.write_text(
json.dumps({"dependencies": [], "graphs": {"agent": "./agent.py:graph"}}),
encoding="utf-8",
)
certfile = tmp_path / "cert.pem"
certfile.write_text("cert", encoding="utf-8")
runner = CliRunner()
result = runner.invoke(
cli,
[
"dev",
"--config",
str(config_path),
"--ssl-certfile",
str(certfile),
],
)
assert result.exit_code != 0
assert "Both --ssl-certfile and --ssl-keyfile must be provided" in result.output
def test_deploy_list_command(monkeypatch) -> None:
runner = CliRunner()
captured: dict[str, str] = {}
-157
View File
@@ -2961,163 +2961,6 @@ def test_docker_tag_with_prerelease_api_version(version: str, in_config: bool):
assert tag == f"langchain/langgraph-api:{version}-py3.11"
def test_docker_tag_with_compatible_api_version_promotes_to_latest_patch():
config = validate_config(
{
"python_version": "3.12",
"dependencies": ["."],
"graphs": {"agent": "./agent.py:graph"},
"image_distro": "wolfi",
"api_version": "~=0.11.0.dev5",
}
)
with patch(
"langgraph_cli.config._get_pypi_versions",
return_value=[
"0.11.0.dev5",
"0.11.0.dev6",
"0.11.0rc1",
"0.11.0",
"0.11.1rc1",
"0.11.1",
"0.12.0rc1",
],
) as get_versions:
tag = docker_tag(config)
get_versions.assert_called_once_with("langgraph-api")
assert tag == "langchain/langgraph-api:0.11.1-py3.12-wolfi"
def test_docker_tag_with_compatible_api_version_freezes_dev_until_rc():
config = validate_config(
{
"python_version": "3.12",
"dependencies": ["."],
"graphs": {"agent": "./agent.py:graph"},
"api_version": "~=0.11.0.dev5",
}
)
with patch(
"langgraph_cli.config._get_pypi_versions",
return_value=[
"0.11.0.dev5",
"0.11.0.dev6",
"0.11.0.dev7",
],
):
tag = docker_tag(config)
assert tag == "langchain/langgraph-api:0.11.0.dev5-py3.12"
def test_docker_tag_with_stable_floating_api_version_promotes_to_future_stable():
config = validate_config(
{
"python_version": "3.12",
"dependencies": ["."],
"graphs": {"agent": "./agent.py:graph"},
"image_distro": "wolfi",
"api_version": ">~=0.11.0.dev5",
}
)
with patch(
"langgraph_cli.config._get_pypi_versions",
return_value=[
"0.11.0.dev5",
"0.11.0.dev6",
"0.11.0rc1",
"0.11.0",
"0.11.1",
"0.12.0rc1",
"0.12.0",
"0.13.0.dev1",
"0.13.0",
],
) as get_versions:
tag = docker_tag(config)
get_versions.assert_called_once_with("langgraph-api")
assert tag == "langchain/langgraph-api:0.13.0-py3.12-wolfi"
def test_docker_tag_with_stable_floating_api_version_ignores_future_prereleases():
config = validate_config(
{
"python_version": "3.12",
"dependencies": ["."],
"graphs": {"agent": "./agent.py:graph"},
"api_version": ">~=0.11.0.dev5",
}
)
with patch(
"langgraph_cli.config._get_pypi_versions",
return_value=[
"0.11.0.dev5",
"0.11.0",
"0.12.0rc1",
"0.12.0.dev1",
],
):
tag = docker_tag(config)
assert tag == "langchain/langgraph-api:0.11.0-py3.12"
def test_validate_config_rejects_unrecognized_api_version_range_operator():
with pytest.raises(click.UsageError, match="Invalid version format"):
validate_config(
{
"python_version": "3.12",
"dependencies": ["."],
"graphs": {"agent": "./agent.py:graph"},
"api_version": "~>=0.11.0.dev5",
}
)
def test_docker_tag_with_compatible_api_version_supports_node_images():
config = validate_config(
{
"node_version": "20",
"graphs": {"agent": "./agent.js:graph"},
"image_distro": "wolfi",
"api_version": "~=1.2.4",
}
)
with patch(
"langgraph_cli.config._get_pypi_versions",
return_value=[
"1.2.4",
"1.2.5",
"1.3.0",
],
) as get_versions:
tag = docker_tag(config)
get_versions.assert_called_once_with("langgraph-api")
assert tag == "langchain/langgraphjs-api:1.2.5-node20-wolfi"
def test_docker_tag_with_compatible_api_version_rejects_tagged_base_image():
config = validate_config(
{
"python_version": "3.11",
"dependencies": ["."],
"graphs": {"agent": "./agent.py:graph"},
"api_version": "~=0.11.0.dev5",
}
)
with pytest.raises(click.UsageError, match="tagged base_image"):
docker_tag(config, base_image="langchain/langgraph-api:0.11.0")
def test_config_to_docker_with_api_version():
"""Test config_to_docker function with api_version parameter."""
+3 -3
View File
@@ -237,14 +237,14 @@ wheels = [
[[package]]
name = "langchain-protocol"
version = "0.0.17"
version = "0.0.15"
source = { registry = "https://pypi.org/simple" }
dependencies = [
{ name = "typing-extensions" },
]
sdist = { url = "https://files.pythonhosted.org/packages/44/b3/4e2429876c7a35585618caa2b9f9089f7162a6b50562b614ad82ac11c17e/langchain_protocol-0.0.17.tar.gz", hash = "sha256:e7cbe58c205df4b4fd87dc6d5bb23f10e13b236d0e2e1b0b9d05bc2b648f3eea", size = 6026, upload-time = "2026-06-12T18:39:51.923Z" }
sdist = { url = "https://files.pythonhosted.org/packages/4f/24/9777489d6fbbee64af0c8f96d4f840239c408cf694f3394672807dafc490/langchain_protocol-0.0.15.tar.gz", hash = "sha256:9ab2d11ee73944754f10e037e717098d3a6796f0e58afa9cadda6154e7655ade", size = 5862, upload-time = "2026-05-01T22:30:04.748Z" }
wheels = [
{ url = "https://files.pythonhosted.org/packages/13/0a/a1bfe72c6ec856e99773bbd96c8086421e554b3693d0142b9ea009c6ac92/langchain_protocol-0.0.17-py3-none-any.whl", hash = "sha256:982a08fe152586ed10d4ff3d538c2e0b5766e5f307cdea325e10be3f2c17cae6", size = 7096, upload-time = "2026-06-12T18:39:50.973Z" },
{ url = "https://files.pythonhosted.org/packages/1d/7a/9c97a7b9cbe4c5dc6a44cdb1545450c28f0c8ce89b9c1f0ee7fbad896263/langchain_protocol-0.0.15-py3-none-any.whl", hash = "sha256:461eb794358f83d5e42635a5797799ffec7b4702314e34edf73ac21e75d3ef79", size = 6982, upload-time = "2026-05-01T22:30:03.877Z" },
]
[[package]]
+3 -3
View File
@@ -211,14 +211,14 @@ wheels = [
[[package]]
name = "langchain-protocol"
version = "0.0.17"
version = "0.0.15"
source = { registry = "https://pypi.org/simple" }
dependencies = [
{ name = "typing-extensions" },
]
sdist = { url = "https://files.pythonhosted.org/packages/44/b3/4e2429876c7a35585618caa2b9f9089f7162a6b50562b614ad82ac11c17e/langchain_protocol-0.0.17.tar.gz", hash = "sha256:e7cbe58c205df4b4fd87dc6d5bb23f10e13b236d0e2e1b0b9d05bc2b648f3eea", size = 6026, upload-time = "2026-06-12T18:39:51.923Z" }
sdist = { url = "https://files.pythonhosted.org/packages/4f/24/9777489d6fbbee64af0c8f96d4f840239c408cf694f3394672807dafc490/langchain_protocol-0.0.15.tar.gz", hash = "sha256:9ab2d11ee73944754f10e037e717098d3a6796f0e58afa9cadda6154e7655ade", size = 5862, upload-time = "2026-05-01T22:30:04.748Z" }
wheels = [
{ url = "https://files.pythonhosted.org/packages/13/0a/a1bfe72c6ec856e99773bbd96c8086421e554b3693d0142b9ea009c6ac92/langchain_protocol-0.0.17-py3-none-any.whl", hash = "sha256:982a08fe152586ed10d4ff3d538c2e0b5766e5f307cdea325e10be3f2c17cae6", size = 7096, upload-time = "2026-06-12T18:39:50.973Z" },
{ url = "https://files.pythonhosted.org/packages/1d/7a/9c97a7b9cbe4c5dc6a44cdb1545450c28f0c8ce89b9c1f0ee7fbad896263/langchain_protocol-0.0.15-py3-none-any.whl", hash = "sha256:461eb794358f83d5e42635a5797799ffec7b4702314e34edf73ac21e75d3ef79", size = 6982, upload-time = "2026-05-01T22:30:03.877Z" },
]
[[package]]
+1 -1
View File
@@ -1094,7 +1094,7 @@ test = [
requires-dist = [
{ name = "click", specifier = ">=8.1.7" },
{ name = "httpx", specifier = ">=0.24.0" },
{ name = "langgraph-api", marker = "python_full_version >= '3.11' and extra == 'inmem'", specifier = ">=0.5.35,<0.12.0" },
{ name = "langgraph-api", marker = "python_full_version >= '3.11' and extra == 'inmem'", specifier = ">=0.5.35,<0.12.0a0" },
{ name = "langgraph-runtime-inmem", marker = "python_full_version >= '3.11' and extra == 'inmem'", specifier = ">=0.7" },
{ name = "langgraph-sdk", marker = "python_full_version >= '3.11'", specifier = ">=0.1.0" },
{ name = "pathspec", specifier = ">=0.11.0" },
+79 -24
View File
@@ -1,45 +1,100 @@
# 🦜🕸️ LangGraph
<div align="center">
<a href="https://www.langchain.com/langgraph">
<picture>
<source media="(prefers-color-scheme: dark)" srcset="../../.github/images/logo-dark.svg">
<source media="(prefers-color-scheme: light)" srcset="../../.github/images/logo-light.svg">
<img alt="LangGraph Logo" src=".github/images/logo-dark.svg" width="50%">
</picture>
</a>
</div>
[![PyPI - Version](https://img.shields.io/pypi/v/langgraph?label=%20)](https://pypi.org/project/langgraph/#history)
[![PyPI - License](https://img.shields.io/pypi/l/langgraph)](https://opensource.org/licenses/MIT)
[![PyPI - Downloads](https://img.shields.io/pepy/dt/langgraph)](https://pypistats.org/packages/langgraph)
[![Open Issues](https://img.shields.io/github/issues-raw/langchain-ai/langgraph)](https://github.com/langchain-ai/langgraph/issues)
[![Twitter](https://img.shields.io/twitter/url/https/twitter.com/langchain_oss.svg?style=social&label=Follow%20%40LangChain)](https://x.com/langchain_oss)
<div align="center">
<h3>Low-level orchestration framework for building stateful agents.</h3>
</div>
Looking for the JS/TS version? Check out [LangGraph.js](https://github.com/langchain-ai/langgraphjs).
<div align="center">
<a href="https://opensource.org/licenses/MIT" target="_blank"><img src="https://img.shields.io/pypi/l/langgraph" alt="PyPI - License"></a>
<a href="https://pypistats.org/packages/langgraph" target="_blank"><img src="https://img.shields.io/pepy/dt/langgraph" alt="PyPI - Downloads"></a>
<a href="https://pypi.org/project/langgraph/" target="_blank"><img src="https://img.shields.io/pypi/v/langgraph.svg?label=%20" alt="Version"></a>
<a href="https://github.com/langchain-ai/langgraph/issues" target="_blank"><img src="https://img.shields.io/github/issues-raw/langchain-ai/langgraph" alt="Open Issues"></a>
<a href="https://docs.langchain.com/oss/python/langgraph/overview" target="_blank"><img src="https://img.shields.io/badge/docs-latest-blue" alt="Docs"></a>
<a href="https://x.com/langchain_oss" target="_blank"><img src="https://img.shields.io/twitter/url/https/twitter.com/langchain_oss.svg?style=social&label=Follow%20%40LangChain" alt="Twitter / X"></a>
</div>
To help you ship LangGraph apps to production faster, check out [LangSmith](https://www.langchain.com/langsmith).
[LangSmith](https://www.langchain.com/langsmith) is a unified developer platform for building, testing, and monitoring LLM applications.
<br>
## Quick Install
Trusted by companies shaping the future of agents including Klarna, Replit, Elastic, and more LangGraph is a low-level orchestration framework for building, managing, and deploying long-running, stateful agents.
```bash
uv add langgraph
## Get started
Install LangGraph:
```
pip install -U langgraph
```
## 🤔 What is this?
Create a simple workflow:
LangGraph is a low-level orchestration framework for building, managing, and deploying long-running, stateful agents. LangGraph provides the infrastructure for durable execution, streaming, human-in-the-loop, persistence, memory, and more.
```python
from langgraph.graph import START, StateGraph
from typing_extensions import TypedDict
We recommend you use LangGraph when you have advanced needs that require a combination of deterministic and agentic workflows, heavy customization, and carefully controlled latency. Use [LangChain](https://docs.langchain.com/oss/python/langchain/overview) when you want to quickly build agents and applications powered by LLMs using pre-built agent architectures and model integrations.
LangChain [agents](https://docs.langchain.com/oss/python/langchain/agents) are built on top of LangGraph in order to provide durable execution, streaming, human-in-the-loop, persistence, and more. (You do not need to know LangGraph for basic LangChain agent usage.)
class State(TypedDict):
text: str
Trusted by companies shaping the future of agents including Klarna, Replit, Elastic, and more LangGraph is used to ship AI applications at scale.
## 📖 Documentation
def node_a(state: State) -> dict:
return {"text": state["text"] + "a"}
For full documentation, see the [API reference](https://reference.langchain.com/python/langgraph/). For conceptual guides, tutorials, and examples on using LangGraph, see the [LangGraph Docs](https://docs.langchain.com/oss/python/langgraph/overview). Get started with the [LangGraph Quickstart](https://docs.langchain.com/oss/python/langgraph/quickstart).
## 📕 Releases & Versioning
def node_b(state: State) -> dict:
return {"text": state["text"] + "b"}
See our [Releases](https://docs.langchain.com/oss/python/release-policy) and [Versioning](https://docs.langchain.com/oss/python/versioning) policies.
## 💁 Contributing
graph = StateGraph(State)
graph.add_node("node_a", node_a)
graph.add_node("node_b", node_b)
graph.add_edge(START, "node_a")
graph.add_edge("node_a", "node_b")
As an open-source project in a rapidly developing field, we are extremely open to contributions, whether it be in the form of a new feature, improved infrastructure, or better documentation.
print(graph.compile().invoke({"text": ""}))
# {'text': 'ab'}
```
For detailed information on how to contribute, see the [Contributing Guide](https://docs.langchain.com/oss/python/contributing/overview).
Get started with the [LangGraph Quickstart](https://docs.langchain.com/oss/python/langgraph/quickstart).
To quickly build agents with LangChain's `create_agent` (built on LangGraph), see the [LangChain Agents documentation](https://docs.langchain.com/oss/python/langchain/agents).
## Core benefits
LangGraph provides low-level supporting infrastructure for *any* long-running, stateful workflow or agent. LangGraph does not abstract prompts or architecture, and provides the following central benefits:
- [Durable execution](https://docs.langchain.com/oss/python/langgraph/durable-execution): Build agents that persist through failures and can run for extended periods, automatically resuming from exactly where they left off.
- [Human-in-the-loop](https://docs.langchain.com/oss/python/langgraph/interrupts): Seamlessly incorporate human oversight by inspecting and modifying agent state at any point during execution.
- [Comprehensive memory](https://docs.langchain.com/oss/python/langgraph/memory): Create truly stateful agents with both short-term working memory for ongoing reasoning and long-term persistent memory across sessions.
- [Debugging with LangSmith](http://www.langchain.com/langsmith): Gain deep visibility into complex agent behavior with visualization tools that trace execution paths, capture state transitions, and provide detailed runtime metrics.
- [Production-ready deployment](https://docs.langchain.com/langsmith/app-development): Deploy sophisticated agent systems confidently with scalable infrastructure designed to handle the unique challenges of stateful, long-running workflows.
## LangGraphs ecosystem
While LangGraph can be used standalone, it also integrates seamlessly with any LangChain product, giving developers a full suite of tools for building agents. To improve your LLM application development, pair LangGraph with:
- [LangSmith](http://www.langchain.com/langsmith) — Helpful for agent evals and observability. Debug poor-performing LLM app runs, evaluate agent trajectories, gain visibility in production, and improve performance over time.
- [LangSmith Deployment](https://docs.langchain.com/langsmith/deployments) — Deploy and scale agents effortlessly with a purpose-built deployment platform for long running, stateful workflows. Discover, reuse, configure, and share agents across teams — and iterate quickly with visual prototyping in [LangGraph Studio](https://docs.langchain.com/oss/python/langgraph/studio).
- [LangChain](https://docs.langchain.com/oss/python/langchain/overview) Provides integrations and composable components to streamline LLM application development.
> [!NOTE]
> Looking for the JS version of LangGraph? See the [JS repo](https://github.com/langchain-ai/langgraphjs) and the [JS docs](https://docs.langchain.com/oss/javascript/langgraph/overview).
## Additional resources
- [Guides](https://docs.langchain.com/oss/python/langgraph/guides): Quick, actionable code snippets for topics such as streaming, adding memory & persistence, and design patterns (e.g. branching, subgraphs, etc.).
- [Reference](https://reference.langchain.com/python/langgraph/): Detailed reference on core classes, methods, how to use the graph and checkpointing APIs, and higher-level prebuilt components.
- [Examples](https://docs.langchain.com/oss/python/langgraph/agentic-rag): Guided examples on getting started with LangGraph.
- [LangChain Forum](https://forum.langchain.com/): Connect with the community and share all of your technical questions, ideas, and feedback.
- [LangChain Academy](https://academy.langchain.com/courses/intro-to-langgraph): Learn the basics of LangGraph in our free, structured course.
- [Case studies](https://www.langchain.com/built-with-langgraph): Hear how industry leaders use LangGraph to ship AI applications at scale.
## Acknowledgements
+13 -69
View File
@@ -1,7 +1,7 @@
from __future__ import annotations
from collections import ChainMap
from collections.abc import Mapping, Sequence
from collections.abc import Sequence
from os import getenv
from typing import Any, cast
@@ -20,7 +20,6 @@ from langchain_core.runnables.config import (
from langgraph.checkpoint.base import CheckpointMetadata
from langgraph._internal._constants import (
_CHECKPOINT_COORDINATE_KEYS,
CONF,
CONFIG_KEY_CHECKPOINT_ID,
CONFIG_KEY_CHECKPOINT_MAP,
@@ -80,42 +79,6 @@ def patch_checkpoint_map(
return config
def _copy_mapping_value(value: Any) -> Any:
return dict(value) if isinstance(value, Mapping) else value
def _merge_metadata(
base: Mapping[str, Any] | None, new: Mapping[str, Any] | None
) -> dict[str, Any]:
"""Merge metadata without mutating inputs.
Top-level keys merge with newer values winning. `lc_versions` is the only
mapping-valued key that merges one level deeper, so independent LangChain
packages can contribute package versions without changing generic metadata
semantics. Mapping values are copied one level, so deeper nested objects
remain shared. `None` inputs are treated as empty metadata.
Mirrors `langchain_core.runnables.config._merge_metadata_dicts` so configs
that pass through LangGraph's merge keep the same `lc_versions` semantics;
keep the two in sync. Unlike lc-core, this copies mapping values one level
(intentionally more defensive do not "simplify" back to a shared ref).
"""
merged = {key: _copy_mapping_value(value) for key, value in (base or {}).items()}
for key, value in (new or {}).items():
if (
key == "lc_versions"
and isinstance(merged.get(key), Mapping)
and isinstance(value, Mapping)
):
merged[key] = {
**cast(Mapping[str, Any], merged[key]),
**value,
}
else:
merged[key] = _copy_mapping_value(value)
return merged
def _merge_callbacks(base: Callbacks, new: Callbacks) -> Callbacks:
"""Merge two callbacks values (None / list / BaseCallbackManager).
@@ -163,10 +126,10 @@ def merge_configs(*configs: RunnableConfig | None) -> RunnableConfig:
if not value:
continue
if key == "metadata":
base[key] = _merge_metadata(
cast(Mapping[str, Any] | None, base.get(key)),
cast(Mapping[str, Any], value),
)
if base_value := base.get(key):
base[key] = {**base_value, **value} # type: ignore
else:
base[key] = value # type: ignore[literal-required]
elif key == "tags":
if base_value := base.get(key):
base[key] = [*base_value, *value] # type: ignore
@@ -343,28 +306,6 @@ def ensure_config(*configs: RunnableConfig | None) -> RunnableConfig:
if _is_not_empty(v)
},
)
# An explicit config that supplies its own checkpoint coordinate (a
# thread_id, or any checkpoint_ns/checkpoint_id/checkpoint_map) is addressing
# its own checkpoint lineage, so drop the inherited ambient configurable
# rather than merging over it: a child graph invoked inside a parent node
# would otherwise write its checkpoints under the parent's namespace and
# never find them again. An explicit thread_id resets even when it equals the
# ambient one, since a child reusing the parent's thread id still addresses
# its own root namespace, not the parent task's. Configs that only refine
# other keys keep the ambient and shallow-merge over it below.
if empty.get(CONF):
for config in configs:
if config is None:
continue
explicit_configurable = config.get(CONF)
if not explicit_configurable:
continue
if any(
_is_not_empty(explicit_configurable.get(k))
for k in _CHECKPOINT_COORDINATE_KEYS
):
empty[CONF] = {}
break
for config in configs:
if config is None:
continue
@@ -386,11 +327,14 @@ def ensure_config(*configs: RunnableConfig | None) -> RunnableConfig:
empty.get("callbacks"), cast(Callbacks, v)
)
elif k == "metadata":
# Matches merge_configs: top-level metadata keys merge, and
# only `lc_versions` merges one level deeper.
empty["metadata"] = _merge_metadata(
cast(Mapping[str, Any] | None, empty.get("metadata")),
cast(Mapping[str, Any], v),
# Shallow-merge metadata dicts across configs so values
# bound via with_config(...) (e.g. user_id) are preserved
# when later configs supply other metadata keys.
existing = empty.get("metadata")
empty["metadata"] = (
{**cast(dict, existing), **cast(dict, v)}
if existing
else cast(dict, v).copy()
)
elif k == "tags":
# Concatenate tags across configs so values bound via
@@ -95,15 +95,6 @@ NULL_TASK_ID = sys.intern("00000000-0000-0000-0000-000000000000")
OVERWRITE = sys.intern("__overwrite__")
# dict key for the overwrite value, used as `{'__overwrite__': value}`
# Checkpoint coordinate keys: when any of these appear in an explicit
# configurable, the caller is addressing its own checkpoint lineage.
_CHECKPOINT_COORDINATE_KEYS = (
CONFIG_KEY_THREAD_ID,
CONFIG_KEY_CHECKPOINT_NS,
CONFIG_KEY_CHECKPOINT_ID,
CONFIG_KEY_CHECKPOINT_MAP,
)
# redefined to avoid circular import with langgraph.constants
_TAG_HIDDEN = sys.intern("langsmith:hidden")
+2 -1
View File
@@ -177,7 +177,8 @@ class DeltaChannel(Generic[Value], BaseChannel[Any, Any, Any]):
if overwrite_value is not None
else self.typ()
)
self.value = base
remaining = [v for i, v in enumerate(values) if i != overwrite_idx]
self.value = self.reducer(base, remaining) if remaining else base
return True
base = self.typ() if self.value is MISSING else self.value
self.value = self.reducer(base, list(values))
+25 -1
View File
@@ -5,10 +5,11 @@ import logging
import typing
import warnings
from collections import defaultdict
from collections.abc import Awaitable, Callable, Hashable, Sequence
from collections.abc import Awaitable, Callable, Hashable, Mapping, Sequence
from dataclasses import dataclass, is_dataclass
from datetime import timedelta
from functools import partial
from importlib import metadata
from inspect import isclass, isfunction, ismethod, signature
from types import FunctionType
from types import NoneType as NoneType
@@ -29,6 +30,7 @@ from langchain_core.runnables import Runnable, RunnableConfig
from langgraph.cache.base import BaseCache
from langgraph.checkpoint.base import Checkpoint
from langgraph.store.base import BaseStore
from packaging.version import Version
from pydantic import BaseModel, TypeAdapter
from typing_extensions import NotRequired, Required, Self, Unpack, is_typeddict
@@ -120,6 +122,27 @@ def _warn_invalid_state_schema(schema: type[Any] | Any) -> None:
)
def _check_delta_channel_api_support(channels: Mapping[str, Any]) -> None:
"""Raise if a `DeltaChannel` graph runs under an API server too old to support it.
`DeltaChannel` reconstruction needs server-side support added in
`langgraph-api>=0.10.0`, so we raise at compile time when an older API
server is installed. Skipped when `langgraph-api` is absent (local
execution) or the graph has no delta channel.
"""
if not any(isinstance(c, DeltaChannel) for c in channels.values()):
return
try:
api_version = metadata.version("langgraph-api")
except metadata.PackageNotFoundError:
return
if Version(api_version) < Version("0.10.0"):
raise RuntimeError(
f"`DeltaChannel` requires `langgraph-api>=0.10.0`, but {api_version} "
"is installed. Upgrade with `pip install -U langgraph-api`."
)
def _get_node_name(node: StateNode[Any, ContextT]) -> str:
try:
return getattr(node, "__name__", node.__class__.__name__)
@@ -1216,6 +1239,7 @@ class StateGraph(Generic[StateT, ContextT, InputT, OutputT]):
CompiledStateGraph: The compiled `StateGraph`.
"""
checkpointer = ensure_valid_checkpointer(checkpointer)
_check_delta_channel_api_support(self.channels)
serde_allowlist: set[tuple[str, ...]] | None = None
if _serde.STRICT_MSGPACK_ENABLED:
+7 -62
View File
@@ -132,23 +132,13 @@ class GraphRunStream:
def abort(self) -> None:
"""Stop the run early.
Closes the underlying graph iterator (propagating `GeneratorExit`
so in-flight nodes and subgraphs are cancelled), closes the mux,
and marks the stream exhausted. Idempotent.
Closes the mux and marks the stream exhausted. The graph
iterator is dropped; any in-flight nodes see the closure on
their next yield point. Idempotent.
"""
if self._exhausted:
return
self._exhausted = True
graph_iter = self._graph_iter
self._graph_iter = None
if (
graph_iter is not None
and (close := getattr(graph_iter, "close", None)) is not None
):
try:
close()
except Exception:
pass
try:
self._mux.close()
except Exception:
@@ -358,8 +348,6 @@ class AsyncGraphRunStream:
self._scope_list: list[str] = list(mux.scope)
self._pump_cond = asyncio.Condition()
self._pumping = False
self._anext_task: asyncio.Future[Any] | None = None
self._aborting = False
for key in mux.native_keys:
setattr(self, key, mux.extensions[key])
if wire_pump:
@@ -419,25 +407,7 @@ class AsyncGraphRunStream:
try:
try:
# Run the pull as a child task so `abort()` can cancel it
# mid-flight. Cancelling propagates `CancelledError` into the
# graph generator frame -> Pregel loop -> nested subgraph
# nodes, which a bare `aclose()` cannot do while the generator
# is running ("asynchronous generator is already running").
self._anext_task = asyncio.ensure_future(self._graph_aiter.__anext__())
try:
part = await self._anext_task
except asyncio.CancelledError:
if self._aborting:
# Abort-initiated cancel: stop gracefully.
self._exhausted = True
return False
# Genuine external cancel of this task: also stop the
# in-flight pull, then propagate.
self._anext_task.cancel()
raise
finally:
self._anext_task = None
part = await self._graph_aiter.__anext__()
event = convert_to_protocol_event(part)
self._observe_event(event)
await self._mux.apush(event)
@@ -458,40 +428,15 @@ class AsyncGraphRunStream:
async def abort(self) -> None:
"""Stop the run early.
Marks the stream exhausted and wakes any pump-waiters. Cancels an
in-flight pull if one is running, then closes the underlying graph
iterator, so running nodes and nested subgraphs are cancelled
whether or not a pump is mid-pull. Closes the mux; any `apush`
blocked on backpressure wakes and returns without appending.
Idempotent.
Marks the stream exhausted, wakes any pump-waiters, and closes
the mux. Any `apush` blocked on backpressure wakes and returns
without appending. Idempotent.
"""
async with self._pump_cond:
if self._exhausted:
return
self._exhausted = True
self._aborting = True
graph_aiter = self._graph_aiter
self._graph_aiter = None
anext_task = self._anext_task
self._pump_cond.notify_all()
# If a pump is mid-pull, cancel it so the cancellation propagates
# into running nodes and nested subgraphs. Once it settles the
# generator is no longer running, so the `aclose()` below is a safe
# final cleanup (and handles the no-in-flight-pull case directly).
if anext_task is not None and not anext_task.done():
anext_task.cancel()
try:
await anext_task
except (asyncio.CancelledError, Exception):
pass
if (
graph_aiter is not None
and (aclose := getattr(graph_aiter, "aclose", None)) is not None
):
try:
await aclose()
except Exception:
pass
try:
await self._mux.aclose()
except Exception:
+2 -2
View File
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
[project]
name = "langgraph"
version = "1.2.5"
version = "1.2.4"
description = "Building stateful, multi-actor applications with LLMs"
authors = []
requires-python = ">=3.10"
@@ -24,7 +24,7 @@ classifiers = [
'Programming Language :: Python :: 3.13',
]
dependencies = [
"langchain-core>=1.4.7,<2",
"langchain-core>=1.4.0,<2",
"langgraph-checkpoint>=4.1.0,<5.0.0",
"langgraph-sdk>=0.4.2,<0.5.0",
"langgraph-prebuilt>=1.1.0,<1.2.0",
-12
View File
@@ -186,18 +186,6 @@ def test_delta_channel_overwrite() -> None:
assert ch.get()[0].content == "new"
def test_delta_channel_overwrite_bypasses_same_step_reducer_writes() -> None:
def list_reducer(state: list, writes: list) -> list:
out = list(state)
for w in writes:
out.extend(w)
return out
ch = DeltaChannel(list_reducer, list).from_checkpoint(MISSING)
ch.update([[1], Overwrite([50]), [2]])
assert ch.get() == [50]
def test_delta_channel_remove_message_and_replay() -> None:
"""RemoveMessage must round-trip correctly when writes are replayed."""
spec = DeltaChannel(_messages_delta_reducer, list)
@@ -0,0 +1,95 @@
"""Compile-time check that `DeltaChannel` graphs run under a supported API server.
`DeltaChannel` reconstruction relies on server-side support added in
`langgraph-api>=0.10.0`. When running under an older API server, delta channels
fail at runtime, so `StateGraph.compile` raises with an upgrade hint. The check
is skipped when `langgraph-api` is not installed (local execution).
"""
from __future__ import annotations
import warnings
from typing import Annotated
import pytest
from typing_extensions import TypedDict
from langgraph.channels.delta import DeltaChannel
from langgraph.constants import START
from langgraph.graph import StateGraph
from langgraph.graph import state as state_module
from langgraph.graph.message import _messages_delta_reducer
class _DeltaState(TypedDict):
messages: Annotated[
list, DeltaChannel(_messages_delta_reducer, snapshot_frequency=50)
]
class _PlainState(TypedDict):
values: Annotated[list, lambda a, b: (a or []) + (b or [])]
def _delta_graph() -> StateGraph:
return (
StateGraph(_DeltaState)
.add_node("n", lambda s: {"messages": []})
.add_edge(START, "n")
)
@pytest.fixture
def api_version(monkeypatch: pytest.MonkeyPatch):
"""Override the reported `langgraph-api` package version (or simulate absence)."""
def _set(version: str | None) -> None:
def fake_version(name: str) -> str:
if name == "langgraph-api":
if version is None:
raise state_module.metadata.PackageNotFoundError(name)
return version
return state_module.metadata.version(name)
monkeypatch.setattr(state_module.metadata, "version", fake_version)
return _set
def test_delta_graph_raises_for_old_api(api_version) -> None:
api_version("0.9.9")
with pytest.raises(RuntimeError, match="requires `langgraph-api>=0.10.0`"):
_delta_graph().compile()
def test_delta_graph_raises_for_api_release_candidate(api_version) -> None:
api_version("0.10.0rc1")
with pytest.raises(RuntimeError, match="requires `langgraph-api>=0.10.0`"):
_delta_graph().compile()
def test_delta_graph_ok_for_min_api(api_version) -> None:
api_version("0.10.0")
_delta_graph().compile()
def test_delta_graph_ok_for_newer_api(api_version) -> None:
api_version("0.11.2")
_delta_graph().compile()
def test_delta_graph_ok_when_api_not_installed(api_version) -> None:
api_version(None)
_delta_graph().compile()
def test_non_delta_graph_never_raises(api_version) -> None:
api_version("0.1.0")
graph = (
StateGraph(_PlainState)
.add_node("n", lambda s: {"values": []})
.add_edge(START, "n")
)
with warnings.catch_warnings():
warnings.simplefilter("error")
graph.compile()
-7
View File
@@ -9,7 +9,6 @@ import pytest
from langchain_core.messages import AIMessage, AnyMessage, ToolCall
from langchain_core.runnables import RunnableConfig, RunnableMap, RunnablePick
from langchain_core.tools import tool
from langchain_core.version import VERSION as LANGCHAIN_CORE_VERSION
from langgraph.checkpoint.base import BaseCheckpointSaver
from langgraph.checkpoint.memory import InMemorySaver
from langgraph.prebuilt.chat_agent_executor import create_react_agent
@@ -1400,7 +1399,6 @@ def test_prebuilt_tool_chat(snapshot: SnapshotAssertion) -> None:
"ls_provider": "fakechatmodel",
"ls_model_type": "chat",
"ls_integration": "langchain_chat_model",
"lc_versions": {"langchain-core": LANGCHAIN_CORE_VERSION},
},
),
(
@@ -1463,7 +1461,6 @@ def test_prebuilt_tool_chat(snapshot: SnapshotAssertion) -> None:
"ls_provider": "fakechatmodel",
"ls_model_type": "chat",
"ls_integration": "langchain_chat_model",
"lc_versions": {"langchain-core": LANGCHAIN_CORE_VERSION},
},
),
]
@@ -1516,7 +1513,6 @@ def test_prebuilt_tool_chat(snapshot: SnapshotAssertion) -> None:
"ls_provider": "fakechatmodel",
"ls_model_type": "chat",
"ls_integration": "langchain_chat_model",
"lc_versions": {"langchain-core": LANGCHAIN_CORE_VERSION},
},
),
]
@@ -6888,7 +6884,6 @@ def test_weather_subgraph(
"ls_provider": "fakemessageslistchatmodel",
"ls_model_type": "chat",
"ls_integration": "langchain_chat_model",
"lc_versions": {"langchain-core": LANGCHAIN_CORE_VERSION},
},
),
),
@@ -6916,7 +6911,6 @@ def test_weather_subgraph(
"ls_provider": "fakemessageslistchatmodel",
"ls_model_type": "chat",
"ls_integration": "langchain_chat_model",
"lc_versions": {"langchain-core": LANGCHAIN_CORE_VERSION},
},
),
),
@@ -6953,7 +6947,6 @@ def test_weather_subgraph(
"ls_provider": "fakemessageslistchatmodel",
"ls_model_type": "chat",
"ls_integration": "langchain_chat_model",
"lc_versions": {"langchain-core": LANGCHAIN_CORE_VERSION},
},
),
]
@@ -11,7 +11,6 @@ from typing import (
import pytest
from langchain_core.messages import AnyMessage, ToolCall
from langchain_core.runnables import RunnableConfig, RunnablePick
from langchain_core.version import VERSION as LANGCHAIN_CORE_VERSION
from langgraph.checkpoint.base import BaseCheckpointSaver
from langgraph.prebuilt.chat_agent_executor import create_react_agent
from langgraph.prebuilt.tool_node import ToolNode
@@ -1151,7 +1150,6 @@ async def test_prebuilt_tool_chat() -> None:
"ls_provider": "fakechatmodel",
"ls_model_type": "chat",
"ls_integration": "langchain_chat_model",
"lc_versions": {"langchain-core": LANGCHAIN_CORE_VERSION},
},
),
(
@@ -1214,7 +1212,6 @@ async def test_prebuilt_tool_chat() -> None:
"ls_provider": "fakechatmodel",
"ls_model_type": "chat",
"ls_integration": "langchain_chat_model",
"lc_versions": {"langchain-core": LANGCHAIN_CORE_VERSION},
},
),
]
@@ -1267,7 +1264,6 @@ async def test_prebuilt_tool_chat() -> None:
"ls_provider": "fakechatmodel",
"ls_model_type": "chat",
"ls_integration": "langchain_chat_model",
"lc_versions": {"langchain-core": LANGCHAIN_CORE_VERSION},
},
),
]
@@ -3985,7 +3981,6 @@ async def test_weather_subgraph(
"ls_provider": "fakemessageslistchatmodel",
"ls_model_type": "chat",
"ls_integration": "langchain_chat_model",
"lc_versions": {"langchain-core": LANGCHAIN_CORE_VERSION},
},
),
),
@@ -4013,7 +4008,6 @@ async def test_weather_subgraph(
"ls_provider": "fakemessageslistchatmodel",
"ls_model_type": "chat",
"ls_integration": "langchain_chat_model",
"lc_versions": {"langchain-core": LANGCHAIN_CORE_VERSION},
},
),
),
@@ -4050,7 +4044,6 @@ async def test_weather_subgraph(
"ls_provider": "fakemessageslistchatmodel",
"ls_model_type": "chat",
"ls_integration": "langchain_chat_model",
"lc_versions": {"langchain-core": LANGCHAIN_CORE_VERSION},
},
),
]
-108
View File
@@ -23,7 +23,6 @@ from langchain_core.runnables import (
RunnablePassthrough,
)
from langchain_core.runnables.graph import Edge
from langchain_core.version import VERSION as LANGCHAIN_CORE_VERSION
from langgraph.cache.base import BaseCache
from langgraph.checkpoint.base import (
BaseCheckpointSaver,
@@ -6924,7 +6923,6 @@ def test_tags_stream_mode_messages() -> None:
"ls_provider": "genericfakechatmodel",
"ls_model_type": "chat",
"ls_integration": "langchain_chat_model",
"lc_versions": {"langchain-core": LANGCHAIN_CORE_VERSION},
"tags": ["meow"],
},
)
@@ -9281,13 +9279,6 @@ def test_send_with_untracked_value_overlapping_keys(
assert state.values.get("dictionary") == {"session_resource": "legal_value"}
def _delta_list_reducer(state: list, writes: Sequence[list]) -> list:
out = list(state)
for write in writes:
out.extend(write)
return out
@pytest.mark.parametrize("as_json", [False, True])
def test_overwrite_sequential(
sync_checkpointer: BaseCheckpointSaver, as_json: bool
@@ -9395,105 +9386,6 @@ def test_overwrite_parallel_error(
graph.invoke({"messages": ["START"]}, config)
@pytest.mark.parametrize("as_json", [False, True])
def test_delta_channel_overwrite_sequential(
sync_checkpointer: BaseCheckpointSaver, as_json: bool
) -> None:
class State(TypedDict):
messages: Annotated[list, DeltaChannel(_delta_list_reducer)]
def node_a(state: State):
return {"messages": ["a"]}
def node_b(state: State):
overwrite = {"__overwrite__": ["b"]} if as_json else Overwrite(["b"])
return {"messages": overwrite}
builder = StateGraph(State)
builder.add_node("node_a", node_a)
builder.add_node("node_b", node_b)
builder.add_edge(START, "node_a")
builder.add_edge("node_a", "node_b")
graph = builder.compile(checkpointer=sync_checkpointer)
config = {"configurable": {"thread_id": "delta-overwrite-sequential"}}
result = graph.invoke({"messages": ["START"]}, config)
assert result == {"messages": ["b"]}
@pytest.mark.parametrize("as_json", [False, True])
def test_delta_channel_overwrite_parallel(
sync_checkpointer: BaseCheckpointSaver, as_json: bool
) -> None:
class State(TypedDict):
messages: Annotated[list, DeltaChannel(_delta_list_reducer)]
def node_a(state: State):
return {"messages": ["a"]}
def node_b(state: State):
overwrite = {"__overwrite__": ["b"]} if as_json else Overwrite(["b"])
return {"messages": overwrite}
def node_c(state: State):
return {"messages": ["c"]}
def node_d(state: State):
return {"messages": ["d"]}
builder = StateGraph(State)
builder.add_node("node_a", node_a)
builder.add_node("node_b", node_b)
builder.add_node("node_c", node_c)
builder.add_node("node_d", node_d)
builder.add_edge(START, "node_a")
builder.add_edge("node_a", "node_b")
builder.add_edge("node_a", "node_c")
builder.add_edge("node_b", "node_d")
builder.add_edge("node_c", "node_d")
graph = builder.compile(checkpointer=sync_checkpointer)
config = {"configurable": {"thread_id": "delta-overwrite-parallel"}}
result = graph.invoke({"messages": ["START"]}, config)
assert result == {"messages": ["b", "d"]}
@pytest.mark.parametrize("as_json", [False, True])
def test_delta_channel_overwrite_parallel_error(
sync_checkpointer: BaseCheckpointSaver, as_json: bool
) -> None:
class State(TypedDict):
messages: Annotated[list, DeltaChannel(_delta_list_reducer)]
def node_a(state: State):
return {"messages": ["a"]}
def node_b(state: State):
overwrite = {"__overwrite__": ["b"]} if as_json else Overwrite(["b"])
return {"messages": overwrite}
def node_c(state: State):
overwrite = {"__overwrite__": ["c"]} if as_json else Overwrite(["c"])
return {"messages": overwrite}
builder = StateGraph(State)
builder.add_node("node_a", node_a)
builder.add_node("node_b", node_b)
builder.add_node("node_c", node_c)
builder.add_edge(START, "node_a")
builder.add_edge("node_a", "node_b")
builder.add_edge("node_a", "node_c")
builder.add_edge("node_b", END)
builder.add_edge("node_c", END)
graph = builder.compile(checkpointer=sync_checkpointer)
config = {"configurable": {"thread_id": "delta-overwrite-parallel-error"}}
with pytest.raises(
InvalidUpdateError, match="Can receive only one Overwrite value per super-step."
):
graph.invoke({"messages": ["START"]}, config)
def test_fork_does_not_apply_pending_writes(
sync_checkpointer: BaseCheckpointSaver,
) -> None:
+272 -111
View File
@@ -24,7 +24,6 @@ from langchain_core.language_models import GenericFakeChatModel
from langchain_core.messages import HumanMessage
from langchain_core.runnables import RunnableConfig, RunnableLambda, RunnablePassthrough
from langchain_core.utils.aiter import aclosing
from langchain_core.version import VERSION as LANGCHAIN_CORE_VERSION
from langgraph.cache.base import BaseCache
from langgraph.checkpoint.base import (
BaseCheckpointSaver,
@@ -7605,7 +7604,6 @@ async def test_tags_stream_mode_messages() -> None:
"ls_provider": "genericfakechatmodel",
"ls_model_type": "chat",
"ls_integration": "langchain_chat_model",
"lc_versions": {"langchain-core": LANGCHAIN_CORE_VERSION},
"tags": ["meow"],
},
)
@@ -8763,117 +8761,280 @@ async def test_imp_exception(
{"my_workflow": "done"},
]
events = [c async for c in my_workflow.astream_events(1, thread1)]
assert [(event["event"], event["name"]) for event in events] == [
("on_chain_start", "LangGraph"),
("on_chain_start", "my_workflow"),
("on_chain_start", "my_task"),
("on_chain_stream", "my_task"),
("on_chain_end", "my_task"),
("on_chain_stream", "LangGraph"),
("on_chain_start", "task_with_exception"),
("on_chain_start", "my_task"),
("on_chain_stream", "my_task"),
("on_chain_end", "my_task"),
("on_chain_stream", "my_workflow"),
("on_chain_stream", "LangGraph"),
("on_chain_end", "my_workflow"),
("on_chain_stream", "LangGraph"),
("on_chain_end", "LangGraph"),
assert [c async for c in my_workflow.astream_events(1, thread1)] == [
{
"event": "on_chain_start",
"data": {"input": 1},
"name": "LangGraph",
"tags": [],
"run_id": AnyStr(),
"metadata": {"thread_id": "1", "ls_integration": "langgraph"},
"parent_ids": [],
},
{
"event": "on_chain_start",
"data": {"input": 1},
"name": "my_workflow",
"tags": ["graph:step:4"],
"run_id": AnyStr(),
"metadata": {
"thread_id": "1",
"ls_integration": "langgraph",
"langgraph_step": 4,
"langgraph_node": "my_workflow",
"langgraph_triggers": ("__start__",),
"langgraph_path": ("__pregel_pull", "my_workflow"),
"langgraph_checkpoint_ns": AnyStr(),
},
"parent_ids": [AnyStr()],
},
{
"event": "on_chain_start",
"data": {"input": {"number": 1}},
"name": "my_task",
"tags": ["seq:step:1"],
"run_id": AnyStr(),
"metadata": {
"thread_id": "1",
"ls_integration": "langgraph",
"langgraph_step": 4,
"langgraph_node": "my_task",
"langgraph_triggers": ("__pregel_push",),
"langgraph_path": (
"__pregel_push",
("__pregel_pull", "my_workflow"),
2,
True,
),
"langgraph_checkpoint_ns": AnyStr(),
},
"parent_ids": [
AnyStr(),
AnyStr(),
],
},
{
"event": "on_chain_stream",
"run_id": AnyStr(),
"name": "my_task",
"tags": ["seq:step:1"],
"metadata": {
"thread_id": "1",
"ls_integration": "langgraph",
"langgraph_step": 4,
"langgraph_node": "my_task",
"langgraph_triggers": ("__pregel_push",),
"langgraph_path": (
"__pregel_push",
("__pregel_pull", "my_workflow"),
2,
True,
),
"langgraph_checkpoint_ns": AnyStr(),
},
"data": {"chunk": 2},
"parent_ids": [
AnyStr(),
AnyStr(),
],
},
{
"event": "on_chain_end",
"data": {"output": 2, "input": {"number": 1}},
"run_id": AnyStr(),
"name": "my_task",
"tags": ["seq:step:1"],
"metadata": {
"thread_id": "1",
"ls_integration": "langgraph",
"langgraph_step": 4,
"langgraph_node": "my_task",
"langgraph_triggers": ("__pregel_push",),
"langgraph_path": (
"__pregel_push",
("__pregel_pull", "my_workflow"),
2,
True,
),
"langgraph_checkpoint_ns": AnyStr(),
},
"parent_ids": [
AnyStr(),
AnyStr(),
],
},
{
"event": "on_chain_stream",
"run_id": AnyStr(),
"name": "LangGraph",
"tags": [],
"metadata": {"thread_id": "1", "ls_integration": "langgraph"},
"data": {"chunk": {"my_task": 2}},
"parent_ids": [],
},
{
"event": "on_chain_start",
"data": {"input": {"number": 1}},
"name": "task_with_exception",
"tags": ["seq:step:1"],
"run_id": AnyStr(),
"metadata": {
"thread_id": "1",
"ls_integration": "langgraph",
"langgraph_step": 4,
"langgraph_node": "my_task",
"langgraph_triggers": ("__pregel_push",),
"langgraph_path": (
"__pregel_push",
("__pregel_pull", "my_workflow"),
2,
True,
),
"langgraph_checkpoint_ns": AnyStr(),
},
"parent_ids": [
AnyStr(),
AnyStr(),
],
},
{
"event": "on_chain_start",
"data": {"input": {"number": 1}},
"name": "my_task",
"tags": ["seq:step:1"],
"run_id": AnyStr(),
"metadata": {
"thread_id": "1",
"ls_integration": "langgraph",
"langgraph_step": 4,
"langgraph_node": "my_task",
"langgraph_triggers": ("__pregel_push",),
"langgraph_path": (
"__pregel_push",
("__pregel_pull", "my_workflow"),
2,
True,
),
"langgraph_checkpoint_ns": AnyStr(),
},
"parent_ids": [
AnyStr(),
AnyStr(),
],
},
{
"event": "on_chain_stream",
"run_id": AnyStr(),
"name": "my_task",
"tags": ["seq:step:1"],
"metadata": {
"thread_id": "1",
"ls_integration": "langgraph",
"langgraph_step": 4,
"langgraph_node": "my_task",
"langgraph_triggers": ("__pregel_push",),
"langgraph_path": (
"__pregel_push",
("__pregel_pull", "my_workflow"),
2,
True,
),
"langgraph_checkpoint_ns": AnyStr(),
},
"data": {"chunk": 2},
"parent_ids": [
AnyStr(),
AnyStr(),
],
},
{
"event": "on_chain_end",
"data": {"output": 2, "input": {"number": 1}},
"run_id": AnyStr(),
"name": "my_task",
"tags": ["seq:step:1"],
"metadata": {
"thread_id": "1",
"ls_integration": "langgraph",
"langgraph_step": 4,
"langgraph_node": "my_task",
"langgraph_triggers": ("__pregel_push",),
"langgraph_path": (
"__pregel_push",
("__pregel_pull", "my_workflow"),
2,
True,
),
"langgraph_checkpoint_ns": AnyStr(),
},
"parent_ids": [
AnyStr(),
AnyStr(),
],
},
{
"event": "on_chain_stream",
"run_id": AnyStr(),
"name": "my_workflow",
"tags": ["graph:step:4"],
"metadata": {
"thread_id": "1",
"ls_integration": "langgraph",
"langgraph_step": 4,
"langgraph_node": "my_workflow",
"langgraph_triggers": ("__start__",),
"langgraph_path": ("__pregel_pull", "my_workflow"),
"langgraph_checkpoint_ns": AnyStr(),
},
"data": {"chunk": "done"},
"parent_ids": [AnyStr()],
},
{
"event": "on_chain_stream",
"run_id": AnyStr(),
"name": "LangGraph",
"tags": [],
"metadata": {"thread_id": "1", "ls_integration": "langgraph"},
"data": {"chunk": {"my_task": 2}},
"parent_ids": [],
},
{
"event": "on_chain_end",
"data": {"output": "done", "input": 1},
"run_id": AnyStr(),
"name": "my_workflow",
"tags": ["graph:step:4"],
"metadata": {
"thread_id": "1",
"ls_integration": "langgraph",
"langgraph_step": 4,
"langgraph_node": "my_workflow",
"langgraph_triggers": ("__start__",),
"langgraph_path": ("__pregel_pull", "my_workflow"),
"langgraph_checkpoint_ns": AnyStr(),
},
"parent_ids": [AnyStr()],
},
{
"event": "on_chain_stream",
"run_id": AnyStr(),
"name": "LangGraph",
"tags": [],
"metadata": {"thread_id": "1", "ls_integration": "langgraph"},
"data": {"chunk": {"my_workflow": "done"}},
"parent_ids": [],
},
{
"event": "on_chain_end",
"data": {"output": "done"},
"run_id": AnyStr(),
"name": "LangGraph",
"tags": [],
"metadata": {"thread_id": "1", "ls_integration": "langgraph"},
"parent_ids": [],
},
]
root_events = [event for event in events if event["name"] == "LangGraph"]
for event in root_events:
assert event["tags"] == []
assert event["metadata"]["thread_id"] == "1"
assert event["metadata"]["ls_integration"] == "langgraph"
assert event["parent_ids"] == []
workflow_events = [event for event in events if event["name"] == "my_workflow"]
for event in workflow_events:
assert event["tags"] == ["graph:step:4"]
metadata = event["metadata"]
assert metadata["thread_id"] == "1"
assert metadata["ls_integration"] == "langgraph"
assert metadata["langgraph_step"] == 4
assert metadata["langgraph_node"] == "my_workflow"
assert metadata["langgraph_triggers"] == ("__start__",)
assert metadata["langgraph_path"] == ("__pregel_pull", "my_workflow")
assert isinstance(metadata["langgraph_checkpoint_ns"], str)
assert len(event["parent_ids"]) == 1
task_events = [event for event in events if event["name"] == "my_task"]
assert len(task_events) == 6
for event in task_events:
assert event["tags"] == ["seq:step:1"]
metadata = event["metadata"]
assert metadata["thread_id"] == "1"
assert metadata["ls_integration"] == "langgraph"
assert metadata["langgraph_step"] == 4
assert metadata["langgraph_node"] == "my_task"
assert metadata["langgraph_triggers"] == ("__pregel_push",)
assert metadata["langgraph_path"][:2] == (
"__pregel_push",
("__pregel_pull", "my_workflow"),
)
assert metadata["langgraph_path"][-1] is True
assert isinstance(metadata["langgraph_checkpoint_ns"], str)
assert len(event["parent_ids"]) == 2
task_with_exception_event = next(
event for event in events if event["name"] == "task_with_exception"
)
assert task_with_exception_event["event"] == "on_chain_start"
assert task_with_exception_event["data"] == {"input": {"number": 1}}
assert task_with_exception_event["tags"] == ["seq:step:1"]
metadata = task_with_exception_event["metadata"]
assert metadata["thread_id"] == "1"
assert metadata["ls_integration"] == "langgraph"
assert metadata["langgraph_step"] == 4
assert metadata["langgraph_node"] == "task_with_exception"
assert metadata["langgraph_triggers"] == ("__pregel_push",)
assert metadata["langgraph_path"][:2] == (
"__pregel_push",
("__pregel_pull", "my_workflow"),
)
assert metadata["langgraph_path"][-1] is True
assert isinstance(metadata["langgraph_checkpoint_ns"], str)
assert len(task_with_exception_event["parent_ids"]) == 2
assert [
event["data"]
for event in events
if event["event"] == "on_chain_stream" and event["name"] == "LangGraph"
] == [
{"chunk": {"my_task": 2}},
{"chunk": {"my_task": 2}},
{"chunk": {"my_workflow": "done"}},
]
assert [
event["data"]
for event in events
if event["event"] == "on_chain_stream" and event["name"] == "my_task"
] == [{"chunk": 2}, {"chunk": 2}]
assert [
event["data"]
for event in events
if event["event"] == "on_chain_end" and event["name"] == "my_task"
] == [
{"output": 2, "input": {"number": 1}},
{"output": 2, "input": {"number": 1}},
]
assert [
event["data"]
for event in events
if event["event"] == "on_chain_stream" and event["name"] == "my_workflow"
] == [{"chunk": "done"}]
assert [
event["data"]
for event in events
if event["event"] == "on_chain_end" and event["name"] == "my_workflow"
] == [{"output": "done", "input": 1}]
assert events[-1]["data"] == {"output": "done"}
@pytest.mark.parametrize("with_timeout", [False, "inner", "outer", "both"])
@pytest.mark.parametrize("subgraph_persist", [True, False])
@@ -607,164 +607,6 @@ class TestStreamV2Async:
_ = await anext(aiter(run.values))
assert run._exhausted is True
async def test_abort_cancels_running_subgraph(self) -> None:
class CountState(TypedDict):
count: int
runs: list[int] = []
async def sub_node(state: CountState) -> dict:
runs.append(state["count"] + 1)
await asyncio.sleep(0.05)
return {"count": state["count"] + 1}
sub_graph = (
StateGraph(CountState)
.add_node("sub_node", sub_node)
.set_entry_point("sub_node")
.add_conditional_edges(
"sub_node",
lambda s: END if s["count"] >= 10 else "sub_node",
)
.compile()
)
async def main_node(state: CountState) -> None:
await sub_graph.ainvoke({"count": 0})
main_graph = (
StateGraph(CountState)
.add_node("main_node", main_node)
.set_entry_point("main_node")
.compile()
)
run = await main_graph.astream_events({"count": 0}, version="v3")
async for e in run:
if (
e["method"] == "values"
and e["params"]["namespace"]
and e["params"]["data"]["count"] >= 2
):
break
await run.abort()
runs_at_abort = len(runs)
# Give the (now-cancelled) subgraph a chance to keep looping.
await asyncio.sleep(0.3)
assert len(runs) == runs_at_abort
assert len(runs) < 10
async def test_abort_cancels_deeply_nested_subgraph(self) -> None:
class CountState(TypedDict):
count: int
runs: list[int] = []
async def deep_node(state: CountState) -> dict:
runs.append(state["count"] + 1)
await asyncio.sleep(0.05)
return {"count": state["count"] + 1}
# Deepest graph loops until count >= 10.
graph = (
StateGraph(CountState)
.add_node("deep_node", deep_node)
.set_entry_point("deep_node")
.add_conditional_edges(
"deep_node",
lambda s: END if s["count"] >= 10 else "deep_node",
)
.compile()
)
# Wrap it three times: graph -> subgraph -> subgraph -> subgraph.
for _ in range(3):
async def caller(state: CountState, _child: Any = graph) -> dict:
return await _child.ainvoke({"count": 0})
graph = (
StateGraph(CountState)
.add_node("caller", caller)
.set_entry_point("caller")
.compile()
)
run = await graph.astream_events({"count": 0}, version="v3")
async for e in run:
if (
e["method"] == "values"
and e["params"]["namespace"]
and e["params"]["data"]["count"] >= 2
):
break
await run.abort()
runs_at_abort = len(runs)
# Give the (now-cancelled) nested subgraph a chance to keep looping.
await asyncio.sleep(0.3)
assert len(runs) == runs_at_abort
assert len(runs) < 10
async def test_abort_cancels_subgraph_during_inflight_pump(self) -> None:
class CountState(TypedDict):
count: int
started = asyncio.Event()
cancelled = asyncio.Event()
async def sub_node(state: CountState) -> dict:
started.set()
try:
# Long-running node: still in flight when abort fires.
await asyncio.sleep(5)
except asyncio.CancelledError:
cancelled.set()
raise
return {"count": state["count"] + 1}
sub_graph = (
StateGraph(CountState)
.add_node("sub_node", sub_node)
.set_entry_point("sub_node")
.compile()
)
async def main_node(state: CountState) -> None:
await sub_graph.ainvoke({"count": 0})
main_graph = (
StateGraph(CountState)
.add_node("main_node", main_node)
.set_entry_point("main_node")
.compile()
)
run = await main_graph.astream_events({"count": 0}, version="v3")
# A consumer task drives the pump. Once the subgraph node is
# running, no further event is produced, so the consumer parks
# inside _apump_next awaiting graph_aiter.__anext__() — the
# generator is "running" and a plain aclose() would raise.
async def consume() -> None:
async for _e in run:
pass
consumer = asyncio.create_task(consume())
try:
await asyncio.wait_for(started.wait(), timeout=2.0)
# Let the consumer drain and park in __anext__.
await asyncio.sleep(0.05)
# Abort from a different task while the consumer is in __anext__.
await run.abort()
# The in-flight subgraph node must observe cancellation.
await asyncio.wait_for(cancelled.wait(), timeout=2.0)
finally:
consumer.cancel()
try:
await consumer
except asyncio.CancelledError:
pass
async def test_extensions_has_native_keys(self) -> None:
run = await _build_simple_graph().astream_events(
{"value": "x", "items": []}, version="v3"
@@ -639,49 +639,3 @@ def test_stateful_namespace_isolation(
"broccoli round 2",
"Veggie: broccoli round 2",
]
def test_child_with_own_thread_id_keeps_namespace(
sync_checkpointer: BaseCheckpointSaver,
) -> None:
"""A child graph invoked from inside a parent node with its own thread_id
must store and read its checkpoint under its own namespace, not inherit the
parent task's checkpoint_ns.
"""
class ChildState(TypedDict):
count: int
def child_node(state: ChildState) -> dict:
return {"count": (state.get("count") or 0) + 1}
child = (
StateGraph(ChildState)
.add_node("n", child_node)
.add_edge(START, "n")
.compile(checkpointer=sync_checkpointer)
)
child_thread = str(uuid4())
child_config = {"configurable": {"thread_id": child_thread}}
def parent_node(state: ParentState) -> dict:
child.invoke({}, config=child_config)
return {"result": "ok"}
parent = (
StateGraph(ParentState)
.add_node("p", parent_node)
.add_edge(START, "p")
.compile(checkpointer=sync_checkpointer)
)
parent_config = {"configurable": {"thread_id": str(uuid4())}}
parent.invoke({"result": ""}, config=parent_config)
state1 = child.get_state(child_config)
assert state1.values.get("count") == 1
assert state1.config["configurable"]["checkpoint_ns"] == ""
parent.invoke({"result": ""}, config=parent_config)
state2 = child.get_state(child_config)
assert state2.values.get("count") == 2
@@ -660,50 +660,3 @@ async def test_stateful_namespace_isolation_async(
"broccoli round 2",
"Veggie: broccoli round 2",
]
@NEEDS_CONTEXTVARS
async def test_child_with_own_thread_id_keeps_namespace_async(
async_checkpointer: BaseCheckpointSaver,
) -> None:
"""A child graph invoked from inside a parent node with its own thread_id
must store and read its checkpoint under its own namespace, not inherit the
parent task's checkpoint_ns.
"""
class ChildState(TypedDict):
count: int
def child_node(state: ChildState) -> dict:
return {"count": (state.get("count") or 0) + 1}
child = (
StateGraph(ChildState)
.add_node("n", child_node)
.add_edge(START, "n")
.compile(checkpointer=async_checkpointer)
)
child_thread = str(uuid4())
child_config = {"configurable": {"thread_id": child_thread}}
async def parent_node(state: ParentState) -> dict:
await child.ainvoke({}, config=child_config)
return {"result": "ok"}
parent = (
StateGraph(ParentState)
.add_node("p", parent_node)
.add_edge(START, "p")
.compile(checkpointer=async_checkpointer)
)
parent_config = {"configurable": {"thread_id": str(uuid4())}}
await parent.ainvoke({"result": ""}, config=parent_config)
state1 = await child.aget_state(child_config)
assert state1.values.get("count") == 1
assert state1.config["configurable"]["checkpoint_ns"] == ""
await parent.ainvoke({"result": ""}, config=parent_config)
state2 = await child.aget_state(child_config)
assert state2.values.get("count") == 2
-243
View File
@@ -25,7 +25,6 @@ from langgraph._internal._config import (
_merge_callbacks,
ensure_config,
get_callback_manager_for_config,
merge_configs,
)
from langgraph._internal._fields import (
_is_optional_type,
@@ -506,95 +505,6 @@ def test_ensure_config_configurable_later_wins_per_key() -> None:
assert merged["configurable"]["only_b"] == "B"
def test_ensure_config_explicit_configurable_replaces_ambient() -> None:
# An explicit checkpoint coordinate (here a new thread_id) starts a fresh
# lineage and drops the ambient run context (e.g. a parent task's
# checkpoint_ns), so a child graph does not inherit it.
from langchain_core.runnables.config import var_child_runnable_config
token = var_child_runnable_config.set(
{"configurable": {"checkpoint_ns": "p:parent-task", "checkpoint_id": "cid"}}
)
try:
merged = ensure_config({"configurable": {"thread_id": "child"}})
finally:
var_child_runnable_config.reset(token)
assert merged["configurable"]["thread_id"] == "child"
assert "checkpoint_ns" not in merged["configurable"]
assert "checkpoint_id" not in merged["configurable"]
def test_ensure_config_ambient_inherited_when_no_explicit_configurable() -> None:
# With no explicit configurable, the ambient run context is inherited
# unchanged (stateless subgraph / interrupt-resume pattern).
from langchain_core.runnables.config import var_child_runnable_config
token = var_child_runnable_config.set(
{"configurable": {"checkpoint_ns": "p:parent-task"}}
)
try:
merged = ensure_config({"tags": ["t"]})
finally:
var_child_runnable_config.reset(token)
assert merged["configurable"]["checkpoint_ns"] == "p:parent-task"
def test_ensure_config_explicit_configurables_still_merge_over_ambient() -> None:
# A new thread_id drops the ambient, but explicit configs still shallow-merge
# among themselves, so a with_config(...) value (ls_agent_type) survives
# alongside an invoke-time thread_id.
from langchain_core.runnables.config import var_child_runnable_config
token = var_child_runnable_config.set(
{"configurable": {"checkpoint_ns": "p:parent-task"}}
)
try:
merged = ensure_config(
{"configurable": {"ls_agent_type": "root"}},
{"configurable": {"thread_id": "child"}},
)
finally:
var_child_runnable_config.reset(token)
assert merged["configurable"]["ls_agent_type"] == "root"
assert merged["configurable"]["thread_id"] == "child"
assert "checkpoint_ns" not in merged["configurable"]
def test_ensure_config_non_coordinate_config_keeps_ambient_checkpoint_ns() -> None:
# A nested subagent is invoked with a non-coordinate configurable key
# (ls_agent_type) and no thread_id; it must keep the inherited checkpoint_ns
# so it stays a discoverable child of the parent run (deepagents `task` tool).
from langchain_core.runnables.config import var_child_runnable_config
token = var_child_runnable_config.set(
{"configurable": {"thread_id": "parent", "checkpoint_ns": "p:parent-task"}}
)
try:
merged = ensure_config({"configurable": {"ls_agent_type": "subagent"}})
finally:
var_child_runnable_config.reset(token)
assert merged["configurable"]["ls_agent_type"] == "subagent"
assert merged["configurable"]["checkpoint_ns"] == "p:parent-task"
assert merged["configurable"]["thread_id"] == "parent"
def test_ensure_config_same_thread_id_still_clears_ambient() -> None:
# A child that reuses the parent's thread_id is still addressing its own root
# namespace on that thread, so the parent task's checkpoint_ns must not leak
# in; otherwise the child writes state that get_state cannot read back.
from langchain_core.runnables.config import var_child_runnable_config
token = var_child_runnable_config.set(
{"configurable": {"thread_id": "shared", "checkpoint_ns": "p:parent-task"}}
)
try:
merged = ensure_config({"configurable": {"thread_id": "shared"}})
finally:
var_child_runnable_config.reset(token)
assert merged["configurable"]["thread_id"] == "shared"
assert "checkpoint_ns" not in merged["configurable"]
def test_ensure_config_merges_metadata_across_configs() -> None:
a = {"metadata": {"user_id": "U1"}}
b = {"metadata": {"correlation_id": "C1"}}
@@ -610,159 +520,6 @@ def test_ensure_config_metadata_later_wins_per_key() -> None:
assert merged["metadata"]["shared"] == "from_b"
def test_merge_configs_merges_metadata_lc_versions() -> None:
a = {
"metadata": {
"lc_versions": {"langgraph": "1.2.4"},
"lc_agent_name": "agent",
}
}
b = {"metadata": {"lc_versions": {"langchain-core": "1.2.0"}}}
merged = merge_configs(a, b)
assert merged["metadata"]["lc_versions"] == {
"langgraph": "1.2.4",
"langchain-core": "1.2.0",
}
assert merged["metadata"]["lc_agent_name"] == "agent"
def test_ensure_config_merges_metadata_lc_versions() -> None:
a = {
"metadata": {
"lc_versions": {"langgraph": "1.2.4"},
"lc_agent_name": "agent",
}
}
b = {"metadata": {"lc_versions": {"langchain-core": "1.2.0"}}}
merged = ensure_config(a, b)
assert merged["metadata"]["lc_versions"] == {
"langgraph": "1.2.4",
"langchain-core": "1.2.0",
}
assert merged["metadata"]["lc_agent_name"] == "agent"
@pytest.mark.parametrize("merge", [merge_configs, ensure_config])
def test_metadata_lc_versions_later_values_win_without_recursive_merge(
merge: Callable[..., RunnableConfig],
) -> None:
a = {
"metadata": {
"lc_versions": {
"langgraph": "1.2.4",
"nested": {"only_a": "A", "shared": "from_a"},
}
}
}
b = {
"metadata": {
"lc_versions": {
"langchain-core": "1.2.0",
"nested": {"only_b": "B", "shared": "from_b"},
}
}
}
merged = merge(a, b)
assert merged["metadata"]["lc_versions"] == {
"langgraph": "1.2.4",
"langchain-core": "1.2.0",
"nested": {"only_b": "B", "shared": "from_b"},
}
@pytest.mark.parametrize("merge", [merge_configs, ensure_config])
def test_metadata_nested_mappings_other_than_lc_versions_are_replaced(
merge: Callable[..., RunnableConfig],
) -> None:
a = {"metadata": {"versions": {"langgraph": "1.2.4"}, "mode": "bound"}}
b = {
"metadata": {
"versions": {"langchain-core": "1.2.0"},
"mode": {"source": "runtime"},
}
}
merged = merge(a, b)
assert merged["metadata"]["versions"] == {"langchain-core": "1.2.0"}
assert merged["metadata"]["mode"] == {"source": "runtime"}
@pytest.mark.parametrize("merge", [merge_configs, ensure_config])
def test_metadata_non_mapping_values_later_wins(
merge: Callable[..., RunnableConfig],
) -> None:
a = {"metadata": {"lc_versions": {"langgraph": "1.2.4"}, "mode": "bound"}}
b = {"metadata": {"lc_versions": "runtime", "mode": {"source": "runtime"}}}
merged = merge(a, b)
assert merged["metadata"]["lc_versions"] == "runtime"
assert merged["metadata"]["mode"] == {"source": "runtime"}
@pytest.mark.parametrize("merge", [merge_configs, ensure_config])
def test_metadata_lc_versions_merge_does_not_mutate_inputs(
merge: Callable[..., RunnableConfig],
) -> None:
a_versions = {"langgraph": "1.2.4"}
b_versions = {"langchain-core": "1.2.0"}
a = {"metadata": {"lc_versions": a_versions}}
b = {"metadata": {"lc_versions": b_versions}}
merged = merge(a, b)
assert a == {"metadata": {"lc_versions": {"langgraph": "1.2.4"}}}
assert b == {"metadata": {"lc_versions": {"langchain-core": "1.2.0"}}}
assert merged["metadata"]["lc_versions"] is not a_versions
assert merged["metadata"]["lc_versions"] is not b_versions
merged["metadata"]["lc_versions"]["langgraph"] = "changed"
assert a_versions == {"langgraph": "1.2.4"}
assert b_versions == {"langchain-core": "1.2.0"}
@pytest.mark.parametrize("merge", [merge_configs, ensure_config])
def test_metadata_single_sided_mapping_values_are_copied(
merge: Callable[..., RunnableConfig],
) -> None:
base_versions = {"langgraph": "1.2.4"}
new_versions = {"langchain-core": "1.2.0"}
merged_base_only = merge({"metadata": {"lc_versions": base_versions}})
merged_new_only = merge(
{"metadata": {}},
{"metadata": {"lc_versions": new_versions}},
)
assert merged_base_only["metadata"]["lc_versions"] is not base_versions
assert merged_new_only["metadata"]["lc_versions"] is not new_versions
merged_base_only["metadata"]["lc_versions"]["langgraph"] = "changed"
merged_new_only["metadata"]["lc_versions"]["langchain-core"] = "changed"
assert base_versions == {"langgraph": "1.2.4"}
assert new_versions == {"langchain-core": "1.2.0"}
@pytest.mark.parametrize("merge", [merge_configs, ensure_config])
def test_metadata_empty_incoming_preserves_base_lc_versions(
merge: Callable[..., RunnableConfig],
) -> None:
a = {"metadata": {"lc_versions": {"langgraph": "1.2.4"}}}
b = {"metadata": {"lc_versions": {}}}
merged = merge(a, b)
assert merged["metadata"]["lc_versions"] == {"langgraph": "1.2.4"}
@pytest.mark.parametrize("merge", [merge_configs, ensure_config])
def test_metadata_lc_versions_accumulate_across_more_than_two_configs(
merge: Callable[..., RunnableConfig],
) -> None:
a = {"metadata": {"lc_versions": {"langgraph": "1.2.4"}}}
b = {"metadata": {"lc_versions": {"langchain-core": "1.2.0"}}}
c = {"metadata": {"lc_versions": {"langchain": "1.1.0"}}}
merged = merge(a, b, c)
assert merged["metadata"]["lc_versions"] == {
"langgraph": "1.2.4",
"langchain-core": "1.2.0",
"langchain": "1.1.0",
}
def test_ensure_config_merges_tags_across_configs() -> None:
a = {"tags": ["alpha"]}
b = {"tags": ["beta"]}
+17 -17
View File
@@ -1350,7 +1350,7 @@ wheels = [
[[package]]
name = "langchain-core"
version = "1.4.7"
version = "1.4.0"
source = { registry = "https://pypi.org/simple" }
dependencies = [
{ name = "jsonpatch" },
@@ -1363,9 +1363,9 @@ dependencies = [
{ name = "typing-extensions" },
{ name = "uuid-utils" },
]
sdist = { url = "https://files.pythonhosted.org/packages/ee/2b/fffaff399d20a56d40b9562fa19701e91abd72d8c9d9bc8c2673077b56b6/langchain_core-1.4.7.tar.gz", hash = "sha256:7a825d77de0a3f39adbd9d09612a75e85527e14a52c1601089bcc062972d9f2b", size = 952522, upload-time = "2026-06-12T19:23:57.588Z" }
sdist = { url = "https://files.pythonhosted.org/packages/59/de/679a53472c25860837e32c0442c962fa86e95317a36460e2c9d5c91b17c2/langchain_core-1.4.0.tar.gz", hash = "sha256:1dc341eed802ed9c117c0df3923c991e5e9e226571e5725c194eeb5bd93d1a7f", size = 920260, upload-time = "2026-05-11T18:42:35.919Z" }
wheels = [
{ url = "https://files.pythonhosted.org/packages/de/3e/dcdffa60078ae7b3a00ebb4cbbf1a204a14c3609983c604886523a7d4418/langchain_core-1.4.7-py3-none-any.whl", hash = "sha256:bcadd51951140ecdcba98311dbd931ba5de02a5ba8a2288dad5069c1eea2a13d", size = 554941, upload-time = "2026-06-12T19:23:55.826Z" },
{ url = "https://files.pythonhosted.org/packages/0f/1a/86c38c27b81913a1c6c12448cab55defb5a1097c7dc9a4cea83f55477a2d/langchain_core-1.4.0-py3-none-any.whl", hash = "sha256:23cbbdb46e38ddd1dd5247e6167e96013eae74bea4c5949c550809970a9e565c", size = 548120, upload-time = "2026-05-11T18:42:33.992Z" },
]
[[package]]
@@ -1382,7 +1382,7 @@ wheels = [
[[package]]
name = "langgraph"
version = "1.2.5"
version = "1.2.4"
source = { editable = "." }
dependencies = [
{ name = "langchain-core" },
@@ -1454,7 +1454,7 @@ test = [
[package.metadata]
requires-dist = [
{ name = "langchain-core", specifier = ">=1.4.7,<2" },
{ name = "langchain-core", specifier = ">=1.4.0,<2" },
{ name = "langgraph-checkpoint", editable = "../checkpoint" },
{ name = "langgraph-prebuilt", editable = "../prebuilt" },
{ name = "langgraph-sdk", editable = "../sdk-py" },
@@ -1721,7 +1721,7 @@ inmem = [
requires-dist = [
{ name = "click", specifier = ">=8.1.7" },
{ name = "httpx", specifier = ">=0.24.0" },
{ name = "langgraph-api", marker = "python_full_version >= '3.11' and extra == 'inmem'", specifier = ">=0.5.35,<0.12.0" },
{ name = "langgraph-api", marker = "python_full_version >= '3.11' and extra == 'inmem'", specifier = ">=0.5.35,<0.12.0a0" },
{ name = "langgraph-runtime-inmem", marker = "python_full_version >= '3.11' and extra == 'inmem'", specifier = ">=0.7" },
{ name = "langgraph-sdk", marker = "python_full_version >= '3.11'", specifier = ">=0.1.0" },
{ name = "pathspec", specifier = ">=0.11.0" },
@@ -3510,19 +3510,19 @@ wheels = [
[[package]]
name = "tornado"
version = "6.5.6"
version = "6.5.5"
source = { registry = "https://pypi.org/simple" }
sdist = { url = "https://files.pythonhosted.org/packages/50/57/6d7303a77ae439d9189108f76c0c4fd89ee5e2cc8387bffb55232565c4ed/tornado-6.5.6.tar.gz", hash = "sha256:9a365179fe8ff6b8766f602c0f67c185d778193e9bdd828b19f0b6ed7764177d", size = 518139, upload-time = "2026-05-27T15:35:54.646Z" }
sdist = { url = "https://files.pythonhosted.org/packages/f8/f1/3173dfa4a18db4a9b03e5d55325559dab51ee653763bb8745a75af491286/tornado-6.5.5.tar.gz", hash = "sha256:192b8f3ea91bd7f1f50c06955416ed76c6b72f96779b962f07f911b91e8d30e9", size = 516006, upload-time = "2026-03-10T21:31:02.067Z" }
wheels = [
{ url = "https://files.pythonhosted.org/packages/1b/0d/b4f481e18c5a51864e6d12b9a05ecf72919696680b747c958c3fc1f4fbae/tornado-6.5.6-cp39-abi3-macosx_10_9_universal2.whl", hash = "sha256:65fcfaafb079435c2c19dc9e07c0f1cf0fa9051759ed0a7d0a3ba7ea7f64919c", size = 447737, upload-time = "2026-05-27T15:35:38.122Z" },
{ url = "https://files.pythonhosted.org/packages/9e/9c/5430c39fcab1144d35860f457b15e9c08b4bc7ac86764354204e983d6183/tornado-6.5.6-cp39-abi3-macosx_10_9_x86_64.whl", hash = "sha256:38bc01b4acacded2de63ae78023548e41ebe6fbed3ec05a796d7ae3ad893887e", size = 445899, upload-time = "2026-05-27T15:35:40.519Z" },
{ url = "https://files.pythonhosted.org/packages/8b/79/fa7e14a2f939c807a8d30619b4eb604eab219601b78792516ebe22d40cf9/tornado-6.5.6-cp39-abi3-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl", hash = "sha256:b942e6a137fda31ff54bf8e6e2c8d1c37f1f50583f3ed53fb840b53b9601d104", size = 448964, upload-time = "2026-05-27T15:35:42.106Z" },
{ url = "https://files.pythonhosted.org/packages/a7/71/bd67d5f5199f937dafe03a49a37989f60f600ff6fef34c79412a829d97bd/tornado-6.5.6-cp39-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:8666946e70171b8c3f1fc9b7876fac492e84822c4c7f3746f4e8f8bc9ac92a79", size = 449935, upload-time = "2026-05-27T15:35:43.906Z" },
{ url = "https://files.pythonhosted.org/packages/cc/a4/c24388c9cf5b3c3a513b56a158af9f23092c9a2810d789e294310797df21/tornado-6.5.6-cp39-abi3-musllinux_1_2_aarch64.whl", hash = "sha256:1c34cfab7ad6d104f052f55de06d39bbafc5885cfeb4da688803308dbcfa90b7", size = 449767, upload-time = "2026-05-27T15:35:45.793Z" },
{ url = "https://files.pythonhosted.org/packages/a5/eb/6a07ad550c3f7b37244bd0becdf293ec3d3e961783d8b720a97df50de1b2/tornado-6.5.6-cp39-abi3-musllinux_1_2_x86_64.whl", hash = "sha256:385f35e4e22fb52551dfcda4cdc8c30c61c2c001aef5ddad99cdfe116952efd3", size = 449174, upload-time = "2026-05-27T15:35:47.485Z" },
{ url = "https://files.pythonhosted.org/packages/bb/84/3469e098dccdb6763130e06aacd786bb4363fca7b590a55c101ddf34ed30/tornado-6.5.6-cp39-abi3-win32.whl", hash = "sha256:db475f1b67b2809b10bb16264829087724ca8d24fe4ed47f7b8675cae453ef86", size = 450230, upload-time = "2026-05-27T15:35:49.322Z" },
{ url = "https://files.pythonhosted.org/packages/d2/3c/273a04e0b9dd9016f1685cca0c1c8795a71ac88a34a8c889a0b443483226/tornado-6.5.6-cp39-abi3-win_amd64.whl", hash = "sha256:6739bf1e8eb09230f1280ddbd3236f0309db70f2c551a8dbc40f62babdf82f79", size = 450667, upload-time = "2026-05-27T15:35:51.194Z" },
{ url = "https://files.pythonhosted.org/packages/02/98/0cffe22a224f60c5fb1e3aa0b76f9da2e1ca78b0e9545e3d077c68ce60a7/tornado-6.5.6-cp39-abi3-win_arm64.whl", hash = "sha256:2543597b24a695d72338a9a77818362d72387c03ae173f1f169eadc5c91466ac", size = 449690, upload-time = "2026-05-27T15:35:52.902Z" },
{ url = "https://files.pythonhosted.org/packages/59/8c/77f5097695f4dd8255ecbd08b2a1ed8ba8b953d337804dd7080f199e12bf/tornado-6.5.5-cp39-abi3-macosx_10_9_universal2.whl", hash = "sha256:487dc9cc380e29f58c7ab88f9e27cdeef04b2140862e5076a66fb6bb68bb1bfa", size = 445983, upload-time = "2026-03-10T21:30:44.28Z" },
{ url = "https://files.pythonhosted.org/packages/ab/5e/7625b76cd10f98f1516c36ce0346de62061156352353ef2da44e5c21523c/tornado-6.5.5-cp39-abi3-macosx_10_9_x86_64.whl", hash = "sha256:65a7f1d46d4bb41df1ac99f5fcb685fb25c7e61613742d5108b010975a9a6521", size = 444246, upload-time = "2026-03-10T21:30:46.571Z" },
{ url = "https://files.pythonhosted.org/packages/b2/04/7b5705d5b3c0fab088f434f9c83edac1573830ca49ccf29fb83bf7178eec/tornado-6.5.5-cp39-abi3-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl", hash = "sha256:e74c92e8e65086b338fd56333fb9a68b9f6f2fe7ad532645a290a464bcf46be5", size = 447229, upload-time = "2026-03-10T21:30:48.273Z" },
{ url = "https://files.pythonhosted.org/packages/34/01/74e034a30ef59afb4097ef8659515e96a39d910b712a89af76f5e4e1f93c/tornado-6.5.5-cp39-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:435319e9e340276428bbdb4e7fa732c2d399386d1de5686cb331ec8eee754f07", size = 448192, upload-time = "2026-03-10T21:30:51.22Z" },
{ url = "https://files.pythonhosted.org/packages/be/00/fe9e02c5a96429fce1a1d15a517f5d8444f9c412e0bb9eadfbe3b0fc55bf/tornado-6.5.5-cp39-abi3-musllinux_1_2_aarch64.whl", hash = "sha256:3f54aa540bdbfee7b9eb268ead60e7d199de5021facd276819c193c0fb28ea4e", size = 448039, upload-time = "2026-03-10T21:30:53.52Z" },
{ url = "https://files.pythonhosted.org/packages/82/9e/656ee4cec0398b1d18d0f1eb6372c41c6b889722641d84948351ae19556d/tornado-6.5.5-cp39-abi3-musllinux_1_2_x86_64.whl", hash = "sha256:36abed1754faeb80fbd6e64db2758091e1320f6bba74a4cf8c09cd18ccce8aca", size = 447445, upload-time = "2026-03-10T21:30:55.541Z" },
{ url = "https://files.pythonhosted.org/packages/5a/76/4921c00511f88af86a33de770d64141170f1cfd9c00311aea689949e274e/tornado-6.5.5-cp39-abi3-win32.whl", hash = "sha256:dd3eafaaeec1c7f2f8fdcd5f964e8907ad788fe8a5a32c4426fbbdda621223b7", size = 448582, upload-time = "2026-03-10T21:30:57.142Z" },
{ url = "https://files.pythonhosted.org/packages/2c/23/f6c6112a04d28eed765e374435fb1a9198f73e1ec4b4024184f21faeb1ad/tornado-6.5.5-cp39-abi3-win_amd64.whl", hash = "sha256:6443a794ba961a9f619b1ae926a2e900ac20c34483eea67be4ed8f1e58d3ef7b", size = 448990, upload-time = "2026-03-10T21:30:58.857Z" },
{ url = "https://files.pythonhosted.org/packages/b7/c8/876602cbc96469911f0939f703453c1157b0c826ecb05bdd32e023397d4e/tornado-6.5.5-cp39-abi3-win_arm64.whl", hash = "sha256:2c9a876e094109333f888539ddb2de4361743e5d21eece20688e3e351e4990a6", size = 448016, upload-time = "2026-03-10T21:31:00.43Z" },
]
[[package]]
+7 -37
View File
@@ -1,36 +1,16 @@
# LangGraph Prebuilt
[![PyPI - Version](https://img.shields.io/pypi/v/langgraph-prebuilt?label=%20)](https://pypi.org/project/langgraph-prebuilt/#history)
[![PyPI - License](https://img.shields.io/pypi/l/langgraph-prebuilt)](https://opensource.org/licenses/MIT)
[![PyPI - Downloads](https://img.shields.io/pepy/dt/langgraph-prebuilt)](https://pypistats.org/packages/langgraph-prebuilt)
[![Twitter](https://img.shields.io/twitter/url/https/twitter.com/langchain_oss.svg?style=social&label=Follow%20%40LangChain)](https://x.com/langchain_oss)
To help you ship LangGraph apps to production faster, check out [LangSmith](https://www.langchain.com/langsmith).
[LangSmith](https://www.langchain.com/langsmith) is a unified developer platform for building, testing, and monitoring LLM applications.
## Quick Install
```bash
uv add langgraph
```
## 🤔 What is this?
This library defines high-level APIs for creating and executing LangGraph agents and tools. It includes prebuilt components such as `create_react_agent`, `ToolNode`, validation helpers, and Agent Inbox schemas.
## 📖 Documentation
For full documentation, see the [API reference](https://reference.langchain.com/python/langgraph.prebuilt/). For conceptual guides and tutorials, see the [LangGraph Docs](https://docs.langchain.com/oss/python/langgraph/overview).
This library defines high-level APIs for creating and executing LangGraph agents and tools.
> [!IMPORTANT]
> This library is bundled with `langgraph`; most users should install `langgraph` instead of installing `langgraph-prebuilt` directly.
> This library is meant to be bundled with `langgraph`, don't install it directly
## Agents
`langgraph-prebuilt` provides an [implementation](https://reference.langchain.com/python/langgraph.prebuilt/chat_agent_executor/create_react_agent) of a tool-calling ReAct-style agent - `create_react_agent`:
`langgraph-prebuilt` provides an [implementation](https://langchain-ai.github.io/langgraph/reference/prebuilt/#langgraph.prebuilt.chat_agent_executor.create_react_agent) of a tool-calling [ReAct-style](https://langchain-ai.github.io/langgraph/concepts/agentic_concepts/#react-implementation) agent - `create_react_agent`:
```bash
uv add langchain-anthropic
pip install langchain-anthropic
```
```python
@@ -59,7 +39,7 @@ app.invoke(
### ToolNode
`langgraph-prebuilt` provides an [implementation](https://reference.langchain.com/python/langgraph.prebuilt/tool_node/ToolNode) of a node that executes tool calls - `ToolNode`:
`langgraph-prebuilt` provides an [implementation](https://langchain-ai.github.io/langgraph/reference/prebuilt/#langgraph.prebuilt.tool_node.ToolNode) of a node that executes tool calls - `ToolNode`:
```python
from langgraph.prebuilt import ToolNode
@@ -81,7 +61,7 @@ tool_node.invoke({"messages": [ai_message]})
### ValidationNode
`langgraph-prebuilt` provides an [implementation](https://reference.langchain.com/python/langgraph.prebuilt/tool_validator/ValidationNode) of a node that validates tool calls against a pydantic schema - `ValidationNode`:
`langgraph-prebuilt` provides an [implementation](https://langchain-ai.github.io/langgraph/reference/prebuilt/#langgraph.prebuilt.tool_validator.ValidationNode) of a node that validates tool calls against a pydantic schema - `ValidationNode`:
```python
from pydantic import BaseModel, field_validator
@@ -134,14 +114,4 @@ def my_graph_function():
if response['type'] == "response":
# Do something with the response
...
```
## 📕 Releases & Versioning
See our [Releases](https://docs.langchain.com/oss/python/release-policy) and [Versioning](https://docs.langchain.com/oss/python/versioning) policies.
## 💁 Contributing
As an open-source project in a rapidly developing field, we are extremely open to contributions, whether it be in the form of a new feature, improved infrastructure, or better documentation.
For detailed information on how to contribute, see the [Contributing Guide](https://docs.langchain.com/oss/python/contributing/overview).
```
+5 -5
View File
@@ -253,7 +253,7 @@ wheels = [
[[package]]
name = "langchain-core"
version = "1.4.7"
version = "1.4.0"
source = { registry = "https://pypi.org/simple" }
dependencies = [
{ name = "jsonpatch" },
@@ -266,9 +266,9 @@ dependencies = [
{ name = "typing-extensions" },
{ name = "uuid-utils" },
]
sdist = { url = "https://files.pythonhosted.org/packages/ee/2b/fffaff399d20a56d40b9562fa19701e91abd72d8c9d9bc8c2673077b56b6/langchain_core-1.4.7.tar.gz", hash = "sha256:7a825d77de0a3f39adbd9d09612a75e85527e14a52c1601089bcc062972d9f2b", size = 952522, upload-time = "2026-06-12T19:23:57.588Z" }
sdist = { url = "https://files.pythonhosted.org/packages/59/de/679a53472c25860837e32c0442c962fa86e95317a36460e2c9d5c91b17c2/langchain_core-1.4.0.tar.gz", hash = "sha256:1dc341eed802ed9c117c0df3923c991e5e9e226571e5725c194eeb5bd93d1a7f", size = 920260, upload-time = "2026-05-11T18:42:35.919Z" }
wheels = [
{ url = "https://files.pythonhosted.org/packages/de/3e/dcdffa60078ae7b3a00ebb4cbbf1a204a14c3609983c604886523a7d4418/langchain_core-1.4.7-py3-none-any.whl", hash = "sha256:bcadd51951140ecdcba98311dbd931ba5de02a5ba8a2288dad5069c1eea2a13d", size = 554941, upload-time = "2026-06-12T19:23:55.826Z" },
{ url = "https://files.pythonhosted.org/packages/0f/1a/86c38c27b81913a1c6c12448cab55defb5a1097c7dc9a4cea83f55477a2d/langchain_core-1.4.0-py3-none-any.whl", hash = "sha256:23cbbdb46e38ddd1dd5247e6167e96013eae74bea4c5949c550809970a9e565c", size = 548120, upload-time = "2026-05-11T18:42:33.992Z" },
]
[[package]]
@@ -285,7 +285,7 @@ wheels = [
[[package]]
name = "langgraph"
version = "1.2.5"
version = "1.2.4"
source = { editable = "../langgraph" }
dependencies = [
{ name = "langchain-core" },
@@ -298,7 +298,7 @@ dependencies = [
[package.metadata]
requires-dist = [
{ name = "langchain-core", specifier = ">=1.4.7,<2" },
{ name = "langchain-core", specifier = ">=1.4.0,<2" },
{ name = "langgraph-checkpoint", editable = "../checkpoint" },
{ name = "langgraph-prebuilt", editable = "." },
{ name = "langgraph-sdk", editable = "../sdk-py" },
+1 -11
View File
@@ -1,11 +1 @@
# LangGraph JavaScript SDK
Looking for the JS/TS version? Check out [LangGraph.js](https://github.com/langchain-ai/langgraphjs).
## 🤔 What is this?
This package has moved to [langchain-ai/langgraphjs](https://github.com/langchain-ai/langgraphjs/tree/main/libs/sdk).
## 📖 Documentation
For JavaScript and TypeScript documentation, see the [LangGraph.js docs](https://docs.langchain.com/oss/javascript/langgraph/overview).
This repository has been moved to [langchain-ai/langgraphjs](https://github.com/langchain-ai/langgraphjs/tree/main/libs/sdk).
+13 -34
View File
@@ -1,31 +1,18 @@
# LangGraph Python SDK
[![PyPI - Version](https://img.shields.io/pypi/v/langgraph-sdk?label=%20)](https://pypi.org/project/langgraph-sdk/#history)
[![PyPI - License](https://img.shields.io/pypi/l/langgraph-sdk)](https://opensource.org/licenses/MIT)
[![PyPI - Downloads](https://img.shields.io/pepy/dt/langgraph-sdk)](https://pypistats.org/packages/langgraph-sdk)
[![Twitter](https://img.shields.io/twitter/url/https/twitter.com/langchain_oss.svg?style=social&label=Follow%20%40LangChain)](https://x.com/langchain_oss)
To help you ship LangGraph apps to production faster, check out [LangSmith](https://www.langchain.com/langsmith).
[LangSmith](https://www.langchain.com/langsmith) is a unified developer platform for building, testing, and monitoring LLM applications.
## Quick Install
```bash
uv add langgraph-sdk
```
## 🤔 What is this?
This library provides the Python SDK for interacting with the LangGraph API. Use it to connect to a running LangGraph API server, manage assistants and threads, and stream runs from Python applications.
You will need a running LangGraph API server. If you're running a server locally using `langgraph-cli`, the SDK will automatically point at `http://localhost:8123`; otherwise, specify the server URL when creating a client.
## 📖 Documentation
For full documentation, see the [API reference](https://reference.langchain.com/python/langgraph-sdk/). For conceptual guides and tutorials, see the [LangGraph Docs](https://docs.langchain.com/oss/python/langgraph/overview).
This repository contains the Python SDK for interacting with the LangSmith Deployment REST API.
## Quick Start
To get started with the Python SDK, [install the package](https://pypi.org/project/langgraph-sdk/)
```bash
pip install -U langgraph-sdk
```
You will need a running LangGraph API server. If you're running a server locally using `langgraph-cli`, SDK will automatically point at `http://localhost:8123`, otherwise
you would need to specify the server URL when creating a client.
```python
from langgraph_sdk import get_client
@@ -56,7 +43,9 @@ async for chunk in client.runs.stream(thread['thread_id'], agent['assistant_id']
## Thread-Centric Streaming (v3)
`client.threads.stream()` returns a context manager that owns the SSE session for one thread. Typed projections — values snapshots, message streams, tool calls, custom events — all share the same underlying connection.
`client.threads.stream()` returns a context manager that owns the SSE session for one
thread. Typed projections — values snapshots, message streams, tool calls, custom
events — all share the same underlying connection.
```python
from langgraph_sdk import get_client
@@ -84,13 +73,3 @@ async with client.threads.stream(
final = await thread.output # terminal state values
```
## 📕 Releases & Versioning
See our [Releases](https://docs.langchain.com/oss/python/release-policy) and [Versioning](https://docs.langchain.com/oss/python/versioning) policies.
## 💁 Contributing
As an open-source project in a rapidly developing field, we are extremely open to contributions, whether it be in the form of a new feature, improved infrastructure, or better documentation.
For detailed information on how to contribute, see the [Contributing Guide](https://docs.langchain.com/oss/python/contributing/overview).
+5 -5
View File
@@ -266,7 +266,7 @@ wheels = [
[[package]]
name = "langchain-core"
version = "1.4.7"
version = "1.4.0"
source = { registry = "https://pypi.org/simple" }
dependencies = [
{ name = "jsonpatch" },
@@ -279,9 +279,9 @@ dependencies = [
{ name = "typing-extensions" },
{ name = "uuid-utils" },
]
sdist = { url = "https://files.pythonhosted.org/packages/ee/2b/fffaff399d20a56d40b9562fa19701e91abd72d8c9d9bc8c2673077b56b6/langchain_core-1.4.7.tar.gz", hash = "sha256:7a825d77de0a3f39adbd9d09612a75e85527e14a52c1601089bcc062972d9f2b", size = 952522, upload-time = "2026-06-12T19:23:57.588Z" }
sdist = { url = "https://files.pythonhosted.org/packages/59/de/679a53472c25860837e32c0442c962fa86e95317a36460e2c9d5c91b17c2/langchain_core-1.4.0.tar.gz", hash = "sha256:1dc341eed802ed9c117c0df3923c991e5e9e226571e5725c194eeb5bd93d1a7f", size = 920260, upload-time = "2026-05-11T18:42:35.919Z" }
wheels = [
{ url = "https://files.pythonhosted.org/packages/de/3e/dcdffa60078ae7b3a00ebb4cbbf1a204a14c3609983c604886523a7d4418/langchain_core-1.4.7-py3-none-any.whl", hash = "sha256:bcadd51951140ecdcba98311dbd931ba5de02a5ba8a2288dad5069c1eea2a13d", size = 554941, upload-time = "2026-06-12T19:23:55.826Z" },
{ url = "https://files.pythonhosted.org/packages/0f/1a/86c38c27b81913a1c6c12448cab55defb5a1097c7dc9a4cea83f55477a2d/langchain_core-1.4.0-py3-none-any.whl", hash = "sha256:23cbbdb46e38ddd1dd5247e6167e96013eae74bea4c5949c550809970a9e565c", size = 548120, upload-time = "2026-05-11T18:42:33.992Z" },
]
[[package]]
@@ -298,7 +298,7 @@ wheels = [
[[package]]
name = "langgraph"
version = "1.2.5"
version = "1.2.4"
source = { editable = "../langgraph" }
dependencies = [
{ name = "langchain-core" },
@@ -311,7 +311,7 @@ dependencies = [
[package.metadata]
requires-dist = [
{ name = "langchain-core", specifier = ">=1.4.7,<2" },
{ name = "langchain-core", specifier = ">=1.4.0,<2" },
{ name = "langgraph-checkpoint", editable = "../checkpoint" },
{ name = "langgraph-prebuilt", editable = "../prebuilt" },
{ name = "langgraph-sdk", editable = "." },