Pyrula Cloud is in private beta.Join the list

Workflows and agents
that survive crashes.

Pyrula is an open source Python library for durable workflows and LLM agents. It records step results in a journal. After a crash, another worker replays those results and continues from the first unfinished step.

Install Pyrula

Install the full library, or choose individual packages.

pip install "pyrula[all]"
Customize install
Install Pyrula
More options
Storage and telemetry
Providers and integrations

● nightly_orders.pyrun_01KA3C · journal · complete
from pyrula.workflows import workflow @workflow async def nightly_orders(ctx, day: str): raw = await ctx.step("extract", export_orders, day) clean = await ctx.step("clean", drop_test_and_dupes, raw) usd = await ctx.step("to_usd", convert_to_usd, clean) return await ctx.step("load", merge_into_warehouse, usd, day)
0001run:initnightly_ordersworker-2
0002step:pendingextractworker-2
0003step:doneextract → 2.1M rows14m 02s
0004step:pendingcleanworker-2
0005step:doneclean → 1.98M rows3m 40s
0006step:pendingto_usdworker-2
0007step:doneto_usd → 1.98M rows2m 11s
0008step:pendingloadworker-2
worker-2 is killed mid-load. worker-5 claims the run and replays 0001 to 0008; extract, clean and to_usd return their recorded results.
0009step:pendingloadworker-5
0010step:doneload → 1.98M merged4m 05s
0011run:completenightly_orders26m 12s

Open source library

Write workflows and agents as Python functions and run them on your own infrastructure.

Source on GitHub →

Pyrula Cloud

Pyrula Cloud adds a hosted UI for your workers. Inspect runs, review recorded results and start what-if runs.

Cloud features →

Workflows

pyrula-workflowsReplay and recovery →

Recovery

The worker writes step:pending before calling a step, then step:done after it succeeds. During recovery, completed steps return their recorded results and the first unfinished step runs again.

nightly_orders journal
seqstepstatusworkertime
0003extractdoneworker-214m 02s
0005cleandoneworker-23m 40s
0007to_usddoneworker-22m 11s
0010loaddoneworker-54m 05s
0011runcompleteworker-526m 12s

Sleeps and signals

ctx.sleep records a wake time and suspends the run until then. ctx.wait_for_signal waits for a named signal. Signals sent before the run reaches the wait are buffered.

await ctx.sleep(timedelta(days=3)) await ctx.wait_for_signal("payment_confirmed") invoice_followup
send_invoice step:done send_reminder step:pending mark_paid step:pending run:sleeping run:woken run:signal_waiting run:signal_received worker-2 worker-5 worker-3 send_invoice step:done send_reminder step:pending mark_paid step:pending run:sleeping run:woken run:signal_waiting run:signal_received worker-2 worker-5 worker-3

What-if runs

In Pyrula Cloud, fork a finished run after a recorded event and change an input, step result, model or system prompt. A connected worker replays calls up to the fork and runs the rest as a new run, linked to the original. Writes without a recorded result are stopped unless you allow them.

This example changes the threshold after scoring, reusing all 128 recorded model calls.

"source": {"runId": "run_01K9F8", "forkAfterSeq": 4},
"overrides": {"inputsPatch": {"threshold": 0.75}}

replayed from the recording · 128 model calls, not paid twiceclick a step to fork therefetch_invoices128 rowsseq 1 to 2score_risk@agent · 128 callsseq 3 to 4flagthreshold 0.90seq 5 to 6reportpdfseq 7 to 83 flagged of 128threshold 0.90forked here, one input changedflagthreshold 0.75ran livereportpdfran live11 flagged of 128what-if · after seq 4replayed from therecording · 128 calls,not paid twiceclick a step to fork therefetch_invoices128 rowsseq 1 to 2score_risk128 model callsseq 3 to 4flagthreshold 0.90seq 5 to 6reportpdfseq 7 to 83 flagged of 128threshold 0.90forked hereflagthreshold 0.75ran livereportpdfran live11 flagged of 128what-if · after seq 4

