runstate (Python SDK)
Python SDK for runstate, the coordination layer for agent swarms. Decorate a function once where you define it, then call it exactly as before. runstate does the coordination inside the call: work done once per run, shared rate limits, slots, budgets, queues and stopping a run.
Install
pip install runstate-sdk
Requires Python 3.10 or later. Imports as runstate.
Configure
Set RUNSTATE_API_KEY and RUNSTATE_SPACE_ID in the environment. Optional:
RUNSTATE_RUN (the run every process joins, default default) and
RUNSTATE_BASE_URL (default https://api.getrunstate.com). The SDK reads
them on the first call. To configure in code, use
runstate.configure(api_key=..., space_id=..., run=...) or
runstate.Runstate(...).
Use
import runstate
@runstate.once
def research_company(name: str) -> dict: ...
@runstate.limit("search-api", max=60, per="minute")
async def search_web(query: str) -> list: ...
@runstate.slots("browser", max=5)
def open_page(url: str) -> str: ...
@runstate.budget("model-usd", reserve=0.40, cost=lambda r: r.usd, limit=50)
def call_model(prompt: str): ...
research_company("acme") # looks like a normal call
runstate.stop() # every worker stops taking new work
Hand work to workers
# review.py, imported by producers and workers
@runstate.queue("review", slots="browser")
def review(doc: dict) -> dict: ...
# producer
score = review(doc)
accepted = review.gather(docs, need=5, accept=lambda result, doc: result["score"] > 0.8)
# worker
runstate.serve()
Decorators work on plain and async def functions. Every module function has
an a-prefixed async form: await runstate.astop(), await runstate.aserve(),
await review.asend(doc).
Docs
- Reference: https://docs.getrunstate.com/sdk/python/
- Migrating from 0.2: https://docs.getrunstate.com/changelog/
- HTTP API for other languages: https://docs.getrunstate.com/api/
Metadata
Release files for runstate-sdk 0.3.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| runstate_sdk-0.3.0.tar.gz | 51.5 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| runstate_sdk-0.3.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 100.6 kB
Release files / runstate_sdk-0.3.0.tar.gz
| Download URL | runstate_sdk-0.3.0.tar.gz |
|---|---|
| Size | 51.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c954a16ef4a1de5231eec0542c7aace40469e82a79701591505e3b99f842fae1
|
|
BLAKE2b-256 checksum How to use checksums |
c9a312f9644b4e84defd4370c6726c38fe17fc87571b4de3f03354626da62b11
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.11.2
|
Release files / runstate_sdk-0.3.0-py3-none-any.whl
| Download URL | runstate_sdk-0.3.0-py3-none-any.whl |
|---|---|
| Size | 49.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
eb72a455cab49977e39a5b8ac547a2e96004a1ff58c1c33cce2192d82fdeb3ba
|
|
BLAKE2b-256 checksum How to use checksums |
76425e80db4f42ed8bc51d2615f55dfc22c55853e388a9bb7f8592c84cf7d185
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.11.2
|