← Learn AI
C_000015 · ai agents · foundation

Agent Loop

The cycle at the heart of every agent: receive context, decide an action, execute it, observe the result, repeat until done.

Step 1 of 5

In words

What it is, why it matters, and what it is like.

Why am I learning this?

You use instructions every day to get things done: you tell a colleague to check a database, you ask a service to print a report, or you follow a checklist to troubleshoot your computer. But those are static commands; they do not change based on what they find. This concept explains how to give instructions that can adapt. When a system encounters an error it didn't expect, or finds new information, it needs to decide its next move in real time. Understanding this loop lets you build systems that don't just follow a script but actually figure out how to solve a problem step by step. For example, if you are building a tool that books flights, you need it to check prices, notice one is too high, search for alternatives, and then book the best one—not because you wrote a line of code for every possible flight combination, but because it can reason through each step.

The idea, in plain terms

Imagine you are planning a holiday. You do not sit down and write the entire itinerary in one go. You start with a goal: 'I want to visit Rome.' You look at what you have: dates, budget, preferences for hotels. You decide on your first action: search for flights. You observe the result: several options appear. Based on those results, you decide your next action: filter by price. You observe again: two flights are within budget. You pick one. Now you need a hotel. You decide to search for hotels near the airport. You observe: they are expensive. You adjust your plan: maybe stay slightly further away. You keep going—deciding, acting, observing—until you have all the pieces and can say, 'It is done.' An AI agent works exactly this way. It is not a single question-and-answer chatbot that guesses the whole answer at once. It is a cycle. The agent has a goal. It looks at the current situation (the context). It decides what to do next (such as searching a database, using a calculator, or writing text). It does that thing. It watches the result. That new information becomes part of the context for the next decision. This repeats until the agent decides it has achieved the goal or run out of attempts. The 'decision' part is done by a large language model, which reasons about the current situation just as you reason about your holiday plans. A traditional computer program follows fixed steps written by a programmer; an agent writes its own next step dynamically.

An analogy

Think of the agent loop as a self-driving car navigating to a destination. You set the goal (the airport) and provide the starting point (the context). The car decides to steer left, then accelerates. It observes the road ahead via sensors. If it sees traffic, it adjusts its speed or changes lanes in the next decision step. It does not calculate every single inch of the journey at the start; it makes small decisions based on what it sees right now, updating its plan continuously until it arrives. Unlike a human driver who might consult a map, the car relies entirely on this real-time sense-decide-act cycle to move forward.

Definition

The agent loop is the continuous process where a system observes its current context, decides on an action based on that observation, executes the action, observes the new result, and repeats these steps until the goal is reached or the system stops.

Where this sits

This concept sits at the center of 'AI Agents', which are systems that perform tasks rather than just answering questions. It provides the foundational engine for topics like 'Agent Executors', which handle the technical running of this cycle, and 'Agent Memory', which allows the system to retain information across these repeated steps.

Signal from the Frontier

Get the next essay on mind, machine, and meaning

Essays at the intersection of AI, philosophy, and Indian governance. No promotional content.

We'll send a one-click sign-in link to confirm. No password needed.

Views expressed are personal and do not represent the Government of India or the Government of Uttarakhand.

Agent Loop — Learn AI — Dr. B.V.R.C. Purushottam