← Agent Fundamentals (Demo)

Foundations

The agent loop

Read: The perceive–decide–act loop

The perceive–decide–act loop

(Demo content — placeholder reading for the platform spine.)

Every agent, from a thermostat to a coding assistant, runs the same loop:

  1. Perceive — gather the current state: the user's request, tool results, files, errors.
  2. Decide — choose the next action that moves toward the goal.
  3. Act — execute it: call a tool, write a file, ask a question.

Then the loop repeats: the result of the action becomes part of what the agent perceives next.

Why observing results matters

An agent that doesn't look at the outcome of its own actions is just a script with extra steps. The power comes from the feedback: a failed API call, an unexpected file, a test that finally passes — each observation reshapes the next decision.

Stopping conditions

A well-built agent also knows when to stop: goal reached, budget exhausted, or a decision that genuinely belongs to a human. You'll implement all three in the exercises later in this course.

Lesson quiz

1. What are the three phases of the agent loop?

2. Why does an agent need to observe the result of its own actions?

Exercise

The loop in practice

1. An agent calls a search API to look something up. Which phase of the loop is the API call itself?

2. An agent's tool call fails with a rate-limit error. Which phase of the loop notices the failure?