Agents

pyrula-agentsAgents →

Agent turns

Pyrula runs each agent turn as a workflow. During recovery, completed model and tool calls return their recorded results, so a crashed turn doesn't repeat them. Agents run over HTTP or Kafka. A disconnected HTTP client can catch up from its last event id.

support_triage · turn 7 · worker-3› customer says the refund never arrived, order F-100 tool:result lookup_order · tool:result refund_status · llm:start · llm:done Looking up F-100. The charge step completed on 10/28 and the refund is waiting on a bank callback. I'll keep the ticket open and check the callback again at 3pm.

Tool calls in a what-if

Start an agent what-if in Pyrula Cloud with a different model or system prompt. The agent's model calls after the fork run live. A tool call whose input matches the recording gets the recorded result.

A tool call with no recorded result runs live only if the tool is declared @tool(read_only=True). Other tools are writes. A write with no recorded result stops the run with write_not_allowed unless you allow it.

Kafka

pyrula-kafkaKafka →

Kafka-triggered runs

@kafka_workflow starts a durable run for each record on an input topic and produces the result to an output topic. @kafka_agent does the same for an agent. The Kafka client is written in Rust and doesn't use librdkafka.

The default is at-least-once delivery. With delivery="exactly_once", the output record and the input offset are committed in one transaction. Delivery guarantees →

score.pypyrula-workflows
from pyrula.workflows.kafka import kafka_workflow
# Invoice and Scored are pydantic models
@kafka_workflow(
    input_topic="invoices",
    group="scorer",
    output_topic="scored-invoices",
    input_schema=Invoice,
    output_schema=Scored,
    delivery="exactly_once",
)
async def score(ctx, invoice: Invoice) -> Scored:
    risk = await ctx.step(
        "score", model_score, invoice)
    return Scored(id=invoice.id, risk=risk)

Pyrula Cloud

Betacloud.pyrula.ioConnect a worker →

Connected workers

Pyrula Cloud is the hosted UI for watching and controlling Pyrula runs. It shows the current state of runs from your connected workers. Open a run to inspect its journal.

Execution stays on your workers. Install the Cloud connector and set PYRULA_CLOUD_API_KEY to connect your existing workflows and agents.

Run history

Read a run's journal to see which steps completed and where recovery resumed.

Connect your first worker →

What-if runs

Fork a finished run with a different input, model or prompt. A connected worker executes the new run.

Try a change →

Saved cases

Save a run or what-if as a case in your fixture store, then replay it to check changes to your code.

Replay a saved case →

Python library. Rust core. Scala inspired.

Workflows and agents are Python functions. The core types, serialization and Kafka client are written in Rust and loaded through PyO3.

The API follows Scala's standard library. Either, Option and Try compose with map and flat_map, and the collections are immutable like Scala's List and Map. The pyrula package also works on its own.

Packages

  1. pyrulaRust-backed core: functional types and serde. Primitives →
  2. pyrula-kafkaPure-Rust, batch-first Kafka client. Kafka →
  3. pyrula-workflowsDurable execution engine on the Rust-backed core. Workflows →
  4. pyrula-agentsDurable agent runtime built on pyrula.workflows.Agents →
  5. pyrula-cloud-clientConnector for Pyrula Cloud. Cloud →

Primitives

from pyrula import Either, IList, Option def qty(raw: str) -> Either[int, str]: if raw.isdigit(): return Either.ok(int(raw)) return Either.err(f"bad qty: {raw}") rows = IList(["3", "12", "x"]).map(qty) rows.collect_err() # IList(['bad qty: x']) nums = rows.collect_ok() # IList([3, 12]) big: Option[int] = nums.find(lambda n: n > 9) big.get_or_else(0) # 12
  • EitherHolds a value or a typed error, without exceptions.
  • ValidatedLike Either, but collects every error instead of stopping at the first.
  • OptionHolds a value or marks it as absent.
  • TryHolds a result or the exception raised while computing it.
  • IList · IMap · ISetImmutable collections that share unchanged structure.