cleandataengineering.aiAgent Harness, drawn simply
You are here: End to end › DBOS › What DBOS does

Agent Harness Tutorial · End to end · Zoom level 2

What DBOS does

A DBOS workflow is an ordinary async Python function, split into steps. After each step, DBOS writes the step's result into PostgreSQL. That is the whole trick.

clock.nowsavedapproval.assesssavedapproval.recordsavedwait for a ballotsavedapproval.carry_outsavedapproval.recordsaveddbos.operation_outputs: one row per finished stepafter a restart, finished steps return their saved result instead of running again
The dashed step is the wait: no thread is held, just a row saying "waiting for a message on topic approval.decision".

Replay. If the process dies, DBOS runs the function again from the top on the next start. Each step it has already finished returns its saved result at once instead of running again. So the payout step, once done, is never done twice.

Even the clock is a step. Reading the time is saved as clock.now, so a replay sees the same time and makes the same decisions.

DBOS tableWhat it holds
workflow_statusone row per workflow: PENDING, then SUCCESS
operation_outputseach finished step's result
workflow_eventsthings the workflow publishes, like "assessed"
notificationsmessages sent to a waiting workflow: Asha's ballot

Each step gets 3 tries of 30 seconds, 1 second apart.

How it is done: the real code

Cut from the live repositories each time the site is built, so it always matches what runs.

agent_harness/approvals/dbos.py:91The approval workflow: each step's result is saved
@DBOS.workflow(name=WORKFLOW)
async def _wait(ask: Ask) -> Approval:
    return await _Run(ask).run()