Agentic Loop
The core execution cycle of an AI agent: observe the current state, reason about what to do next, take an action (call a tool, generate a response, update memory), observe the result, and repeat until the goal is achieved or a stopping condition is met. The agentic loop is what distinguishes agents from single-shot LLM calls—agents iterate, adapt to intermediate results, recover from errors, and pursue multi-step objectives. Loop control (when to continue, when to stop, when to ask for human input) is one of the hardest design problems in agent engineering.
Example
A coding agent receives a bug report. Loop iteration 1: read the error log. Iteration 2: find the relevant source file. Iteration 3: identify the bug. Iteration 4: write a fix. Iteration 5: run tests. Iteration 6: tests fail—revise the fix. Iteration 7: tests pass—submit the PR. Each iteration observes, reasons, and acts.
Frequently asked questions
- How do you prevent an agentic loop from running forever?
- Common safeguards: maximum iteration limits (e.g., 25 steps), token budget caps, timeout limits, repeated-action detection (agent stuck doing the same thing), and confidence thresholds (if the agent can't make progress, escalate to a human). The best agent frameworks combine multiple safeguards so no single failure mode causes runaway execution.