Agents that survive
crashes and pauses.

An async-first runtime where agents call tools, remember across sessions, pause for human approval, and resume after a process restart — without you writing any of that infrastructure. Durable execution, event-sourced, like Temporal — scoped to LLM agents.

Read docsGitHub
$uv add agent-substrate
Postgres-journaled
Zero-cost suspension
No double-sends
Case: Payment workflow crash
Step 1/7
agent.py
In-Memory
$ python agent.py
Result: Lost state & double spend
substrate.log
Durable
$ substrate run payment.agent
Result: Exact step recovered
▶BUILD YOUR AGENTS
01

Not just a prompt wrapper. A resilient runtime engine for real-world agents.

Sandboxed tool chaining, autonomous subagent swarms, long-term memory compaction, security guardrails, and dynamic code interpretation.

Tool Chaining. Script multiple tools in one sandboxed turn, piping large data by ref with 0 round-trips.
SANDBOX CHAIN
DATA BY REF
# Pipe data with 0 round-trips
res = tools.query_db("events")
summary = tools.analyze(res)
return summary.report
1 Execution Turn92% fewer calls
Subagent Teams. Coordinate specialized ReAct and Orchestrator agents that delegate tasks autonomously.
HIERARCHYSUPERVISED
Orchestrator
researcher
coder
Priority delegationAuto-handoff
Long-Term Memory. Postgres & Redis history with vector recall and smart token budget compaction.
MEMORY STORE
-87% TOKENS
Raw Turn History14,200 tok
Compacted State1,840 tok
Sliding + LLM SummaryPostgres + Redis
Guardrails Middleware. Pre/post turn pipeline stopping prompt injections and redacting sensitive PII in real time.
SAFETY PIPELINE
TRIPWIRE
PII (SSN/Email)REDACTED
Prompt InjectionBLOCKED
Tool SchemaVALIDATED
Pre & Post TurnZero Leakage
Code Interpreter. Synthesize and execute Python on the fly when no pre-built tool matches the task.
CODE INTERPRETER
ZERO-EGRESS
# Fallback: No tool found
↳ synthesize & run script
import polars as pl
df = pl.read_csv("data.csv")
Isolated Sandbox<15ms Boot
Platform primitives:MCP GatewayVisual BuilderHuman GovernanceMulti-Model RouterEvals Fabric
Zero prompt-chain glue code needed
▶OPERATE IN PRODUCTION
02

Built for mission-critical operations. Run agents with complete safety, budget control, and reliability.

Automatic crash recovery, hard spend ceilings, zero-cost pauses for human approvals, and full step-by-step activity visibility.

Crash Protection. If a server restarts mid-task, resume instantly with saved state and 0 duplicate tool calls.
FAILOVER RECOVERY
INSTANT RESUME
Step 1: Parse instructionsSAVED
Step 2: Query databaseSAVED
Server restartedResumed at Step 3
Zero lost progress0 duplicate API calls
Spend & Loop Caps. Hard dollar limits per task that auto-halt runaway tool loops before surprise cloud bills.
BUDGET SAFETY
ACTIVE GUARD
Task Cost Ceiling$5.00 limit
Current Task Cost$1.73
No surprise billsAuto-halt armed
Zero-Cost Pauses. Pause for human approvals or webhooks with 0% CPU and $0 server cost, waking instantly.
APPROVAL GATE
$0.00 / HR
StatusAWAITING APPROVAL
Server Resources0% CPU · 0 MB RAM
Idle DurationDays or weeks safe
Zero idle costInstant wake-up
Execution Timeline. Transparent activity log showing every prompt, tool query, latency, and exact token cost.
ACTIVITY TIMELINE
FULL AUDIT
1. User request parsed0.2s · $0.01
2. Query analytics DB0.18s · $0.00
3. Generate report1.1s · $0.04
Full step visibilityExact cost per step
Operational guarantees:Crash ProtectionHard Spend LimitsZero-Cost PausesLoop Auto-HaltFull Audit Trail
Learn how Substrate protects your production budget
▶SYSTEM ARCHITECTURE
03

Layered for modularity and isolation. From pure domain contracts to production serving.

A 4-tier architectural hierarchy spanning 13 isolated concepts: types → telemetry → tools → models → stores → documents → workspace → safety → context → middleware → runtime → agents → testing.

SUBSTRATE HIERARCHY
TOP → FOUNDATION
TIER 3
IMMUTABLE WAL JOURNAL

Runtime & Middleware

The durable execution engine: process crash recovery, append-only WAL journals, lifecycle interceptors at TURN, CHAT, and TOOL stages, PII masking, rate limiting, and sliding-window token compaction.

CORE SUBMODULES4 COMPONENTS
substrate.runtime.runtime
Durable runtime lifecycle managing workers, run scopes, and outcomes.
substrate.runtime.journal
Append-only write-ahead log recording every tool intent and completion.
substrate.middleware.pipeline
Tri-stage interceptor pipeline (TURN, CHAT, TOOL) for audit, PII, and rate limits.
substrate.context.compaction
Sliding-window compaction reducing token consumption before model dispatch.
PYTHON API CONTRACTSTRICT SIGNATURES
# Tier 3: Durable Runtime Engine & Interceptor Middleware
from substrate.runtime import Runtime, RunOutcome
from substrate.middleware import MiddlewarePipeline, PIIDetectionMiddleware, RateLimiterMiddleware
from substrate.context import ContextConfig, SlidingWindowCompaction

middleware = MiddlewarePipeline([
    PIIDetectionMiddleware(mask=True),
    RateLimiterMiddleware(max_rpm=60),
])

async with Runtime.open("./.substrate", middleware=middleware) as runtime:
    outcome = await runtime.run(agent, "Generate monthly report")
    print(f"Status: {outcome.status.value}")
    
    # Inspect immutable execution trace
    for event in await runtime.read(outcome.run_id):
        print(f"  {event.kind}: {event.payload}")
Consumes Tiers 1 & 2 · Execution Engine
Zero Circular Dependencies
Architectural invariants:Strict Downward ImportsDecoupled Compute & StateWAL Replay DeterminismCrash-Resilient DurabilityW3C Distributed OTel
Explore complete architecture reference
▶HONEST & FLEXIBLE ACCESS

Open source at the core. Simple plans in the cloud.

Run it yourself for free, start on the hosted Free plan, bring your own model key for more, or partner with us for an enterprise deployment.

MIT Licensed
OPEN SOURCE

Run Locally (Free)

100% open source under MIT. Deploy on your laptop, Docker, or Kubernetes with zero platform limits.

Free
FREE

Start on the Hosted Plan

A few messages a day on our models, with documents, memory and scheduled tasks. No credit card needed.

Most Flexible
BRING YOUR OWN KEY

Explorer

Connect your own model key for a much higher daily limit. A flat monthly fee covers our processing; no markup on model costs.

Custom Solutions
BESPOKE

Consulting & Sales

Need custom agent architecture, private VPC deployment, or bespoke tools? Work directly with our engineering team.