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.
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 table | What it holds |
|---|---|
| workflow_status | one row per workflow: PENDING, then SUCCESS |
| operation_outputs | each finished step's result |
| workflow_events | things the workflow publishes, like "assessed" |
| notifications | messages 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()