Agent Fundamentals
How AI agents work: the observe-think-act loop, core agent patterns, architecture, and when to use agents versus simpler approaches.
Learning Objectives
- •Explain the observe-think-act loop that drives all agent behavior
- •Distinguish between ReAct, planner, and tool-user agent patterns
- •Map agent architecture components and their responsibilities
- •Apply a decision framework to determine when agents add value
- •Connect agent fundamentals to tool use patterns in the next section
From LLMs to Agents
BasicFrom LLMs to Agents
You now understand how LLMs process text, use context windows, and call functions. But an LLM on its own is reactive — it waits for a prompt and responds once.
What happens when we put an LLM in a loop, give it goals, and let it decide what to do next? That's an agent. This section shows how the pieces you've learned combine into autonomous systems.
The Observe-Think-Act Cycle
BasicThe Observe-Think-Act Cycle
Every AI agent -- regardless of framework, model, or use case -- runs on the same fundamental loop. Understanding this loop is the single most important concept in agentic AI.
The Loop
- Observe -- The agent reads its current context: user instructions, tool outputs, environment state, and prior conversation history.
- Think -- The Large Language Model (LLM) reasons about what to do next. It weighs the goal against what it has learned so far and selects a strategy.
- Act -- The agent executes an action: calling a tool, writing output, requesting human input, or deciding the task is complete.
The loop repeats until the agent reaches its goal or determines it cannot proceed.
Why This Matters
Traditional software follows a fixed path: input goes in, output comes out. An agent is different. Each iteration of the loop can change direction based on what the agent discovers. A coding agent might:
- Observe: Read a failing test and its error message
- Think: Determine the root cause is a missing null check
- Act: Edit the source file and re-run the test
- Observe: See the test now passes
- Think: Decide the task is complete
This adaptive behavior is what separates agents from static pipelines. The agent does not need every step pre-programmed -- it figures out the path as it goes.
The Loop Has Guardrails
In production systems, the loop is bounded by constraints:
| Guardrail | Purpose | Example |
|---|---|---|
| Max iterations | Prevent infinite loops | Stop after 25 tool calls |
| Token budget | Control cost | Cap at 100k tokens per task |
| Timeout | Ensure responsiveness | 5-minute wall-clock limit |
| Human approval gates | Maintain oversight | Require approval before file deletion |
These guardrails are not optional. Without them, an agent can run up costs, get stuck in loops, or take destructive actions.
Agent Architecture Overview
BasicAgent Architecture Overview
Every agent system shares the same core components, regardless of the framework or model powering it.
- Tool output
- User input
- State
- LLM reasoning
- Plan / ReAct
- Decide next step
- Tool calls
- Responses
- Delegations
- Conversation
- Long-term
- Retrieval
- APIs
- File I/O
- Search
- Max iterations
- Cost caps
- Approval gates
- Task progress
- Context window
Component Responsibilities
- Observe: Gathers all available context -- tool results, user messages, and the agent's own state -- into the LLM's input window.
- Think: The LLM processes the context and decides what to do next. This is where reasoning, planning, and decision-making happen.
- Act: The agent executes its chosen action. This could be a tool call, a final response, or a request for human input.
- Memory: Stores conversation history and retrieved knowledge. Keeps the agent grounded across long interactions.
- Tools: The agent's interface to the outside world. Without tools, an agent can only generate text.
- Guardrails: Safety and cost controls that bound the agent's behavior. Essential for production deployment.
- State: Tracks task progress, intermediate results, and context window management.
The key insight: the LLM is only the "Think" component. Everything else -- observation, action, memory, tools, guardrails -- is infrastructure that you build around it.
A Critical Note on Safety
BasicA Critical Note on Safety
Before we go further, pause and consider this: agents that can take actions can also cause harm if unchecked.
An agent with database access can delete records. An agent with email access can send messages to customers. An agent with file system access can overwrite important data. These aren't hypothetical risks — they're direct consequences of giving AI systems the ability to act.
Guardrails, human oversight, and bounded permissions aren't optional extras — they're architectural requirements.
As you learn about tools, RAG, and multi-agent systems in the sections ahead, keep this principle in mind: every new capability needs a corresponding control. More tools means more potential for misuse. More autonomy means more need for oversight. More power means more responsibility in the system design.
We'll cover safety and governance in depth in a dedicated section, but this mindset should inform everything you build from here forward. The question isn't just "can the agent do this?" — it's "what happens when it does this wrong, and how do we limit the damage?"
Section Recap
BasicKey Takeaways
Before you move on, here's what to remember from this section:
- The agent loop — observe, think, act — is the core pattern driving all agent behavior
- Agent patterns vary by need: ReAct for adaptability, Planner for structured tasks, Tool-User for simple actions
- Architecture components include the LLM (brain), tools (hands), memory (context), and orchestration (control flow)
- Not everything needs an agent — use agents when tasks require multi-step reasoning, tool use, or adaptive behavior
- Guardrails are essential — iteration limits, loop detection, and evaluation steps prevent runaway costs and errors
Check Your Understanding: Agent Fundamentals
BasicTest Your Knowledge
5 questions selected from a pool based on your difficulty level. Retry for different questions.
~5 min