Skip to content
Tech Atlas, home
Search
Esc
  • All roadmapsBrowse every learning path
  • ExploreFind a technology area
  • ProjectsGuided projects and builds
  • My AtlasYour learning dashboard
Lesson 2 of 6 · Concept · 15 min · revision 2

Checkpointers Versus Workflow Engines

Run the same three-step triage task on a workflow engine (DBOS) and on a framework checkpointer (LangGraph with SQLite), crash both after a side effect, compare what each repeats, and use the differences to choose one for a given agent workload.

Contentsand lesson path

On this page

  1. Why it matters
  2. One task, two tools
  3. Choosing for a workload
  4. Check your understanding
  5. Apply it
  6. Review prompt

Lessons of Durable Agent Execution

  1. What Breaks in Long-Running Agents Concept · 15 min
  2. Checkpointers Versus Workflow Engines Concept · 15 min
  3. Idempotent Side Effects Worked example · 20 min
  4. Lab: Background Runs with Retries and Cancellation Lab · 25 min
  5. Crash, Resume, Compare Lab · 25 min
  6. Check: Failure and Recovery Scenarios Knowledge check · 8 questions

What you will learn

  • Explain durable execution and choose between framework checkpointing and a workflow engine for a given agent workload.

Prerequisites: Agent Loops & ReAct

01. Why it matters

The previous lesson wrote a journal by hand. In practice you get durability from a tool, and there are two kinds. A framework checkpointer belongs to an agent framework: after each step of the agent's graph it saves the graph state, and it can resume a thread from the last saved state. A workflow engine is a separate runtime that records each step of ordinary functions, and it usually adds durable timers, queues, retries, messages between runs and a view of every run in progress.

Both keep a run alive across a crash, so the choice is not about "durable or not". It is about how much else the workload needs, and how much extra infrastructure and discipline your team can take on. Picking a full engine for a two-minute summariser adds moving parts for nothing; picking a checkpointer for a flow that waits five days for a signature leaves you writing your own scheduler.

02. One task, two tools

The task is a short triage run: classify a ticket (a model call in real life), create_ticket in a ticket system (a side effect), and notify the customer (another side effect). As in lesson 1, each step appends a line to effects.log so you can count what ran. Setting CRASH_AFTER_CREATE=1 kills the process with os._exit(9) straight after the ticket is created, before the step can return.

Create a virtual environment and install the pinned versions used here. Both libraries keep their records in SQLite files in the current folder, so you need no server. DBOS recommends PostgreSQL in production; SQLite is for development and tests.

Terminal · Python 3.12
mkdir engines-lab && cd engines-lab
python3 -m venv .venv && source .venv/bin/activate
pip install "dbos==3.5.0" "langgraph==1.2.22" "langgraph-checkpoint-sqlite==3.1.3"

In DBOS, a workflow is a function decorated with @DBOS.workflow(), and each step is a function decorated with @DBOS.step(). DBOS saves the output of each finished step in its system database. SetWorkflowID gives the run a fixed ID, so calling the workflow again with the same ID attaches to the same run instead of starting a new one. DBOS.launch() also looks for unfinished workflows of this process and recovers them.

Python · engines-lab/dbos_triage.py
"""Three-step ticket triage as a DBOS workflow, with a crash you can switch on."""
import os
import sys

from dbos import DBOS, DBOSConfig, SetWorkflowID

DBOS(config=DBOSConfig(name="triage", log_level="ERROR",
                       system_database_url="sqlite:///triage.sqlite"))


def effect(line: str) -> None:  # stands in for a real side effect
    with open("effects.log", "a") as f:
        f.write(line + "\n")


@DBOS.step()
def classify(ticket: str) -> str:
    effect(f"classify {ticket}")
    return "billing"  # a model call would go here


@DBOS.step()
def create_ticket(ticket: str, queue: str) -> str:
    effect(f"create_ticket {ticket} in {queue}")
    if os.environ.get("CRASH_AFTER_CREATE") == "1":
        os._exit(9)  # hard crash: no cleanup, no checkpoint for this step
    return f"T-{ticket}"


