Skip to slide
Chapter 2 · The Agent Loop Pattern
14 / 191

CHAPTER 02 · The Agent Loop Pattern · 7 / 8

Statelessness within, state at the edges

The loop itself is best kept stateless: it takes the assembled context in, runs, and returns a result plus events. Persistence happens at the edges: load history before the loop, save the outcome after. This keeps the loop a pure function of its inputs, which makes it testable, retryable, and easy to reason about. (More in Chapter 9.)

← → arrow keys work too