OpenRath
An open-source, PyTorch-like runtime for dynamic multi-agent and multi-session workflows.
- Version
- v2.0.0
- License
- BSD-3-Clause
- Language
- Python
- GitHub
- 1.1k ★

“Most agent frameworks begin with an agent loop. OpenRath begins with Session.”
OpenRath: Session-Centered Runtime State for Agent Systems
Fukang Wen, Zhijie Wang, Ruilin Xu · cs.SE (primary) · cs.PL · 2026
Core abstractions
Session
The runtime value passed between agents and workflows. Branchable, inspectable, replayable.
Sandbox / Backend
The execution environment for tools: local, or an optional OpenSandbox container.
Memory
Persists knowledge. A local backend with built-in BM25 recall, swappable for OpenViking.
FlowToolCall
A JSON schema to the model, a Python callable to the runtime. stdio MCP tools adapt.
Workflow / Agent
An agent transforms sessions; a workflow composes both, nesting without limit.
Selector
Picks the next workflow, so if and while stay plain Python.
Provider
Routes OpenAI-compatible, Anthropic, or optional LiteLLM clients.

A PyTorch-shaped layering
| PyTorch | OpenRath | Role |
|---|---|---|
| Tensor | Session | 流动的值 |
| Device | Backend | 放置位置 |
| Parameter | Memory | 持久状态 |
| Function | FlowToolCall | 可调用操作 |
| nn.Module | Workflow / Agent | 组合结构 |
| if / while | Selector | 控制流 |

Install
pip install openrathCore packagepip install "openrath[opensandbox]"Containerized sandboxpip install "openrath[openviking]"OpenViking memory backendpip install "openrath[server,postgres]"v2 production deployment
Quickstart
The v2 public API lives under the rath.* namespace; the v1 openrath façade remains available.
from pathlib import Path
from uuid import uuid4
from rath.definition import Workflow, step, EffectClass
from rath.runtime import LocalRuntime, RunContext, SQLiteRunStore
class DurableHello(Workflow):
@step(entry=True, effects=EffectClass.READ_ONLY)
def greet(self, state):
return {**state, "message": "hello from OpenRath v2"}
def forward(self, session):
return self.greet(session)
store = SQLiteRunStore(Path("openrath.db"))
runtime = LocalRuntime(store)
runtime.submit(DurableHello(), session_id=uuid4(),
context=RunContext.local(revision_id=uuid4()))
runtime.work_once(worker_id="local-worker")from openrath import Session, flow
user_session = Session.from_user_message(
"Count the words in: OpenRath makes agent clusters traceable."
)
user_session = user_session.to("local", spec="./")
out = workflow(user_session)“Durable, explicit multi-agent execution.”
@step / @router
Declare compilable execution and routing boundaries.
ExecutionPlan
A canonical graph bound to an immutable revision.
Run
Durable execution state carrying tenant, session, and plan identity.
Event / Checkpoint
Ordered lifecycle evidence, plus resumable per-step state.
Lease / fencing token
Prevents a stale worker from committing after ownership changes.
Effect ledger
Reconciles retries and ambiguous external side effects.
Embedded
Local durable execution with SQLite.
Agent Server
PostgreSQL with action grants, governed adapters, and an audit sink.

BSD-3-Clause · 59 forks · Paper submitted 2026 · The Agent Server HTTP surface remains Beta