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.5.0.tar.gz (62.9 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.5.0-cp39-abi3-win_amd64.whl (246.6 kB view details)

Uploaded CPython 3.9+Windows x86-64

swarmstate-0.5.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (367.8 kB view details)

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

swarmstate-0.5.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (364.2 kB view details)

Uploaded CPython 3.9+manylinux: glibc 2.17+ ARM64

swarmstate-0.5.0-cp39-abi3-macosx_11_0_arm64.whl (341.6 kB view details)

Uploaded CPython 3.9+macOS 11.0+ ARM64

swarmstate-0.5.0-cp39-abi3-macosx_10_12_x86_64.whl (355.9 kB view details)

Uploaded CPython 3.9+macOS 10.12+ x86-64

File details

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

File metadata

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

File hashes

Hashes for swarmstate-0.5.0.tar.gz
Algorithm Hash digest
SHA256 67efa98e57e565917fe6d4be6dd6b2a10905a658212bda41006ad404bac6577e
MD5 2d84dd413e84e8449769163d8702aec2
BLAKE2b-256 d39c03a23130c5d428983205968d407bec6b5caca6244eef1f86196abea6be19

See more details on using hashes here.

Provenance

The following attestation bundles were made for swarmstate-0.5.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.5.0-cp39-abi3-win_amd64.whl.

File metadata

  • Download URL: swarmstate-0.5.0-cp39-abi3-win_amd64.whl
  • Upload date:
  • Size: 246.6 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.5.0-cp39-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 7a15d52723ae94f83380b675d078337f33e3821916956420461f6b41044d4dfb
MD5 a2d1ee6385475c4255a8b90c6f8577bb
BLAKE2b-256 e80a9d95d29828bd29cd9e0ace2643a53553575d57bb4c38de17b084ce2e069a

See more details on using hashes here.

Provenance

The following attestation bundles were made for swarmstate-0.5.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.5.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for swarmstate-0.5.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 e2eda8d656fbb173240a10c75b6c7ce699a146a24fe95932d3e621b30d03cdf6
MD5 1196d0f3c4bf4aa6154c7cee4c57f42d
BLAKE2b-256 2c90cb738374849c7aa77546c70ca80e50add7071bcced8ee76117a3630e7efe

See more details on using hashes here.

Provenance

The following attestation bundles were made for swarmstate-0.5.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.5.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for swarmstate-0.5.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 387d94c1564e0a9c28fabc9fccbcdf5caca3d87e44ca3195b862fecf623f8e3f
MD5 16fdeed447bd2046687e35b88173b5ec
BLAKE2b-256 0f7fc87d7770369242a28e09fc207eb42b0047459dab8f3598904b65b5dcaf53

See more details on using hashes here.

Provenance

The following attestation bundles were made for swarmstate-0.5.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.5.0-cp39-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for swarmstate-0.5.0-cp39-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 c20baf65147c6e5a0001969e2aee57b52d15e136dbce61af1b38aa685e8d5738
MD5 2e4b7f9a44528a3ff6f8a35ea4c9a8ad
BLAKE2b-256 ef2c1908f227015effa45443b666f48b30646d954ef45eea13f2b2805a43d530

See more details on using hashes here.

Provenance

The following attestation bundles were made for swarmstate-0.5.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.5.0-cp39-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for swarmstate-0.5.0-cp39-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 31082756f61713743f63b3194e5e9f132a1efe415315c60f263a58680ce1ab9e
MD5 37409b4b3ee32fabfc768c21a82bbb3f
BLAKE2b-256 4bdc87eb4888e64d68ddfa3cf89777eec4e96ce25d458b252a7f41de5686263b

See more details on using hashes here.

Provenance

The following attestation bundles were made for swarmstate-0.5.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