Stasis
Stasis is a Rust framework for AI orchestration with durable runtime jobs, cluster-aware control plane primitives, and memory integration hooks.
Package note: the crates.io package is stasis-rs while Rust imports use stasis.
Architecture
domain: Runtime models, policies, events, and error contracts.application: Use-cases, orchestration pipelines, and runtime handlers.ports: Stable inbound/outbound interfaces.infrastructure: Adapters for in-memory, SurrealDB, networking, and providers.sdk: Consumer-facing facades (StasisSdk,RuntimeSdk,ControlPlaneSdk).
SDK Surface
StasisSdk: agent registration and prompt invocation flows.RuntimeSdk: enqueue, process, publish, recurring materialization, runtime stats.ControlPlaneSdk: endpoint and cluster coordination commands.
Quick Start
use ;
use GenaiLlmGateway;
async
For a deterministic local smoke test (no provider dependency), use examples/simple_agent.rs.
Prelude tiers:
stasis::prelude: minimal, stable default imports.stasis::prelude_ext: extended runtime/memory/control-plane imports.stasis::sdk_prelude: minimal SDK-first imports for app code.
To use a real provider via genai, set a provider key (for example OPENAI_API_KEY) and optionally configure model/provider routing:
You can also set a Stasis-scoped fallback key:
Provider-specific overrides are supported:
STASIS_OPENAI_API_KEYSTASIS_ANTHROPIC_API_KEYSTASIS_OLLAMA_API_KEY
Runtime examples are available in examples.
Tool Macro (Signature-Driven)
StasisTool can be generated from a typed async function using #[stasis_tool(...)]:
use JsonSchema;
use ;
use Result;
use stasis_tool;
async
// Generated symbols:
// - struct SearchDocsTool;
// - fn search_docs_tool() -> SearchDocsTool;
This avoids repetitive manual trait implementations while preserving strict JSON-schema-based validation.
Macro contract:
- Function must be
asyncand take exactly one typed input argument. - Return type must be
Result<OutputType>. - Input type must implement
Deserialize + JsonSchema. - Output type must implement
Serialize. - When
output_schema = true, output type must also implementJsonSchema.
Production-focused entry points:
- examples/simple_agent_production.rs: minimal real-provider invocation.
- examples/agentic_workflows_production.rs: full workflow set with
STASIS_EXAMPLE_TEAM_PROFILE(all|sre|product|support),STASIS_EXAMPLE_RUNTIME_BACKEND(in-memory|surreal-mem|surreal-ws|surreal-kv), andSTASIS_EXAMPLE_DRY_RUN=1for provider-safe smoke runs. - examples/runtime_backends_profiles.rs: backend profile bootstrap for in-memory, Surreal websocket, and Surreal KV modes.
- examples/team_role_workflows.rs: role-specific scenario packs for SRE incident, product planning, and support triage loops.
CI-friendly smoke harness:
Embedded Dashboard
You can embed the dashboard into your existing Axum app behind an optional feature flag.
Enable feature:
Mount dashboard routes in your app code:
use Arc;
use Router;
use ;
The standalone stasis_dashboard binary remains available for separate operations workflows.
Dashboard runtime backend selection (for stasis_dashboard):
STASIS_DASHBOARD_RUNTIME_BACKEND=in-memory|surreal-mem|surreal-ws|surreal-kvSTASIS_DASHBOARD_SURREAL_NAMESPACE(default:stasis)STASIS_DASHBOARD_SURREAL_DATABASE(default:runtime)STASIS_DASHBOARD_SURREAL_ENDPOINT(required forsurreal-ws)STASIS_DASHBOARD_SURREAL_KV_PATH(required forsurreal-kv)
Demo seeding remains opt-in and only applies to in-memory mode:
STASIS_DASHBOARD_DEMO_SEED=true
Documentation
- Docs index: docs/README.md
- V1 draft: docs/v1-runtime-draft.md
- Runtime design: docs/design/job-runtime-design.md
- Architecture overview: docs/architecture/overview.md
- ADR index: docs/adr/README.md
mdBook
- Book root: docs-book
- Table of contents: docs-book/src/SUMMARY.md
Build locally:
Serve locally: