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 + backends) ✅ - persistent, drop-in checkpointer backends RedisStore, DiskStore (SQLite) and PostgresStore, all msgpack wire-format, plus SwarmStateStorage (portable 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.8.0.tar.gz (74.2 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.8.0-cp39-abi3-win_amd64.whl (252.5 kB view details)

Uploaded CPython 3.9+Windows x86-64

swarmstate-0.8.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (373.3 kB view details)

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

swarmstate-0.8.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (369.8 kB view details)

Uploaded CPython 3.9+manylinux: glibc 2.17+ ARM64

swarmstate-0.8.0-cp39-abi3-macosx_11_0_arm64.whl (347.5 kB view details)

Uploaded CPython 3.9+macOS 11.0+ ARM64

swarmstate-0.8.0-cp39-abi3-macosx_10_12_x86_64.whl (361.4 kB view details)

Uploaded CPython 3.9+macOS 10.12+ x86-64

File details

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

File metadata

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

File hashes

Hashes for swarmstate-0.8.0.tar.gz
Algorithm Hash digest
SHA256 77883dd51453ff894ea23de354990f1c9925ffe2d6e9576019cab4c40b55d743
MD5 016f3b3e6202585609cef83f555e0fa1
BLAKE2b-256 7c795a7ff090d0adc654290bb6592e8224ed5bad9ccf862b32708ae15ec71fd8

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: swarmstate-0.8.0-cp39-abi3-win_amd64.whl
  • Upload date:
  • Size: 252.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.8.0-cp39-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 50ab36aa42d381d6b19ad1592e09119e2dca28563039b70abe2b585f78a8f066
MD5 00c4bca6f24d30c97f75ea530c675fe8
BLAKE2b-256 b0149da98af836156811b3a393a064fd6b9125096e7627c13097ac6c0299978c

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for swarmstate-0.8.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 18559bf9fa2c79e6d758a772312537d676dbdd6e87fabb324694ab6202b1cfe0
MD5 4d92ca79045bab54c25d706a4ea96e0c
BLAKE2b-256 84f3ab6ee577c598b6f31e1f5e1c8a63e6ea1c12ddcc07292dc5016d18778cf6

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for swarmstate-0.8.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 0001d02409d445402baaeb098a325e838956db329319e03a64da047065361447
MD5 0199e82e832cc4cf379497dd35e4b70c
BLAKE2b-256 2178e7af1711d932ef16514ca1040185058087a4fcbe037373fba3a53e5a310c

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for swarmstate-0.8.0-cp39-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 7320ea3f1e6e42f8d02495b1c46bf0182deb0563bc30ac378897a7c87b7dbd94
MD5 e39cd38f8e374c891dc9ee87a8e527e1
BLAKE2b-256 84690a8b6e7ab4cb048319fbbbd329acd7cea327602edf82e49d3fea907c6117

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for swarmstate-0.8.0-cp39-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 7b1fe0084fc3c3bd42327721a9ee915c9181ba0b264b8241d819bee3fe1052d8
MD5 1c2a68f65f280591dc1f8ebbf00ecd83
BLAKE2b-256 b16a83b1ac20cb3f3165dc127326137649389dc8a685691cc173eebecb06c058

See more details on using hashes here.

Provenance

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