An agent runtime can be modeled as a graph whose nodes perform work and whose edges choose the next transition. State is the typed snapshot shared across steps: user goal, messages, plan, retrieved evidence, tool results, approvals, budgets, errors, and produced artifacts.
State updates need reducer semantics. Append-only event lists, last-write-wins fields, counters, and sets behave differently when branches execute in parallel. Define each merge rule rather than mutating a shared dictionary from arbitrary nodes.
Cycles support observe-and-replan behavior, but every cycle needs a termination condition. A robust loop stops on goal completion, non-retriable error, user cancellation, deadline, iteration budget, cost budget, or no-progress detection.