How an AI Agent Works

Follow the execution cycle of an AI agent, step by step, from request to checked result.

LEARNING OBJECTIVES

  • — Describe the seven steps of the agent execution cycle
  • — Explain what the model does versus what the application does
  • — Recognize where failures and safety checks belong in the cycle

Prerequisites: Lesson 02 — AI Models vs. AI Agents vs. Automation

The execution cycle

Every tool-using agent runs the same basic cycle. Once you can picture it, most agent behavior — including most agent failures — starts to make sense.

Controlled execution flow
  1. 01Receive the request
  2. 02Interpret the goal
  3. 03Choose an action
  4. 04Execute the tool
  5. 05Observe the result
  6. 06Continue or finish
  7. 07Check the outcome

Each step, in plain language

Walk through the cycle slowly. Notice how often the application — not the model — is the one acting.

  • Step 01 — Receive the request: the agent gets a goal from a user or an approved workflow. Example: “Find the total number of orders in the sample dataset.”
  • Step 02 — Interpret the goal: the model reads the request together with its instructions and the available context, and works out what is being asked.
  • Step 03 — Choose an action: if tools are available, the model may select one and propose the inputs — for example, a read-only counting tool over the orders table.
  • Step 04 — Execute the tool: the application validates the proposed action and runs it only if it is permitted. The model never executes anything itself.
  • Step 05 — Observe the result: the tool's output — say, 1,284 orders — is returned to the model as new context.
  • Step 06 — Continue or finish: the model decides whether another action is needed or it can now answer. The cycle may repeat, within a fixed turn limit.
  • Step 07 — Check the outcome: the application or a human verifies the result actually satisfies the original request.

What the model does not have

A model has no operating-system access, no internet access, no database access, and no permission to perform actions. None of these come built in. Every capability an agent appears to have was explicitly provided by the surrounding application as a tool, and every permission was granted by the people who configured it.

This is the most common misunderstanding about agents. When an agent 'looks something up', the application looked it up. The model's job was deciding what to look up and explaining what came back.

Where things go wrong

Each step has a characteristic failure. Good agent design plans for all of them.

  • Interpretation: a vague request gets misread. Mitigation: clear instructions and clarifying questions.
  • Action choice: the model picks the wrong tool or wrong inputs. Mitigation: validation before execution.
  • Execution: the tool fails or times out. Mitigation: controlled errors returned to the model, not crashes.
  • Observation: the result is incomplete or misleading. Mitigation: the model is told what the tool could not do.
  • Continuation: the agent loops without converging. Mitigation: a hard limit on turns.
  • Outcome: the answer looks right but is not. Mitigation: evaluation against the original request, and human review for important tasks.

Course project: trace the cycle

Take your First AI Assistant. A user asks: “Which of this month's documents are missing a signature?” Trace all seven steps for that request: what the assistant receives, how it interprets the goal, which tool it would need (a read-only document scan), what the result looks like, and who checks the final answer. You will configure exactly these pieces in the next lesson.

Summary

An agent works in a cycle: receive, interpret, choose, execute, observe, continue or finish, and check. The model interprets and proposes; the application validates, executes, and limits. Every step has a known failure mode, and every failure mode has a known mitigation.

INTERACTIVE EXERCISE

Explore the execution cycle

Select each stage to see what happens, why it matters, a practical example, a common failure, and a safety consideration. Then run the simulation to watch a fictional task move through the whole cycle.

Receive the request

What happens
The agent receives a goal from a user or an approved workflow.
Why it matters
Everything downstream depends on understanding what was actually asked for.
Practical example
“Find the total number of orders in the sample dataset.”
Common failure
The request is vague — “check the orders” — and the agent guesses the wrong goal.
Safety consideration
Requests should arrive through approved channels, not from untrusted instructions hidden in data.

Run the simulation

Fictional task: “Find the total number of orders in a sample dataset.”

Glossary.

Execution cycle
The repeating loop of interpret → choose → execute → observe that an agent runs until the task is done.
Tool call
A structured request from the model naming a tool and its inputs. It is a proposal, not an executed action.
Turn limit
A hard cap on how many times the cycle may repeat, so an agent cannot run forever.
Validation
The application's check that a proposed action is well-formed and permitted before it runs.

Check your understanding.

5 questions. You get an explanation after every answer, and you can change your answer to try again.

1. In the execution cycle, who executes a tool?
2. What does a model have access to out of the box?
3. Why does the cycle include a turn limit?
4. A tool fails and returns an error. What should happen?
5. Put these in order: execute the tool, choose an action, observe the result.

Saved in this browser only.

Need help implementing an intelligent workflow?

Explore AI Agents & Automation