
Controlled Iteration
How to loop safely.
Controlled Iteration
Cycles are the superpower of agents.
- "Plan -> Execute -> Observe -> Plan -> Execute..."
The Feedback Loop
A loop only makes sense if the state changes in each iteration.
graph TD
Generate[Generate Code] --> Test[Run Tests]
Test -- Fail --> UpdateState[Add Error to State]
UpdateState --> Generate
Test -- Pass --> Success
- Agent generates code.
- Tester runs code (finds Error).
- Crucial Step: The Error is added to the State message history.
- Agent reads the State (seeing the error) and tries again.