Lesson 13.02 · Phase 13 · Production Agents
Durable execution
A process can die between any two lines. Write the agent so that dying is boring: the next process picks up the journal and carries on, and nothing in the world happens twice.
Learning objectives
- Record every model call and tool call as a step in a journal, and replay completed steps instead of running them again.
- Explain the gap between "the side effect happened" and "the journal recorded it", and close it with idempotency keys derived from the step.
- Detect non-determinism: on replay, the code must ask for the same steps in the same order.
- Crash real worker processes at chosen points and show what each design does to refunds, emails and model calls.
An agent refunds an order and then emails the customer. Halfway through, the container is evicted, or the deploy from Lesson 1 runs past its grace period, or the machine runs out of memory. The orchestrator restarts the job from the beginning. The agent looks up the order, sees it still needs a refund (it doesn't check, or the model decides differently this time), and refunds again.
Loading the full lesson…