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.6.0.tar.gz (64.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.6.0-cp39-abi3-win_amd64.whl (247.2 kB view details)

Uploaded CPython 3.9+Windows x86-64

swarmstate-0.6.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (368.4 kB view details)

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

swarmstate-0.6.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (364.9 kB view details)

Uploaded CPython 3.9+manylinux: glibc 2.17+ ARM64

swarmstate-0.6.0-cp39-abi3-macosx_11_0_arm64.whl (342.2 kB view details)

Uploaded CPython 3.9+macOS 11.0+ ARM64

swarmstate-0.6.0-cp39-abi3-macosx_10_12_x86_64.whl (356.4 kB view details)

Uploaded CPython 3.9+macOS 10.12+ x86-64

File details

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

File metadata

  • Download URL: swarmstate-0.6.0.tar.gz
  • Upload date:
  • Size: 64.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.6.0.tar.gz
Algorithm Hash digest
SHA256 efb5da084bda402428a2d65b7c069ed2fe7fe062d55d345890c4f553cb3e6309
MD5 8bf337ead1b1649d4759eb86bcdfea0a
BLAKE2b-256 fa2f075f942be83dc35fdd7b12b54fa6c67cbb9b26b4c6bad291b4c079972b6f

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: swarmstate-0.6.0-cp39-abi3-win_amd64.whl
  • Upload date:
  • Size: 247.2 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.6.0-cp39-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 d33c8db657a671454dabe477bd1580251cd5f00efd57c97f4897ae29a90e569e
MD5 52c3914304b5de9c723742b24970f44f
BLAKE2b-256 ec9f0b0d1dee126b54b26fd541a65b261dbc9981d5616ca84d120f7d1c99601d

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for swarmstate-0.6.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 4f57703da9dfb7c52a228fe2b324fbe6deedcd5ce1576d1f841850bc31c58876
MD5 f885da13b331664d660ad0dcfdea93c6
BLAKE2b-256 3faa34199b8ff948b9e33ecc81ada2ff4c64e2fc6a0cc4d87896ba985cdc7e0b

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for swarmstate-0.6.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 33f7f793cfa9720a8c793fc74290257d36eb98f1796ac0a8b30cec2ac024eba0
MD5 8d93898b82a12fd3b0268ea703451d8f
BLAKE2b-256 7a3b4ac2405ee2c6b31ed044ce6793cf5803ccf34e90ac190d7597335315e7f3

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for swarmstate-0.6.0-cp39-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 81899713054ab70ee1007e7842c70fd873a37cf72f76a8f0d21d465fc323cb93
MD5 00aadb6b72235a7c3f2ac4454fe44fa1
BLAKE2b-256 4c0efa1cc74014dcbf84a309320f55e3a6db442e95adb4a56b9896e08806134a

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for swarmstate-0.6.0-cp39-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 e7087d14cf8e16105f7e5858b0f8700407264136ebe77104c9d8cbbd7fdd9393
MD5 3d71bb9902485b9dfadd1db63ffaa6ee
BLAKE2b-256 69c78f87823ee42269c9715338588aeb18e6d0111629bdee38dbe0c443fc5b5e

See more details on using hashes here.

Provenance

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