The Agent Loop: Perception → Reasoning → Action → Observation
Breaking down the perception → reasoning → action → observation cycle, how LLMs make decisions inside an agent, and why agents are fundamentally different from chatbots.
What is the perception–reasoning–action loop of an AI agent?
An AI agent repeats four steps: perception (it reads the request, memory and earlier tool results), reasoning (the model decides to answer, call a tool or stop), action (your code runs the tool) and observation (the result goes back into the context). The loop ends with a final answer or at an iteration limit.
AI Agents: From Architecture to Production
From the agent loop and tool calling to memory, orchestrator–worker systems, MCP and production concerns. Based on Microsoft's open AI Agents for Beginners course, with code on the Claude API.
The rest of this lesson opens after a free sign-up
Sign up with email or Google: the first two lessons of every course stay open for good, and the whole catalog is open for 7 days. No card needed.
Chatbot vs AI agent
| Chatbot | AI agent | |
|---|---|---|
| Passes per request | One reply | Many: a loop of model calls |
| Tools | None | Calls tools: search, code, APIs, files |
| Planning | Answers the message as written | Plans steps and revises the plan mid-task |
| When it stops | After one reply | Final answer, iteration limit or a stop signal from a tool |
| Who controls it | The user, message by message | The model inside limits set by your code |
One iteration of the loop
- PerceptionRequest, memory, previous tool results
- ReasoningThe model picks: answer, call a tool or finish
- ActionYour code runs the tool or API call
- ObservationThe result is appended to messages, then back to step 1
Notes for running the lesson code
Checked on 9 Nov 2026 against the Claude docs and Anthropic's engineering guide.


