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 the full library, or choose individual packages.
pip install "pyrula[all]"
| 0001 | run:init | nightly_orders | worker-2 |
| 0002 | step:pending | extract | worker-2 |
| 0003 | step:done | extract → 2.1M rows | 14m 02s |
| 0004 | step:pending | clean | worker-2 |
| 0005 | step:done | clean → 1.98M rows | 3m 40s |
| 0006 | step:pending | to_usd | worker-2 |
| 0007 | step:done | to_usd → 1.98M rows | 2m 11s |
| 0008 | step:pending | load | worker-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. | |||
| 0009 | step:pending | load | worker-5 |
| 0010 | step:done | load → 1.98M merged | 4m 05s |
| 0011 | run:complete | nightly_orders | 26m 12s |
Write workflows and agents as Python functions and run them on your own infrastructure.
Source on GitHub →Pyrula Cloud adds a hosted UI for your workers. Inspect runs, review recorded results and start what-if runs.
Cloud features →pyrula-workflowsReplay and 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.
| seq | step | status | worker | time |
|---|---|---|---|---|
| 0003 | extract | done | worker-2 | 14m 02s |
| 0005 | clean | done | worker-2 | 3m 40s |
| 0007 | to_usd | done | worker-2 | 2m 11s |
| 0010 | load | done | worker-5 | 4m 05s |
| 0011 | run | complete | worker-5 | 26m 12s |
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_followupIn 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.
pyrula-agentsAgents →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.
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.
pyrula-kafkaKafka →@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 →
frompyrula.workflows.kafkaimportkafka_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 defscore(ctx, invoice: Invoice) -> Scored: risk =awaitctx.step( "score", model_score, invoice)returnScored(id=invoice.id, risk=risk)
cloud.pyrula.ioConnect a worker →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.
Read a run's journal to see which steps completed and where recovery resumed.
Connect your first worker →Fork a finished run with a different input, model or prompt. A connected worker executes the new run.
Try a change →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 →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.
pyrulaRust-backed core: functional types and serde.
Primitives →
pyrula-kafkaPure-Rust, batch-first Kafka client.
Kafka →
pyrula-workflowsDurable execution engine on the Rust-backed core.
Workflows →
pyrula-agentsDurable agent runtime built on pyrula.workflows.Agents →pyrula-cloud-clientConnector for Pyrula Cloud.
Cloud →
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.