Skip to main content

State-of-the-art Azure Cosmos DB checkpointer for LangGraph

Project description

langgraph-cosmosdb-checkpointer

State-of-the-art Azure Cosmos DB checkpointer implementation for LangGraph with:

  • strict config semantics (thread_id, checkpoint_ns, checkpoint_id)
  • deterministic/idempotent put_writes ordering rules
  • optimistic concurrency handling for special writes
  • payload guardrails for Cosmos 2MB item limit (compression + chunking)

Install

pip install langgraph-cosmosdb-checkpointer

Usage

from langgraph_cosmosdb_checkpointer import CosmosDBSaver, CosmosDBSettings

settings = CosmosDBSettings(
    database_name="langgraph",
    checkpoint_container_name="checkpoints",
    writes_container_name="writes",
    blob_container_name="checkpoint_blobs",
)

saver = CosmosDBSaver.from_endpoint(
    endpoint="https://<account>.documents.azure.com:443/",
    credential="<account-key>",
    settings=settings,
)

You can also use AsyncCosmosDBSaver for async graph execution.

By default (create_containers=True), the saver creates the database and containers automatically if they don't exist.

Cosmos DB indexing policy

The writes container must have a composite index to support the multi-field sort used when loading pending writes:

ORDER BY c.task_id ASC, c.idx ASC

If you create the container using this library, it will include the required composite index. If the container already exists, Cosmos DB will keep the existing indexing policy (i.e., create_container_if_not_exists(...) will not update it), so you must update the container indexing policy in Azure or recreate the container.

Azure AD / Entra ID authentication

from_endpoint supports DefaultAzureCredential for Azure AD auth:

from azure.identity import DefaultAzureCredential
from langgraph_cosmosdb_checkpointer import CosmosDBSaver

saver = CosmosDBSaver.from_endpoint(
    endpoint="https://<account>.documents.azure.com:443/",
    credential=DefaultAzureCredential(),
)

If credential is omitted, from_endpoint will use DefaultAzureCredential() automatically.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

langgraph_cosmosdb_checkpointer-1.0.0.tar.gz (22.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

langgraph_cosmosdb_checkpointer-1.0.0-py3-none-any.whl (12.7 kB view details)

Uploaded Python 3

File details

Details for the file langgraph_cosmosdb_checkpointer-1.0.0.tar.gz.

File metadata

File hashes

Hashes for langgraph_cosmosdb_checkpointer-1.0.0.tar.gz
Algorithm Hash digest
SHA256 3d0cc160f9598fa5164dd27a8d3d86a26cbe33819ce27dcae0829cd9e6e9439e
MD5 626f38f90cdc6c0b44598e449a4d89f7
BLAKE2b-256 015b0a7f94d3459d9befdc08321a314b81425b4aee4630665d71753f81b4f5e4

See more details on using hashes here.

File details

Details for the file langgraph_cosmosdb_checkpointer-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for langgraph_cosmosdb_checkpointer-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2566da46d7159f0d52573a791d92cadf36cd311f57b5824f682dac9882d8236b
MD5 a66d23d18f6f59d4728d1c5e8f173a7d
BLAKE2b-256 f5b8f1d2b4ccf819b6f5ea336fa05d00617e14dedd10e0250c6e0eee444d6371

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page