AI AgentsAI Agent Fundamentals

What is an agent loop?

An agent loop is the repeated cycle an AI agent follows to make progress toward a goal.

A simple version looks like this:

Observe → Decide → Act → Observe again

The loop continues until the task is complete or another stopping condition is reached.

How the loop works

1. Observe

The agent receives information about the current state of the task.

This may include:

  • the user's request
  • previous steps
  • tool outputs
  • API responses
  • errors
  • application or environment state

The observation gives the agent the context it needs for the next decision.

2. Decide

The agent evaluates the goal and the latest information, then chooses what to do next.

For example, it may decide to:

  • call a tool
  • retrieve more information
  • perform a calculation
  • retry a failed step
  • ask the user for missing information
  • produce the final answer

In LLM-based agents, a language model often contributes to this decision.

3. Act

The agent performs the chosen action.

Examples include:

  • calling an API
  • querying a database
  • searching the web
  • reading a file
  • running code
  • updating an application

4. Observe the result

The result of the action becomes new input for the agent.

For example:

Action: Search for available flights Observation: No direct flights are available.

The agent can now use that new information to choose another action, such as searching for connecting flights.

Why is it called a loop?

It is called a loop because the agent does not necessarily make one decision and stop.

Instead, the result of one action affects the next decision:

Observe → Decide → Act → Observe → Decide → Act → ...

This feedback cycle allows the agent to adapt as the task changes or as new information becomes available.

Example

Suppose an agent is asked:

> Find a restaurant near my hotel that is open tonight.

A simplified agent loop might be:

  1. Observe the request.
  2. Decide to search nearby restaurants.
  3. Run a restaurant search.
  4. Observe the results.
  5. Decide to check opening hours.
  6. Check availability or hours.
  7. Observe which restaurants are open.
  8. Return suitable options.
  9. Stop.

Each pass through the cycle is commonly considered one step or iteration of the agent's execution.

When does the loop stop?

An agent loop should have clear stopping conditions.

It may stop when:

  • the goal is achieved
  • a final answer is ready
  • the agent needs user input
  • an unrecoverable error occurs
  • a maximum-step limit is reached

These controls are important because an agent without a valid stopping condition could continue repeating actions unnecessarily.

In short

An agent loop is the control cycle that repeatedly lets an AI agent observe its current situation, decide on the next action, execute that action, and use the result to continue working toward its goal.

Specific loop patterns such as observe-think-act and plan-act-observe are variations of this general idea and are covered separately.

#what is an agent loop#AI agent loop#agent execution loop#AI agent observe decide act#agent loop explained#ai-agents#agent-loop#agent-execution#feedback-loop

Learning Sequence

AI Agents Curriculum

2% Completed
Up NextAI Agents

What are perception, reasoning, action, and feedback in an AI agent?

Explore Related Questions

Deepen your understanding across related AI Agents topics.

Machinoai Logo
Machinoai

Your edge in the AI era. Deep dives into machine learning concepts, paper explainers, verified industry jobs, and developer tools.

© 2026 Machinoai. All rights reserved.