Skip to main content

Firestore runtime implementation for LangGraph.

Project description

LangGraph Runtime Firestore

License Python 3.11+

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

  1. Create a Google Cloud project
  2. Enable the Firestore API
  3. Create a service account and download the credentials JSON file
  4. 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

langgraph_runtime_firestore-1.0.4.tar.gz (142.8 kB view details)

Uploaded Source

Built Distribution

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

langgraph_runtime_firestore-1.0.4-py3-none-any.whl (49.8 kB view details)

Uploaded Python 3

File details

Details for the file langgraph_runtime_firestore-1.0.4.tar.gz.

File metadata

File hashes

Hashes for langgraph_runtime_firestore-1.0.4.tar.gz
Algorithm Hash digest
SHA256 9f2c92628f6140955ebb5168b54d9a806cdaab6535efee16264acc785cdf7eec
MD5 2d3adad4f5be80f0e3128f46e41bcb70
BLAKE2b-256 4521e5eed723f92978122d045f6751eb3f539d0639149af649560163af0ac973

See more details on using hashes here.

File details

Details for the file langgraph_runtime_firestore-1.0.4-py3-none-any.whl.

File metadata

File hashes

Hashes for langgraph_runtime_firestore-1.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 a299464d10ae74552c7ec3a243a46ee6a80b730b573ccc1aa9baae58e88af04f
MD5 bb326b79b31dd750bfa7a827551cfc9a
BLAKE2b-256 6e22f47ab79f60bf247ed28e0a4103d7883c092383720b6087cf8be8992f31ae

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