[PR #6859] Adding support for cosmosdb checkpointer #5348

Open
opened 2026-02-20 17:51:35 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/langchain-ai/langgraph/pull/6859

State: open
Merged: No


Add CosmosDB Checkpointer to Official LangGraph Repository

Description

Adopting the community-created CosmosDB checkpoint implementation by @skamalj into the official LangGraph repository. This brings Azure CosmosDB support alongside the existing PostgreSQL and SQLite checkpoint implementations, making it more discoverable for users.

Background

The CosmosDB checkpointer was originally developed by @skamalj as a community project at skamalj/langgraph_checkpoint_cosmosdb. It provides a fully-featured checkpoint implementation for Azure CosmosDB, allowing LangGraph applications to persist state in Azure's globally distributed database service.

Integration Changes

To align with the official LangGraph checkpoint architecture patterns (used in checkpoint-postgres and checkpoint-sqlite), we've made the following updates:

Architecture:

  • Split implementation into base.py (sync) and aio.py (async)
  • CosmosDBSaver - Synchronous implementation using azure.cosmos.CosmosClient
  • AsyncCosmosDBSaver - Native async implementation using azure.cosmos.aio.CosmosClient
  • Follows the same patterns as PostgreSQL and SQLite checkpointers for consistency

Features:

  • Full checkpoint CRUD operations (put, get, list)
  • Support for checkpoint writes and pending writes
  • Both key-based authentication and Azure RBAC/Managed Identity
  • Synchronous and asynchronous implementations
  • Thread-safe operations
  • Base64 encoding for binary data compatibility with CosmosDB

Files Added:

  • libs/checkpoint-cosmosdb/langgraph/checkpoint/cosmosdb/base.py - sync implementation
  • libs/checkpoint-cosmosdb/langgraph/checkpoint/cosmosdb/aio.py - async implementation
  • libs/checkpoint-cosmosdb/langgraph/checkpoint/cosmosdb/__init__.py - package exports
  • libs/checkpoint-cosmosdb/tests/test_cosmosdb.py - test suite
  • libs/checkpoint-cosmosdb/README.md - usage documentation
  • libs/checkpoint-cosmosdb/pyproject.toml - package configuration

Usage

Synchronous:

from langgraph.checkpoint.cosmosdb import CosmosDBSaver

checkpointer = CosmosDBSaver(
    database_name="your_database",
    container_name="your_container"
)

Asynchronous:

from langgraph.checkpoint.cosmosdb import AsyncCosmosDBSaver

async with AsyncCosmosDBSaver.from_conn_info(
    endpoint="https://your-account.documents.azure.com:443/",
    key="your_key",
    database_name="your_database",
    container_name="your_container"
) as checkpointer:
    await checkpointer.aput(config, checkpoint, metadata, versions)

Testing

  • All imports working correctly
  • Ruff linting passes
  • Mypy type checking passes
  • Test suite included (requires COSMOSDB_ENDPOINT env var to run)

Credits

Huge thanks to @skamalj (Kamal) for creating this implementation! This work originated from his community project and we're grateful for his contribution to the LangGraph ecosystem. All original contributions have been preserved in the git history.

Impact

This addition expands LangGraph's checkpoint storage options to include Azure CosmosDB, making it easier for teams already using Azure to adopt LangGraph without additional infrastructure setup.

**Original Pull Request:** https://github.com/langchain-ai/langgraph/pull/6859 **State:** open **Merged:** No --- # Add CosmosDB Checkpointer to Official LangGraph Repository ## Description Adopting the community-created [CosmosDB checkpoint](https://github.com/skamalj/langgraph_checkpoint_cosmosdb/tree/main) implementation by [@skamalj](https://github.com/skamalj) into the official LangGraph repository. This brings Azure CosmosDB support alongside the existing PostgreSQL and SQLite checkpoint implementations, making it more discoverable for users. ## Background The CosmosDB checkpointer was originally developed by [@skamalj](https://github.com/skamalj) as a community project at [skamalj/langgraph_checkpoint_cosmosdb](https://github.com/skamalj/langgraph_checkpoint_cosmosdb). It provides a fully-featured checkpoint implementation for Azure CosmosDB, allowing LangGraph applications to persist state in Azure's globally distributed database service. ## Integration Changes To align with the official LangGraph checkpoint architecture patterns (used in `checkpoint-postgres` and `checkpoint-sqlite`), we've made the following updates: **Architecture:** - Split implementation into `base.py` (sync) and `aio.py` (async) - `CosmosDBSaver` - Synchronous implementation using `azure.cosmos.CosmosClient` - `AsyncCosmosDBSaver` - Native async implementation using `azure.cosmos.aio.CosmosClient` - Follows the same patterns as PostgreSQL and SQLite checkpointers for consistency **Features:** - ✅ Full checkpoint CRUD operations (put, get, list) - ✅ Support for checkpoint writes and pending writes - ✅ Both key-based authentication and Azure RBAC/Managed Identity - ✅ Synchronous and asynchronous implementations - ✅ Thread-safe operations - ✅ Base64 encoding for binary data compatibility with CosmosDB **Files Added:** - `libs/checkpoint-cosmosdb/langgraph/checkpoint/cosmosdb/base.py` - sync implementation - `libs/checkpoint-cosmosdb/langgraph/checkpoint/cosmosdb/aio.py` - async implementation - `libs/checkpoint-cosmosdb/langgraph/checkpoint/cosmosdb/__init__.py` - package exports - `libs/checkpoint-cosmosdb/tests/test_cosmosdb.py` - test suite - `libs/checkpoint-cosmosdb/README.md` - usage documentation - `libs/checkpoint-cosmosdb/pyproject.toml` - package configuration ## Usage **Synchronous:** ```python from langgraph.checkpoint.cosmosdb import CosmosDBSaver checkpointer = CosmosDBSaver( database_name="your_database", container_name="your_container" ) ``` **Asynchronous:** ```python from langgraph.checkpoint.cosmosdb import AsyncCosmosDBSaver async with AsyncCosmosDBSaver.from_conn_info( endpoint="https://your-account.documents.azure.com:443/", key="your_key", database_name="your_database", container_name="your_container" ) as checkpointer: await checkpointer.aput(config, checkpoint, metadata, versions) ``` ## Testing - ✅ All imports working correctly - ✅ Ruff linting passes - ✅ Mypy type checking passes - ✅ Test suite included (requires `COSMOSDB_ENDPOINT` env var to run) ## Credits **Huge thanks to [@skamalj (Kamal)](https://github.com/skamalj)** for creating this implementation! This work originated from his community project and we're grateful for his contribution to the LangGraph ecosystem. All original contributions have been preserved in the git history. ## Impact This addition expands LangGraph's checkpoint storage options to include Azure CosmosDB, making it easier for teams already using Azure to adopt LangGraph without additional infrastructure setup.
yindo added the pull-request label 2026-02-20 17:51:35 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langchain-ai/langgraph#5348