Agentic Loop
Definition
The core execution cycle of an autonomous agent: observe → decide → act → observe result → decide next step. Unlike a single model call (prompt in, response out), an agentic loop runs indefinitely until the task is complete, an error threshold is reached, or a human intervenes. The loop is what makes an agent autonomous — it can pursue multi-step goals, recover from errors, and adapt its strategy based on intermediate results. Different frameworks implement the loop differently (event-driven, graph-based, simple while-loop), but the fundamental cycle is the same.
Builder Context
Design your agentic loop with clear termination conditions: max iterations, success criteria, and error budgets. The most dangerous failure mode is an unbounded loop where the agent keeps trying (and spending tokens/API calls) without making progress. Implement a 'stuck detector' — if the agent takes the same action twice with the same result, escalate or terminate. For production: log every loop iteration with the agent's reasoning, action taken, and result. This trace is essential for debugging.