-
Notifications
You must be signed in to change notification settings - Fork 651
add cosmos db sample for checkpointer #1313
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
add cosmos db sample for checkpointer #1313
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds documentation for using Azure Cosmos DB as a checkpoint saver for LangChain agents, providing an alternative to the existing PostgreSQL example.
Key changes:
- Added installation instructions and Python code example for the
langgraph-checkpoint-cosmosdbpackage - Included configuration details for authentication and database/container setup
- Added a note about sync/async support and RBAC credentials
| checkpointer = CosmosDBSaver( # [!code highlight] | ||
| database_name="your_database", # [!code highlight] | ||
| container_name="your_container" # [!code highlight] | ||
| ) # [!code highlight] | ||
|
|
||
| agent = create_agent( | ||
| "gpt-5", | ||
| [get_user_info], | ||
| checkpointer=checkpointer, # [!code highlight] | ||
| ) |
Copilot
AI
Nov 6, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Cosmos DB example should follow the same pattern as the PostgreSQL example above (lines 92-98) by using a context manager. Consider wrapping the CosmosDBSaver initialization in a with statement to ensure proper resource cleanup, unless the CosmosDBSaver doesn't support context managers.
| checkpointer = CosmosDBSaver( # [!code highlight] | |
| database_name="your_database", # [!code highlight] | |
| container_name="your_container" # [!code highlight] | |
| ) # [!code highlight] | |
| agent = create_agent( | |
| "gpt-5", | |
| [get_user_info], | |
| checkpointer=checkpointer, # [!code highlight] | |
| ) | |
| with CosmosDBSaver( # [!code highlight] | |
| database_name="your_database", # [!code highlight] | |
| container_name="your_container" # [!code highlight] | |
| ) as checkpointer: # [!code highlight] | |
| agent = create_agent( | |
| "gpt-5", | |
| [get_user_info], | |
| checkpointer=checkpointer, # [!code highlight] | |
| ) |
| <Note> | ||
| Azure Cosmos DB checkpointer supports both sync and async operations. If the database and container already exist, you can use default RBAC credentials (e.g., `az login`) instead of setting the endpoint and key. | ||
| </Note> | ||
| ::: | ||
|
|
||
|
|
Copilot
AI
Nov 6, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The note is placed inside the :::python block, which means it will only appear in the Python-specific documentation. Since this is general information about Azure Cosmos DB (not Python-specific), consider placing it outside the :::python block to ensure it appears in all documentation versions.
| <Note> | |
| Azure Cosmos DB checkpointer supports both sync and async operations. If the database and container already exist, you can use default RBAC credentials (e.g., `az login`) instead of setting the endpoint and key. | |
| </Note> | |
| ::: | |
| ::: | |
| <Note> | |
| Azure Cosmos DB checkpointer supports both sync and async operations. If the database and container already exist, you can use default RBAC credentials (e.g., `az login`) instead of setting the endpoint and key. | |
| </Note> |
Overview
added cosmos db sample for checkpointer in short term memory section
Type of change
Update existing documentation
Related issues/PRs
N/A
Checklist
docs devsrc/docs.jsonif neededAdditional notes
There are actually many checkpointer store implementations now: https://pypi.org/search/?q=langgraph-checkpoint. Perhaps this doc could further be revised to make that clear. However, I cannot comment authoritatively on those (I am PM in Cosmos DB engineering team). so just adding the Cosmos DB sample in addition to the existing Postgres sample.