Skip to content
STUB

Agent Loop

The pattern: agent execution as a state machine, not a loop-and-pray. Nodes are typed functions (plan, call-tool, observe, decide). Edges are conditional transitions. State is a typed object that flows. Any state can be restored and re-run. Every transition emits a span.

The trade-off: explicitness vs. agility. A naive while True: prompt, tool_call, observe loop is fast to write and impossible to debug. The state-machine framing is more upfront work but yields an agent you can replay, trace, and reason about. “Sometimes works” becomes “I know exactly where it failed.”

Deepens in Year 5 Phase 26: Agent Development — LangGraph implementation of the query-helper agent is the worked example. Phase 28: AIOps and services/aiops/ are where the pattern carries production weight.