Skip to main content

Drop-in state backend for LangGraph, CrewAI & custom agent loops — Rust core, framework-agnostic, built for production.

Project description

swarmstate

Drop-in state backend for LangGraph, CrewAI & custom agent loops - Rust core, framework-agnostic, built for production.

~12.8× faster checkpoint writes than SqliteSaver on LangGraph's interface, and O(1) state snapshots (hundreds of thousands× faster than a deepcopy on large state). Reproducible numbers → swarmstate.github.io/benchmarks.

swarmstate is a state and checkpointing backend with a Rust core and a Python API for multi-agent systems. It does not compete with visible agent frameworks; it acts as low-level infrastructure - much like engines such as DuckDB, ClickHouse, Arrow, or Polars sit underneath data applications without replacing them.

It solves three production pains:

  1. State lock-in across frameworks - a framework-agnostic store so migrating frameworks doesn't lose state.
  2. Checkpointing cost and latency - a Rust-backed implementation of LangGraph's checkpointer interface.
  3. Deterministic routing paid for in tokens - a native handoff graph that resolves rule-based transitions in microseconds.

Installation

pip install swarmstate            # prebuilt abi3 wheels, no compiler required
uv add swarmstate                 # or with uv

Optional extras: swarmstate[langgraph], swarmstate[crewai], swarmstate[redis], swarmstate[all].

Usage

import swarmstate as ss

store = ss.Store()                              # in-memory, msgpack codec
store.set("workflow", "onboarding", {"step": 3, "data": {...}})
snap = store.snapshot()                          # cheap, immutable snapshot
store.set("workflow", "onboarding", {"step": 4})
store.restore(snap)                              # rollback
store.get("workflow", "onboarding")              # -> {"step": 3, "data": {...}}

snap2 = store.snapshot()
snap2.diff(snap)                                 # {"added": [...], "removed": [...], "changed": [...]}

# Deterministic, LLM-free routing (resolved natively in Rust)
g = ss.HandoffGraph()
g.add_edge("triage", "billing", when="category == 'billing'")
g.add_edge("triage", "human")                    # unconditional default
g.route("triage", {"category": "billing"})       # -> "billing"

Drop-in LangGraph checkpointer (pip install "swarmstate[langgraph]"):

from swarmstate.integrations.langgraph import SwarmStateSaver

graph = builder.compile(checkpointer=SwarmStateSaver())   # replaces SqliteSaver, 1 line

Status

Early development.

  • M0 (scaffolding) ✅ - Rust core builds; import swarmstate works.
  • M1 (Rust store) ✅ - concurrent KV store, msgpack codec, O(1) immutable snapshots, incremental diffs, GIL released on hot paths.
  • M2 (HandoffGraph) ✅ - deterministic conditional routing with a safe Rust condition evaluator (no eval), cycle detection.
  • M3 (LangGraph adapter) ✅ - SwarmStateSaver, a drop-in BaseCheckpointSaver backed by the Store; snapshot/roll back the whole checkpoint DB at once.
  • M4 (Benchmarks) ✅ - SwarmStateSaver.put ~12.8× faster than SqliteSaver; Store.snapshot() is O(1) (hundreds of thousands× faster than deep-copying large state). Reproducible: benchmarks/run.py; charts & tables in the docs.
  • M5 (CrewAI adapter + Redis backend) ✅ - RedisStore and a SQLite DiskStore (both persistent, msgpack wire-format, drop-in checkpointer backends) plus SwarmStateStorage (CrewAI-compatible memory backed by a shared Store).
  • M6 (docs · wheels · PyPI) ✅ - full docs site, benchmarks, cross-platform abi3 wheels, and PyPI publishing via Trusted Publishing (OIDC).

Development

python -m venv .venv && source .venv/bin/activate
pip install maturin pytest
maturin develop --release     # compile the Rust core and install it locally
cargo test                    # Rust core tests
pytest -q                     # Python API tests

License

MIT

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

swarmstate-0.7.0.tar.gz (72.8 kB view details)

Uploaded Source

Built Distributions

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

swarmstate-0.7.0-cp39-abi3-win_amd64.whl (250.5 kB view details)

Uploaded CPython 3.9+Windows x86-64

swarmstate-0.7.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (371.2 kB view details)

Uploaded CPython 3.9+manylinux: glibc 2.17+ x86-64

