Skip to main content

Langgraph S3 Checkpoint Persistant Memory

Project description

LangGraph S3 Checkpoint

A Python package that provides S3 storage capabilities for LangGraph checkpoints. This package implements the BaseCheckpointSaver interface from LangGraph to allow storing and retrieving checkpoints from Amazon S3.

Installation

You can install the package directly from PyPI:

pip install langgraph-s3-checkpointer

Or using uv:

uv pip install langgraph-s3-checkpointer

Requirements

  • Python 3.8+
  • boto3
  • langgraph

Usage

Basic Usage

from s3checkpointer.s3saver import S3CheckpointSaver
from langgraph.graph import StateGraph

# Initialize the S3 checkpoint saver
s3_saver = S3CheckpointSaver(
    bucket_name="my-langgraph-checkpoints",
    prefix="my-app",  # Optional prefix for S3 keys
    # AWS credentials (optional if using environment variables or IAM roles)
    aws_access_key_id="YOUR_ACCESS_KEY",  
    aws_secret_access_key="YOUR_SECRET_KEY",
    region_name="us-east-1"
)

# Create a LangGraph with the S3 checkpoint saver
builder = StateGraph(checkpointer=s3_saver)

# ... define your graph nodes and edges ...

# Build the graph
graph = builder.compile()

# The graph will now use S3 for checkpoint storage

Using with Environment Variables

You can also configure AWS credentials using environment variables:

import os
from s3checkpointer.s3saver import S3CheckpointSaver

# Set AWS credentials in environment variables
os.environ["AWS_ACCESS_KEY_ID"] = "YOUR_ACCESS_KEY"
os.environ["AWS_SECRET_ACCESS_KEY"] = "YOUR_SECRET_KEY"
os.environ["AWS_REGION"] = "us-east-1"

# Initialize without explicit credentials
s3_saver = S3CheckpointSaver(
    bucket_name="my-langgraph-checkpoints",
    prefix="my-app"
)

Configuration Options

The S3CheckpointSaver class accepts the following parameters:

Parameter Type Required Description
bucket_name str Yes The name of the S3 bucket to store checkpoints
prefix str No A prefix to use for all keys in the bucket (default: "")
aws_access_key_id str No AWS access key ID (default: None, read from environment)
aws_secret_access_key str No AWS secret access key (default: None, read from environment)
region_name str No AWS region name (default: None, read from environment)

Features

  • Store and retrieve LangGraph checkpoints in Amazon S3
  • Automatic bucket creation if it doesn't exist
  • Efficient batch deletion of checkpoints
  • Support for checkpoint metadata
  • Thread-based organization of checkpoints

Testing

To run the tests:

# Install test dependencies
pip install pytest moto

# Run tests
pytest tests/

License

MIT License

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

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_s3_checkpointer-0.1.0.tar.gz (7.6 kB view details)

Uploaded Source

Built Distribution

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

langgraph_s3_checkpointer-0.1.0-py3-none-any.whl (6.4 kB view details)

Uploaded Python 3

File details

Details for the file langgraph_s3_checkpointer-0.1.0.tar.gz.

File metadata

File hashes

Hashes for langgraph_s3_checkpointer-0.1.0.tar.gz
Algorithm Hash digest
SHA256 c090ee596853724e25ce75c69b0ff4bfabd7059bcfa5b1cb9ca35ca73643a6b2
MD5 99a678e2b5714990a725cbd4a6539aef
BLAKE2b-256 c1e35f5835d6d39327d1e5e85efad25cd94cd4ec925c931ff690015c524525e8

See more details on using hashes here.

File details

Details for the file langgraph_s3_checkpointer-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for langgraph_s3_checkpointer-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e0a7250ae296168821bd7ab84e515bfd91846ee8b830e2851284a92f6dac1886
MD5 c2b19b9af6013b30cf314c29f815eb77
BLAKE2b-256 98dc14659fc35e2f418449443128210f47525d33c573a98045b58116a3747d31

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