AI Agents / Agent Anatomy
The reason-act-observe loop that makes an agent.
Reviewed by Yuvaraj
A chatbot answers in one shot: you ask, it replies from whatever it already knows. An agent does something fundamentally different, it decides what to do next, takes an action in the world, looks at the actual result, and decides again. That loop of planning and reasoning over real feedback is what lets a model tackle tasks it cannot answer from memory alone: looking facts up, doing arithmetic reliably, calling APIs, and chaining several steps toward a goal.
The workhorse pattern is ReAct (Reasoning + Acting). Instead of emitting a final answer immediately, the model interleaves three kinds of output:
The agent repeats Thought → Action → Observation until a Thought judges the goal met and emits a final answer. The critical property is grounding: every Observation is real data from outside the model, so later reasoning is conditioned on facts rather than on the model's guesses.
Ask about this lesson, or about anything in AI. Answers cite the lessons they draw on.
Finished this lesson?
Mark it complete to earn XP, keep your streak, and schedule a review.
Most robust agents blend the two: draft a lightweight plan, then re-plan reactively as observations arrive. Decomposition breaks one goal into ordered subgoals ("find the countries, then their populations, then subtract"), and reflection (self-critique) adds a step where the agent evaluates its own progress, "Did that search actually answer the question? Is this number plausible?", and revises when it hits a dead end or a contradiction.
Goal: What is the population difference between the two most populous EU countries?
Thought: I can't recall exact populations reliably. First find which EU
countries are most populous.
Action: search("most populous EU countries by population 2024")
Observation: Germany ~83.2M, France ~68.2M, Italy ~59M, Spain ~48M.
Thought: The two most populous are Germany and France. I need 83.2M - 68.2M,
and I'll use the calculator to avoid an arithmetic slip.
Action: calculate("83200000 - 68200000")
Observation: 15000000
Thought: The difference is about 15 million. I can answer now.
Final Answer: The two most populous EU countries are Germany (~83.2M) and France
(~68.2M); the difference is roughly 15 million people.
Notice the search grounds the which countries step and the calculator grounds the arithmetic step, neither is left to the model's unreliable internal guess.
For a curious beginner
How it is actually used
The underlying mechanism
Common mistakes