swarmstate-0.7.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (367.8 kB view details)

Uploaded CPython 3.9+manylinux: glibc 2.17+ ARM64

swarmstate-0.7.0-cp39-abi3-macosx_11_0_arm64.whl (345.4 kB view details)

Uploaded CPython 3.9+macOS 11.0+ ARM64

swarmstate-0.7.0-cp39-abi3-macosx_10_12_x86_64.whl (359.5 kB view details)

Uploaded CPython 3.9+macOS 10.12+ x86-64

File details

Details for the file swarmstate-0.7.0.tar.gz.

File metadata

  • Download URL: swarmstate-0.7.0.tar.gz
  • Upload date:
  • Size: 72.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for swarmstate-0.7.0.tar.gz
Algorithm Hash digest
SHA256 af2b6b6a10427c7a1c80e79b58722b76b0831a49d018aebc06656938da11eeb3
MD5 a318ff317550cad106f652ade3014b6d
BLAKE2b-256 de3096b57fe2278bb639ea09ebf725b849abe1dc5f08dc222de0ecd736933347

See more details on using hashes here.

Provenance

The following attestation bundles were made for swarmstate-0.7.0.tar.gz:

Publisher: release.yml on swarmstate/swarmstate

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file swarmstate-0.7.0-cp39-abi3-win_amd64.whl.

File metadata

  • Download URL: swarmstate-0.7.0-cp39-abi3-win_amd64.whl
  • Upload date:
  • Size: 250.5 kB
  • Tags: CPython 3.9+, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for swarmstate-0.7.0-cp39-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 6a73b602b1eafe25e8cda487f3652029fba045bc2166fad3913a3207e0cb66e3
MD5 5ba2f82b2128cb399f54a819d27b35c4
BLAKE2b-256 8aaf79b92bcb11475f4008503679a37c19ce455295e2c6f6bf799848aefd05c9

See more details on using hashes here.

Provenance

The following attestation bundles were made for swarmstate-0.7.0-cp39-abi3-win_amd64.whl:

Publisher: release.yml on swarmstate/swarmstate

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file swarmstate-0.7.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for swarmstate-0.7.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 131ecb09969eaea9dde1dac03ef0a5ee2d06a190054f225624dc1d63bdefc6d1
MD5 492ceac4f5415694cf7607b79ca3c9d3
BLAKE2b-256 94c2115f5499e3975cc73819d1f6c3532168e3d8abc80ace6a275e027a12588c

See more details on using hashes here.

Provenance

The following attestation bundles were made for swarmstate-0.7.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: release.yml on swarmstate/swarmstate

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file swarmstate-0.7.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for swarmstate-0.7.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 1e011e5b20f299e3f5491be1575097a041250e343907cdfbd6d42a56ba2c9322
MD5 3ae7d01a34aa11d3c620c6c47b5f7233
BLAKE2b-256 64dcca9fe4b656090e6bbbe0008c6c1c2f08ec0a01c310fa78fa248d285f223a

See more details on using hashes here.

Provenance

The following attestation bundles were made for swarmstate-0.7.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:

Publisher: release.yml on swarmstate/swarmstate

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file swarmstate-0.7.0-cp39-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for swarmstate-0.7.0-cp39-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 5499cac2d754d53afec3891fb0d36eb7fce17b19c7218cca8c4c901533d279c3
MD5 6d9f3d54edcecc76dfad31c23ca71c6d
BLAKE2b-256 2ccca2cb5503947cfe297c5cfc8e27d2e85e4b543b507998315e6485f4c2dd7d

See more details on using hashes here.

Provenance

The following attestation bundles were made for swarmstate-0.7.0-cp39-abi3-macosx_11_0_arm64.whl:

Publisher: release.yml on swarmstate/swarmstate

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file swarmstate-0.7.0-cp39-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for swarmstate-0.7.0-cp39-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 efc3c012d13adfc6fc0c4f36fb4d2524287f3927c65b588482069dbcb01d3dff
MD5 a118101335f31b01f339c5f6aa05d418
BLAKE2b-256 7c34a178689f950e55e622864a1d84545c7408489bbaeb2d828504c84399ef4f

See more details on using hashes here.

Provenance

The following attestation bundles were made for swarmstate-0.7.0-cp39-abi3-macosx_10_12_x86_64.whl:

Publisher: release.yml on swarmstate/swarmstate

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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