Lesson 03.09 · Phase 03 · The Agent Loop
State machines for agents
Let the model make small, checked choices. Let code own the order of operations.
Learning objectives
- Explain when a free agent loop is the wrong shape, and what a state machine guarantees instead.
- Implement a state machine with an explicit transition table, illegal-transition errors, per-state tools, a pause state, and visit limits that survive pauses.
- Constrain the model to choosing one option from a list, validate the choice, and retry with feedback.
- Measure the model's choices on labelled data, and design the machine so a wrong choice is safe.
A support agent with lookuporder, refund and sendemail in a free loop can do anything in any order. Usually it does the right thing. But "usually" is the wrong word for money. Nothing in the loop stops it from refunding before checking that the order exists, refunding an order delivered three months ago, or refunding twice.
Loading the full lesson…