Agent Harness Tutorial · End to end · Zoom level 2
Which step touches which table
Follow one turn down the page and watch which table each step touches. The pattern is simple: read once at the start, guard each write in the middle, save once at the end.
The checkpoint is saved once per turn, with "insert, or update if this run id is already there", so a retried save can't make a duplicate.
The delivery row is always settled, even when the turn failed, so a retry of the same message gets the same answer rather than running again.
Not built yet: saving a checkpoint after every trip of the loop (today it is once per turn), and an outbox so the reply and the checkpoint are written in one transaction.
Code view: input, process, output, the call stack, the classes
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/state/postgres.py:77Save the checkpoint: insert, or update if this run already saved ON CONFLICT (run_id) DO UPDATE
SET state = EXCLUDED.state,
conversation_id = EXCLUDED.conversation_id,
customer_id = EXCLUDED.customer_id,
updated_at = now()
""",