@DBOS.step()
def notify(ref: str) -> None:
    effect(f"notify {ref}")


@DBOS.workflow()
def triage(ticket: str) -> str:
    queue = classify(ticket)
    ref = create_ticket(ticket, queue)
    notify(ref)
    return ref


if __name__ == "__main__":
    DBOS.launch()  # also recovers this executor's unfinished workflows
    with SetWorkflowID(f"triage-{sys.argv[1]}"):
        print("result:", triage(sys.argv[1]))
    DBOS.destroy()
Terminal · crash, recover, then call a finished run again
CRASH_AFTER_CREATE=1 python dbos_triage.py 1042; echo "exit code: $?"
python dbos_triage.py 1042
python dbos_triage.py 1042
cat effects.log
Expected output
exit code: 9
result: T-1042
result: T-1042
classify 1042
create_ticket 1042 in billing
create_ticket 1042 in billing
notify T-1042

Read effects.log line by line. classify ran once: its result was saved, so recovery reused it. create_ticket ran twice: the process died inside that step, before DBOS could record its output, so recovery ran it again. This is the crash window from lesson 1, and DBOS documents it plainly: steps are tried at least once but are never re-executed after they complete. The third call with the same workflow ID returned the saved result and ran nothing, because the workflow ID works as an idempotency key for the whole run.

DBOS, like Temporal and Restate, also expects the workflow function itself to be deterministic: called again with the same inputs, it must call the same steps with the same inputs in the same order. Recovery runs the workflow function from the top and uses saved step outputs in place of re-running finished steps, so a workflow that branched on random.random() or the clock could take a different path the second time. Anything non-deterministic, including every model call and API call, belongs inside a step. Temporal calls its steps activities and reports a non-determinism error when a replayed workflow issues different commands from its recorded history.

Now the same task as a LangGraph graph. Each node returns an update to a shared state, and the SQLite checkpointer saves that state after each super-step (one round of nodes). Runs are grouped by thread_id. get_state(config).next tells you which node would run next, which is how the script detects an unfinished run; invoke(None, config) resumes it. The stateful agent graphs lesson explores histories and forks; here you only need resume.

Python · engines-lab/graph_triage.py
"""The same triage as a LangGraph graph with a SQLite checkpointer."""
import os
import sqlite3
import sys
from typing import TypedDict

from langgraph.checkpoint.sqlite import SqliteSaver
from langgraph.graph import END, START, StateGraph


class Triage(TypedDict, total=False):
    ticket: str
    queue: str
    ref: str


def effect(line: str) -> None:
    with open("effects.log", "a") as f:
        f.write(line + "\n")


def classify(state: Triage) -> Triage:
    effect(f"classify {state['ticket']}")
    return {"queue": "billing"}


def create_ticket(state: Triage) -> Triage:
    effect(f"create_ticket {state['ticket']} in {state['queue']}")
    if os.environ.get("CRASH_AFTER_CREATE") == "1":
        os._exit(9)
    return {"ref": f"T-{state['ticket']}"}


def notify(state: Triage) -> Triage:
    effect(f"notify {state['ref']}")
    return {}


builder = StateGraph(Triage)
for name, fn in [("classify", classify), ("create_ticket", create_ticket),
                 ("notify", notify)]:
    builder.add_node(name, fn)
builder.add_edge(START, "classify")
builder.add_edge("classify", "create_ticket")
builder.add_edge("create_ticket", "notify")
builder.add_edge("notify", END)

conn = sqlite3.connect("graph.sqlite", check_same_thread=False)
graph = builder.compile(checkpointer=SqliteSaver(conn))
config = {"configurable": {"thread_id": f"triage-{sys.argv[1]}"}}

saved = graph.get_state(config)
if saved.next:  # an unfinished run exists: resume it from its checkpoint
    print("resuming at:", saved.next)
    result = graph.invoke(None, config, durability="sync")
elif saved.values:  # this thread already finished: do not run it again
    result = saved.values
