LearnGroundStudioAI
AI Agents & Tool Use
AGT·02·Foundations of agents·15 min·Lesson 2 / 8FREE

The agent loop: perceive, decide, act

If an agent is "a model with hands," the agent loop is how it decides when to use them. It's a simple cycle, and once you see it, agents stop feeling like magic.

The loop: perceive → decide → act → repeat

Every agent, no matter how fancy, runs the same basic cycle:

  1. Perceive — it reads the situation: your request plus anything it's learned so far.
  2. Decide — it chooses: do I have enough to answer, or do I need to use a tool first?
  3. Act — if it needs a tool, it calls one and gets a result back.
  4. Repeat — it folds that result into what it knows and loops again.

When it finally has enough, it stops looping and gives you a final answer.

Picture a capable assistant

A great human assistant does the same thing. You ask a question; they decide whether they can answer now or need to look something up; they look it up; they come back. The agent loop is just that, automated.

Watching it run

Say you ask an agent: "What's the weather in Lisbon, and should I pack a coat?"

  • Perceive: reads your question.
  • Decide: "I don't actually know today's Lisbon weather — I should use the weather tool."
  • Act: calls get_weather("Lisbon") → gets back 18°C, light rain.
  • Repeat → decide: "Now I have what I need."
  • Answer: "It's 18°C with light rain in Lisbon — pack a light coat."

Notice the model didn't guess the weather. It recognized a gap, used a tool to fill it, then answered. That's the entire trick.

The loop can run more than once

Harder requests just mean more laps. "Book the cheapest flight to Lisbon next Friday" might loop through: search flights → compare prices → check your calendar → create the booking. Same loop, four laps.

Knowledge check

In the agent loop, what happens right after the model decides it needs information it doesn't have?

Next, we'll get honest about when an agent is the right tool — and the common cases where a plain chatbot or a bit of normal software beats one.

Finished this lesson?