Firestore runtime implementation for LangGraph.
Project description
LangGraph Runtime Firestore
A Firestore-based runtime implementation for LangGraph, providing persistent storage and state management for LangGraph applications using Google Cloud Firestore.
Features
- Firestore Backend: Uses Google Cloud Firestore for persistent storage of threads, runs, and assistants
- Thread Management: Create, update, and manage conversation threads with full state persistence
- Run Execution: Execute LangGraph runs with automatic state checkpointing
- Assistant Support: Manage AI assistants with versioned configurations
- Real-time Streaming: Stream run outputs and state updates in real-time
- Background Queue: Built-in task queue for async run execution
- State Snapshots: Retrieve and update thread state at any point in time
Installation
pip install langgraph-runtime-firestore
Prerequisites
- Python 3.11 or higher
- A Google Cloud project with Firestore enabled
- Firebase service account credentials
Quick Start
1. Set up Firestore
- Create a Google Cloud project
- Enable the Firestore API
- Create a service account and download the credentials JSON file
- Set the environment variables:
export FIRESTORE_CREDENTIALS_PATH=/path/to/your/credentials.json
export FIRESTORE_PROJECT_ID=your-gcp-project-id
2. Use in your application
from starlette.applications import Starlette
from langgraph_runtime_firestore import lifespan
# Create your ASGI application with Firestore runtime
app = Starlette(lifespan=lifespan)
3. Run with LangGraph CLI
langgraph dev
Configuration
Required Environment Variables
| Variable | Description |
|---|---|
FIRESTORE_CREDENTIALS_PATH |
Path to your Firebase service account credentials JSON file |
FIRESTORE_PROJECT_ID |
Your Google Cloud project ID |
Optional Environment Variables
| Variable | Default | Description |
|---|---|---|
LANGGRAPH_DISABLE_FILE_PERSISTENCE |
false |
Disable local file caching |
N_JOBS_PER_WORKER |
(varies) | Number of concurrent jobs per worker |
Architecture
This runtime implements the LangGraph Runtime API with Firestore as the backend:
- Threads: Stored in
users/{user}/threads/{thread_id}collection - Runs: Stored in memory with metadata synced to Firestore
- Assistants: Stored in
assistants/{assistant_id}collection - Checkpoints: Managed through the checkpoint module with optional Firestore persistence
- Streaming: In-memory queue-based streaming with message persistence
Development
Setup
# Clone the repository
git clone https://github.com/MarcoFurrer/langgraph_runtime_firestore.git
cd langgraph_runtime_firestore
# Install in development mode
pip install -e ".[dev]"
Code Quality
# Check code style
make lint
# Auto-fix linting issues
make format
Project Structure
langgraph_runtime_firestore/
├── checkpoint.py # Checkpoint management
├── database.py # Firestore connection & initialization
├── ops.py # Core operations (Threads, Runs, Assistants)
├── store.py # Store implementation
├── queue.py # Background task queue
├── serialize.py # Firestore serialization utilities
├── firestore_stream.py # Streaming infrastructure
├── lifespan.py # Application lifecycle management
├── retry.py # Retry logic for DB operations
└── metrics.py # Metrics collection
Contributing
Contributions are welcome! Please see CONTRIBUTING.md for guidelines.
License
This project is licensed under the Elastic License 2.0. See LICENSE for details.
Acknowledgments
This runtime was originally developed from langgraph_runtime_inmem and adapted for Firestore integration.
Support
For issues, questions, or contributions, please open an issue on the GitHub repository.
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file langgraph_runtime_firestore-1.0.3.tar.gz.
File metadata
- Download URL: langgraph_runtime_firestore-1.0.3.tar.gz
- Upload date:
- Size: 138.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4067bbe7d053e18c992e078c93903bc57e9c6a43f9636d2fa20b86be08f8bdca
|
|
| MD5 |
615f33a62ba6e7b54edb42bb8731e33b
|
|
| BLAKE2b-256 |
ffbdc6f07e47313dbd345e3abd526c1b185486c73b223e9d45f1d4847208ee46
|
File details
Details for the file langgraph_runtime_firestore-1.0.3-py3-none-any.whl.
File metadata
- Download URL: langgraph_runtime_firestore-1.0.3-py3-none-any.whl
- Upload date:
- Size: 44.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
86d0a9113b9588e7d5d77ce0f83792dbd9d29bec4463e874ecb8dd1f7f8bd2b0
|
|
| MD5 |
541230dcb2e684e7a3a7c9cd9c2da01b
|
|
| BLAKE2b-256 |
7ba0f4561c98ab930bdf47096a07cbfa3bd450edd9d6a26b48438d5081470b1c
|