Runtime
The runtime is the journaling layer. Every model call and every tool
dispatch is keyed by (session_id, step_name) and stored. On a fresh
process pointed at the same journal, the same session resumes ,
already-completed steps return cached results; only the un-completed
work re-executes.
from loomflow import Agent
from loomflow.runtime import SqliteRuntime
agent = Agent(
"...",
model="claude-opus-4-7",
runtime=SqliteRuntime("./journal.db"),
)Three backends, same protocol
InProcRuntime (default; no durability) · SqliteRuntime (single file) · PostgresRuntime (production durable).In-proc · SQLite · PostgresHow runtime.step() and runtime.stream_step() keep cached results stable across crashes. The agent.resume() API.Replay and resumeWhat gets journaled
Every wrap point in the agent loop:
model_call_<turn>. The streamed model response (text + tool calls + usage).tool_call_<turn>_<slot>. Each parallel tool dispatch in a turn.persist_episode_<turns>. Thememory.remember(episode)call.
Architecture-specific steps add more, delegate_<turn>_<worker>
for Supervisor, plan / step_N / synthesize for Plan-and-Execute,
etc.
Default, InProcRuntime
Without a runtime= kwarg, Agent uses InProcRuntime. No journal,
no durability. Crashes lose everything. Fine for stateless one-shot
scripts and tests.
When to upgrade
| Symptom | Backend |
|---|---|
| ”I want crashes to resume” | SqliteRuntime (single file) |
| “Multi-instance” | PostgresRuntime |
| ”Just dev / tests” | InProcRuntime (default) |
Where journaling matters
- Long-running runs. Research agents, multi-stage pipelines , one model call gone wrong shouldn’t lose the work.
- Expensive tool calls. Slow APIs, paid endpoints, work that’s hard to redo.
- Resumability after deploys. Restart the process, pick up ongoing runs.
The journal vs. the audit log. The journal is for correctness
, it stores every step’s result so a crash recovers cleanly. The
audit log is for compliance. It stores who did what, with HMAC
signatures and user_id attribution. They’re separate stores with
separate lifecycles. See Audit log attribution.