Understanding Agents and the ReAct Pattern
This lesson explains how agents, in which an FM decides which actions to take using tools and observing results, handle open-ended, multi-step tasks that fixed workflows cannot, at the cost of predictability.
Learning outcomes
After completing this lesson, you will be able to:
- Describe the agent loop.
- Explain the ReAct pattern and planning.
- Choose between an agent and a workflow.
The agent loop
An agent combines a model, instructions, tools and memory. Given a goal, the model decides whether it can answer directly or needs a tool. If it needs a tool, it emits a structured tool call; the application runs the tool and returns the result; the model reads the result and decides the next step. The loop continues until the model produces a final answer or a stopping condition ends it. Because the model chooses the steps, the same agent can handle many variations of a task without a predefined workflow.
ReAct and planning
Agents need a way to decide what to do next based on what they have learned so far. The ReAct (reason and act) pattern provides one by interleaving three elements in a loop: a thought, in which the model reasons about what to do next; an action, which is a tool call; and an observation, the tool's result, which informs the next thought. Writing out the reasoning improves tool choice and makes the agent's behaviour traceable when something goes wrong.
Two variants are common. In plan-and-execute, the model first writes a complete plan and then carries out each step, revising the plan when an observation shows it will not work; this suits longer tasks where a coherent strategy matters. In reflection, the agent reviews its result against the task before finishing and corrects mistakes, which improves quality at the cost of extra model calls.
The following diagram shows the thought, action and observation loop.

Thought, action or observation?
Agents versus workflows
Not every multi-step task needs an agent. A workflow, such as a Step Functions state machine or a Bedrock Flow, follows predefined steps and is predictable, testable and cheap. An agent is flexible but less predictable, uses more tokens, and needs safeguards such as iteration limits, least privilege tools and human approval for sensitive actions. A common design uses workflows for the fixed parts of a process and an agent only where the path depends on the situation. The following table compares them.
The following diagram compares the two projects.

Agent or workflow?
Agent or workflow?
An HR team wants to automate onboarding: create accounts, assign a laptop, enrol benefits and send a welcome email, always in that order. A second project should answer employees' free-form questions that may require looking up their leave balance, policies or payslips.
Onboarding has fixed steps and needs auditability, so a Step Functions workflow fits. The employee assistant faces open-ended questions that need different tools, so an agent with read-only tools fits.
What does the ReAct pattern interleave?
Show answer
Thought (reasoning), action (a tool call) and observation (the tool's result), repeated until the task is done.
Exam Tips
Remember for the exam
- Agent loop: model chooses tool, application runs it, model observes, repeat.
- ReAct interleaves thought, action and observation.
- Fixed steps: workflow. Situation-dependent steps: agent.
- Agents need iteration limits, least privilege tools and approvals.