The Agent Loop: Perceive, Think, Act

4 min
Audience
ages 10–15
Time
20 to 30 min
Module
1/5
Badge to earn
Loop Master

Today's mission

By the end of this lesson, you will be able to name the four parts of the agent loop in order and explain why repeating them is what lets an agent finish a job.

The idea in one picture

You're cooking a new recipe. You look at the pan (perceive). You decide it needs more heat (think). You turn the dial (act). Then you look again (perceive) to see if it's sizzling just right. If not, you adjust again. You repeat this little cycle until dinner is ready. Nobody turns the dial once and walks away — that's how you burn the food! An agent works exactly the same way: it doesn't act once and hope for the best. It looks, decides, acts, checks, and goes around again until the goal is reached.

How it works

Every agent, no matter how fancy, runs the same simple loop over and over: look around, decide what to do, do it, check the result, then repeat.

Read the diagram from top to bottom, then follow the "No" arrow back up. The diamond is the key moment: the agent asks itself, "Is the goal reached?" If not, it goes around again. If yes, it stops.

The four parts:

  1. Perceive — gather information about the current state. What do I see right now? What did the last action change?
  2. Think — reason about what to do next. Given what I see, what is the single most useful next step?
  3. Act — take one concrete action: search, click, write code, send a message. Usually this means using a tool (more on that in the next lesson).
  4. Observe — look at what happened. Did it work? Did something unexpected show up? Then loop back to step 1.

Examples:

  • A coding agent: it reads an error message → thinks about a possible fix → edits the file → runs the test → sees the result → repeats until the test passes.
  • A shopping agent: it searches for a product → compares prices → checks the reviews → decides → buys → confirms the order arrived in the cart.

Each turn of the loop is small. The power comes from doing it many times: ten, twenty, fifty turns, each one moving a little closer to the goal.

Screen-free activity

The blindfolded loop. You need a friend, a scarf, and a small object (a cup, a toy) placed somewhere in the room.

  1. One person is the "agent" and wears the blindfold. The other is the "world" and can only answer "warmer" or "colder".
  2. The agent takes one step in any direction (act), then asks "warmer or colder?" (perceive/observe).
  3. The agent thinks about the answer and decides the next step (think). Repeat the loop.
  4. Count the number of loops it takes to reach the object. Then swap roles and try again.
  5. Discuss: what happened when someone tried to take three steps without asking? Why does checking after every step help?

Key takeaways

  • The agent loop has four parts: Perceive → Think → Act → Observe, then a check: "Goal reached?"
  • Each turn of the loop does just one small action and then looks at the result.
  • Repeating the loop dozens of times is what turns a simple cycle into a powerful problem-solver.

A question for a grown-up

Can you think of a job or hobby where you use this loop yourself, checking after every small action? What happens when someone skips the "observe" step?

So what? This loop is the heartbeat of every agent — simple on its own, but powerful when repeated dozens of times toward a goal. Once you can see the loop, you can understand almost any agent you meet.