else:
    result = graph.invoke({"ticket": sys.argv[1]}, config, durability="sync")
print("result:", result.get("ref"))
Terminal · the same three runs on LangGraph
rm -f effects.log
CRASH_AFTER_CREATE=1 python graph_triage.py 1042; echo "exit code: $?"
python graph_triage.py 1042
python graph_triage.py 1042
cat effects.log
Expected output
exit code: 9
resuming at: ('create_ticket',)
result: T-1042
result: T-1042
classify 1042
create_ticket 1042 in billing
create_ticket 1042 in billing
notify T-1042

The effects are the same: the interrupted node runs again, finished nodes do not. Two details matter. First, the script passes durability="sync", which saves each checkpoint before the next node starts. LangGraph 1.x defaults to "async", which saves while the next node is already running; that is faster, but a hard crash can then lose the most recent checkpoint and resume one node earlier than you expect. Second, LangGraph does not treat a thread that already finished as "done, return the result": calling invoke with new input on that thread starts another pass. The script checks saved.values to avoid that, which is the job DBOS did for you with the workflow ID.

03. Choosing for a workload

Both tools re-run the step that was interrupted, so in both you still need idempotent side effects (lesson 3). The differences are in everything around the steps.

  • What a step is. A checkpointer saves at node boundaries. If one node calls the model and then creates a ticket, a crash after the ticket repeats the whole node, model call included. An engine records each decorated function, so you can make every external call its own step.
  • Waiting. Engines provide durable timers and signals: a workflow can sleep for three days or wait for an approval message without a process holding it. With a checkpointer you can pause a thread (for example with an interrupt for human review), but something else has to wake it up later.
  • Operations. Engines give queues, concurrency limits, scheduled runs, cancellation and a list of every run with its status. With a checkpointer these are yours to build.
  • Cost. An engine is another component to run, upgrade and monitor (Temporal needs its own cluster or a hosted service; DBOS recommends a Postgres database in production), and its determinism rules take practice. A checkpointer is a library inside the agent you already have.

Some rules of thumb follow from this. If a run finishes in seconds and can simply be retried from the start, you may need neither: a retry of the whole request is cheaper than any framework. If the agent is a graph that runs for minutes inside one service and must survive a deploy or pause for a person, a checkpointer is usually enough. If the run lasts hours or days, waits on timers or outside events, coordinates several services, or needs operators to see and manage thousands of runs, a workflow engine earns its cost. Teams also combine them: the engine owns the long-lived process and its timers, and each step calls a short agent graph.

04. Check your understanding

Practice check · 3 questions

Checkpointers and engines

Use the two scripts and their output in this lesson.

Q1. In `dbos_triage.py`, suppose the crash happens inside `notify` instead, after its line is written. Which lines does recovery add to `effects.log`?
Q2. You remove `durability="sync"` from `graph_triage.py`, so LangGraph uses its default. What can change after the crash?
Q3. A LangGraph node calls the model to write a summary and then creates a ticket. The process dies just after the ticket is created. What runs when the thread resumes?
Practice only: not graded, not saved, not evidence.

05. Apply it

Use the step list you wrote for your practice agent in lesson 1. Write one paragraph that answers: how long does a run take at the longest, does it wait on people, timers or other systems, how many runs are in flight at once, and who will operate it. Pick a checkpointer, a workflow engine, or plain retries, and name the two facts that decided it. Then mark which of your steps would become separate engine steps or separate graph nodes so that each side effect has its own boundary.

06. Review prompt

From memory, explain why create_ticket appeared twice in effects.log for both tools, and why classify appeared once. State the determinism rule for workflow functions in your own words and say why model calls must be steps. Finally, list four things a workflow engine adds that a framework checkpointer does not, and the price you pay for them.

References

Your progress

Reading state

Sign in to save that you finished reading this lesson.

Sign in to mark reading complete

Prove this skill

8 questions · about 6 minutes · scored automatically. Marking a lesson as read never demonstrates a skill.
Take the skill check