CSE Roadmap

Core tier · about 5 hours · 13 parts

Part 10 of 13 · 5 min read

A real engine for this

A real engine for this: Temporal, and what it automates versus what you still decide

Think of the difference between keeping your own trip diary by hand (part 2's rereading-versus-redeciding) and handing a travel company your itinerary, where they keep the log, replay it if a flight is cancelled, and guarantee you never get rebooked onto the same flight twice by accident.

In plain words: parts 1 and 2 built an event log and a replay function by hand, in about 300 lines, to show what durable execution actually requires underneath. A durable-execution engine such as Temporal is the same idea -- an append-only history, deterministic replay, explicit handling of anything non-deterministic -- built, tested, and operated as a separate service, so an application developer writes ordinary-looking code and gets crash recovery, retries, and exactly-once side effects without hand-rolling apply and a migration chain themselves. Temporal calls a durable, replayable sequence of steps a workflow, and calls any step that is allowed to be non-deterministic (a model call, an HTTP request, anything with a side effect) an activity -- activities are recorded in the history as their result, not re-run on replay, which is mini-durable's "recorded" branch from part 2, as a rule the engine enforces for you rather than one you remember to follow.

A worked example. Temporal's own integration with the OpenAI Agents SDK, generally available as of 23 March 2026, wraps each model call and each tool call in a Temporal activity automatically, so an agent built against that SDK gets durable execution -- survive a worker crash, a deploy, a multi-hour wait on a tool -- by adding the integration package, not by rewriting the agent loop around a hand-built log. The same project's April 2026 release extended this to agent sandboxes: a sandbox's full lifecycle (start, run commands, stop) runs as Temporal activities too, so a crash mid-sandbox-session resumes rather than starting the sandbox over.

About this example About this part

This module's mini-durable has no Temporal client and does not call out to a real engine; nothing here is run against one. The GA date and the integration's behaviour are reported in Temporal's own published posts and documentation (links below). This is one engine among several with the same job (Pydantic AI's own documentation lists eight durable-execution engines it supports); Temporal is named here because its public write-ups describe the mapping onto workflow-versus-activity most explicitly, not because it is uniquely correct. Last checked: 15 November 2026.

Durable-execution engine, workflow, activity

A durable-execution engine is a service that persists an application's event log and replays it on the application's behalf, so the application code does not implement its own apply, snapshot and migration logic. A workflow is the durable, replayable sequence of steps; its own code must be deterministic, exactly as apply must be in part 2. An activity is a step allowed to do something non-deterministic or side-effecting (call a model, call an API); the engine records its result once and never re-executes it on replay, which is what makes "replay the log" (part 2) safe to do automatically after every crash, not just as a manual debugging tool.

Example: mini-durable's replay(log, mode="recorded") reading a stored choice instead of calling the model again is, line for line, the same guarantee a workflow engine gives an activity: once it happened, replay reads what happened, it does not ask the model to decide again.

For the curious What a named engine does not remove from part 3 and part 4

Versioning old state against new code (part 3) and deciding whether a long pause has invalidated the premises a plan was built on (part 4) are not solved by the engine. Temporal's own versioning API exists precisely because workflow code changes while old histories are still in flight -- the problem from part 3 does not go away, it gets a dedicated tool. Whether a paused agent should re-check its assumptions before resuming (part 4) is a decision about your workflow's logic; the engine durably persists whatever decision you encode, it does not make the decision for you.

What the example does not do

About this example What the example does not do
  • No real storage: no database, transactions, locks, or concurrent writers (module 3 covers conflicts).
  • Sizes are JSON length, with no compression or serialisation overhead.
  • Crash points are uniform over steps and happen between steps.
  • One migration path with two simple changes; real migrations can be lossy.
  • A single hazard rate for staleness; real changes depend on the fact.
  • Optional real experiment: use a real checkpointer with a SQLite file, run 200 steps, kill the process at random steps, resume, and measure file size and resume time against the simulation.

Check yourself

A run crashes at step 40 of 200. With a snapshot every step, an event log, or a snapshot every 20 events, which writes least and which resumes fastest?

Show answer

The log writes least and replays the most; snapshots resume instantly and write the most; the hybrid sits between. Choose by bytes written and events replayed.

For the curious A saved state can go stale

A paused run that resumes a day later may act on facts that changed. With an assumed 2 percent per hour chance, 38 percent of resumes after 24 hours acted on a false premise unless the agent re-checked before the irreversible step. A part-hour pause used to count as zero hours; it now rounds up and is tested.

What you will use daily at work

Practice What it looks like
State outside the process Keyed by a run id so any worker can resume.
Record model outputs Replaying with a live model call can diverge from the original run.
Version the state A migration for each schema change.