Skip to content

AbdulmalikDS/langgraph-runtime-inmem-open

Repository files navigation

LangGraph Runtime InMem Open - Robot Parrot Logo

LangGraph Runtime InMem Open Source Alternative

License: MIT Python 3.8+ Version Tests

What is This?

LangGraph Runtime InMem Open is a 100% open-source alternative to the closed-source langgraph-runtime-inmem package. Created by Abdulmalik Alquwayfili, this project addresses critical supply-chain security issues while providing the same functionality as the original.

The Problem

The original langgraph-runtime-inmem package has several limitations:

  • Closed-source - No public repository or code review available
  • PyPI-only distribution - Creates supply-chain security risks
  • Not auditable - Cannot verify security or functionality
  • Not transparent - Cannot see what the code actually does

This affects security auditing, Nixpkgs integration, community contributions, and transparency.

Our Solution

This open-source alternative provides:

  • 100% open source with MIT license
  • Publicly hosted on GitHub with full history
  • Fully auditable source code
  • Community-driven development
  • Drop-in replacement with the same API
  • Ready for Nixpkgs integration

Features

Core Functionality

  • InMemoryStore - High-performance in-memory key-value store with namespace support
  • MemorySaver - In-memory checkpoint saver for LangGraph state management
  • DiskBackedInMemStore - Optional disk persistence for data durability
  • Async Support - Full async/await compatibility
  • Context Managers - Safe checkpoint operations with automatic cleanup

Compatibility

  • Drop-in replacement for langgraph-runtime-inmem
  • Compatible with langgraph-cli[inmem]
  • Ready for Nixpkgs integration
  • Cross-platform support (Windows, macOS, Linux)

Performance

  • Sub-millisecond response times for in-memory operations
  • Optimized data structures and memory management
  • Handles thousands of concurrent operations
  • Minimal memory footprint

Installation

From GitHub (Recommended for Nixpkgs)

git clone https://github.com/AbdulmalikDS/langgraph-runtime-inmem-open.git
cd langgraph-runtime-inmem-open
pip install -e .

Development Setup

git clone https://github.com/AbdulmalikDS/langgraph-runtime-inmem-open.git
cd langgraph-runtime-inmem-open
pip install -e ".[dev]"

Nixpkgs Integration

langgraph-runtime-inmem-open = python3Packages.buildPythonPackage rec {
  pname = "langgraph-runtime-inmem-open";
  version = "0.1.0";
  src = fetchFromGitHub {
    owner = "AbdulmalikDS";
    repo = "langgraph-runtime-inmem-open";
    rev = "v${version}";
    sha256 = "...";
  };
  propagatedBuildInputs = with python3Packages; [
    langgraph
    pydantic
  ];
  doCheck = true;
  checkInputs = with python3Packages; [
    pytest
    pytest-cov
    pytest-asyncio
  ];
  pythonImportsCheck = [ "langgraph_runtime_inmem_open" ];
};

Usage Examples

Basic Store Operations

from langgraph_runtime_inmem_open import InMemoryStore

# Create a store instance
store = InMemoryStore()

# Store data with namespace
store.put(("users", "123"), "preferences", {
    "theme": "dark",
    "language": "en",
    "notifications": True
})

# Retrieve data
prefs = store.get(("users", "123"), "preferences")
print(prefs)

# Search data with filters
dark_theme_users = store.search(("users",), filter={"theme": "dark"})

# List all namespaces
namespaces = store.list_namespaces()

# Delete data
store.delete(("users", "123"), "preferences")

Checkpoint Operations

from langgraph_runtime_inmem_open import MemorySaver

# Create a checkpoint saver
saver = MemorySaver()

# Save a checkpoint
checkpoint_data = {
    "state": "running",
    "step": 5,
    "data": {"key": "value"},
    "timestamp": "2024-01-15T10:30:00Z"
}
saver.put("thread-123", checkpoint_data)

# Load a checkpoint
loaded_data = saver.get("thread-123")

# List all threads
threads = saver.list_threads()

# Use context manager for safe operations
with saver as ctx:
    ctx.save({"test": "data"})
    loaded = ctx.load()

LangGraph Integration

from langgraph_runtime_inmem_open import InMemoryStore, MemorySaver
from langgraph.graph import StateGraph

# Use our implementation with LangGraph
store = InMemoryStore()
saver = MemorySaver()

# Create a graph with our checkpoint saver
graph = StateGraph(state_schema=YourState)
graph = graph.compile(checkpointer=saver)

Advanced Usage with Disk Persistence

from langgraph_runtime_inmem_open import DiskBackedMemorySaver

# Create a disk-backed saver for persistence
saver = DiskBackedMemorySaver(persist_path="./checkpoints")

# Data will be automatically saved to disk
saver.put("important-thread", {"critical": "data"})

# Data persists across process restarts

Testing

Run the Test Suite

# Run all tests
pytest tests/

# Run with coverage
pytest tests/ --cov=langgraph_runtime_inmem_open --cov-report=html

# Run specific test file
pytest tests/test_store.py -v

Performance Benchmarks

Operation Items Time Performance
Insert 1,000 ~0.002s 500,000 ops/sec
Retrieve 1,000 ~0.001s 1,000,000 ops/sec
Search 1,000 ~0.003s 333,333 ops/sec
Checkpoint Save 100 ~0.001s 100,000 ops/sec
Checkpoint Load 100 ~0.001s 100,000 ops/sec

Benchmarks run on typical development hardware (Intel i7, 16GB RAM)

Migration Guide

From Closed-Source Package

# Before (closed-source)
from langgraph_runtime_inmem import InMemoryStore, MemorySaver

# After (open-source)
from langgraph_runtime_inmem_open import InMemoryStore, MemorySaver

# Same API, same functionality

Nixpkgs Migration

# Before
langgraph-cli = python3Packages.buildPythonPackage rec {
  propagatedBuildInputs = with python3Packages; [
    # langgraph-runtime-inmem  # Closed source, supply-chain risk
  ];
};

# After
langgraph-cli = python3Packages.buildPythonPackage rec {
  propagatedBuildInputs = with python3Packages; [
    langgraph-runtime-inmem-open  # Open source, auditable
  ];
};

Related Issues

This project addresses several community concerns:

  • LangGraph Issue #5802 - Closed-source dependency problem
  • Nixpkgs Issue #430234 - Supply-chain risk documentation

License

This project is licensed under the MIT License. See the LICENSE file for details.

Acknowledgments

  • LangChain Team for creating the LangGraph framework
  • Nixpkgs Community for highlighting supply-chain security issues
  • Open Source Community for the tools and libraries used in this project

Support

About

Open-source alternative to langgraph-runtime-inmem

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors