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.4.0.tar.gz (62.1 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.4.0-cp39-abi3-win_amd64.whl (245.3 kB view details)

Uploaded CPython 3.9+Windows x86-64

swarmstate-0.4.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (366.4 kB view details)

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

swarmstate-0.4.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (361.5 kB view details)

Uploaded CPython 3.9+manylinux: glibc 2.17+ ARM64

swarmstate-0.4.0-cp39-abi3-macosx_11_0_arm64.whl (340.2 kB view details)

Uploaded CPython 3.9+macOS 11.0+ ARM64

swarmstate-0.4.0-cp39-abi3-macosx_10_12_x86_64.whl (353.7 kB view details)

Uploaded CPython 3.9+macOS 10.12+ x86-64

File details

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

File metadata

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

File hashes

Hashes for swarmstate-0.4.0.tar.gz
Algorithm Hash digest
SHA256 9055c47f27bda50516a456689b33d3319462fb04a0632db0b6084b796e503bae
MD5 a5c42523068728cbc873101c51274c39
BLAKE2b-256 228556241ed4abc8546f09d9b36c0c4353db5253f375857ecc693bb3e1f53424

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: swarmstate-0.4.0-cp39-abi3-win_amd64.whl
  • Upload date:
  • Size: 245.3 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.4.0-cp39-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 b1100eaedf10b3a305320f56ab3adc7f3fbf2d8a495c9ebd5f0b5868a5c44dbb
MD5 e3717b1114945825f975ffadebe16c6e
BLAKE2b-256 90cac8480efb2811eecbfc18b3a09d7367a3322cd4fdddee07b561f989802d91

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for swarmstate-0.4.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 2f70bc08e9a3382fd6c6cc28aa8fc38bc349b09bf9ebd7f95a775690b1363151
MD5 68f43fa5fa568a8f15ed164b7dbf2eeb
BLAKE2b-256 71aa501b55ab2927ae80f421686f1293550b9faadc22bbdb54c1bb4f9e78a723

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for swarmstate-0.4.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 0f7fe4cf165c3dbfe7bc12935f02db2739fa55eaeaedd4b768bbd81571176ff4
MD5 86b3571cd0ba6e284202b95ff25db98d
BLAKE2b-256 dc5ba30700be4a894f7a25eed9a2b6fc1e2af3d1c085b8bbc111b8674e73d986

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for swarmstate-0.4.0-cp39-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 5264f679dd11512e62dc3075dc6c388d8275604857dab42cc2229c356f3f53ba
MD5 303f28acc53fbadce7c721fb569e0820
BLAKE2b-256 fc43501aff23d26d4295d3d5c310ba9c741f91e7e679041efafdbc066952df26

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for swarmstate-0.4.0-cp39-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 24c8c286b01e8c1eb9d4efd6649202b4c3dfcb2b086c2854165f02d8dfea061c
MD5 308ee29d33790c9769cb7c160b9e1915
BLAKE2b-256 b86476d6f0c218d896f73defaaf37f20ba3e0c204586231417045693473ae547

See more details on using hashes here.

Provenance

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