Applied LLM Systems: RAG, Agents & MCP / Agents and Tools
Plan, act, observe, reflect.
Reviewed by Yuvaraj
An agent's power comes from repetition with feedback. That repetition has a shape, and almost every tool-using agent follows some version of it: plan → act → observe → reflect, over and over, until the goal is met.
Answer from memory before revealing, retrieval practice is what builds durable recall.
Which sequence describes one iteration of a typical agent loop?
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.
Take the goal "What is a 15% tip on a bill of 80?" with a calculator tool available:
calculator("0.15 * 80").12.12.One iteration was enough here. A harder goal simply runs more iterations, each new observation feeding the next plan.
For a curious beginner
Think of cooking from an unfamiliar recipe. You read the next step (plan), do it (act), taste the result (observe), and decide whether to continue, add salt, or fix a mistake (reflect). You could not have decided the salt in advance, you had to taste first. An agent works the same way: it cannot know a step's result until it takes the step.
How it is actually used
Each iteration is a model call whose prompt includes the goal and the trace so far. The model emits a structured action, typically a tool name and JSON arguments. The runtime executes the tool, appends the result to the trace, and calls the model again. A stop condition (an explicit "finish" action, a satisfied goal, or a step budget) ends the loop. The trace is the memory; keeping it faithful is what makes the next decision sound.
The underlying mechanism
The loop is a state machine. Let be the state (goal plus trace) at step . A policy chooses an action, the environment returns an observation , and the state updates:
Reflection is a test that halts the loop or lets it continue. The framing is deliberately close to a reinforcement-learning agent acting in an environment.
Drop reflection and you get a script: a fixed sequence that cannot notice when a step failed. Reflection is what lets an agent see "that returned an error" or "that did not answer the question" and choose a different action instead of charging ahead. It is the difference between an agent that recovers and one that fails silently.
Try it in the Agent Loop Simulator
The linked lab steps through plan/act/observe/reflect one phase at a time so you can watch the trace build. Its tools are real but small, the calculator genuinely evaluates the expression, and "research" looks answers up in a fixed table and admits when it has no source rather than inventing one. Planning is scripted, not a live model, so the loop's shape is the lesson, reproducibly.