Survive a restart, wait for a person
Build a claim flow that saves its place after every step, pauses for a human on large amounts, and pays exactly once.
You build: claim_flow.py: intake, decide, approve, pay, with its state in Postgres.
- Python 3.11 or newer and uv
- Docker
- An OpenRouter key (free models are enough)
- The learn-pg container from lab 20
-
01Write the four steps as a graph and run one small claim end to end
uv run --with langgraph --with langgraph-checkpoint-postgres --with "psycopg[binary]" --with openai claim_flow.py start --thread t0 --amount 20You pass when: The claim is paid in one run, and a payments table has one row for t0.
-
02Stop and wait for approval when the amount is over 100
uv run --with langgraph --with langgraph-checkpoint-postgres --with "psycopg[binary]" --with openai claim_flow.py start --thread t1 --amount 250You pass when: The process prints that it is waiting for approval and exits. Nothing is paid.
-
03Approve it from a new process
The second run is the real test. Any step that moves money must be safe to repeat.
uv run --with langgraph --with langgraph-checkpoint-postgres --with "psycopg[binary]" --with openai claim_flow.py resume --thread t1 --approveYou pass when: It carries on from the saved step and pays. Run the same command again: there is still exactly one payment row for t1.
-
04See the same contract in a ready-made stack
Optional. Flisk's agent resource keeps sessions in a checkpoint store in the same way your flow keeps threads in Postgres.
flisk project agent-stack && flisk upYou pass when: A local stack starts with an agent, tools and a database. flisk status --json shows the resources; flisk agent sessions <resource> lists stored sessions, and they are still listed after flisk restart <resource>.
The check runs on the computer, not on your word: a step passes when its command exits with 0 there.
Computers are not set up on this site yet. Run each command on your own machine and compare with "You pass when".
Commands run in labs/43-durable and may take up to 60 seconds each. Every command starts a new shell: put keys and settings in a .env file there, it is loaded each time.