What Is an AI Agent?
A Large Language Model (LLM) is a text-in, text-out system. You send it a prompt; it responds. That's powerful — but fundamentally reactive.
An AI agent is different. An agent is an LLM equipped with:
- Tools it can call (search the web, run code, write files, call APIs)
- Memory it can read from and write to (conversation history, vector databases)
- A planning loop that lets it break down goals into steps
- Reflection — the ability to evaluate its own outputs and try again
The result is a system that can pursue open-ended goals autonomously over multiple steps, rather than answering a single question.
The Agent Loop
Every AI agent runs some variation of this loop:
- Perceive — receive a goal or observation (user request, tool result, environment state)
- Reason — think through what to do next (which tool to call, what to say)
- Act — call a tool, produce output, or ask for clarification
- Observe — receive the result of the action
- Repeat — continue until the goal is achieved or a stopping condition is met
LLM vs Agent: A Concrete Comparison
| Capability | Plain LLM | AI Agent |
|---|---|---|
| Single-turn interaction | Yes | Yes |
| Multi-step reasoning | Limited | Yes |
| Call external APIs | No | Yes |
| Browse the web | No | Yes |
| Run code | No | Yes |
| Persist memory | No | Yes |
| Self-correct | No | Yes |
| Pursue long-horizon goals | No | Yes |
A Simple Example
LLM task: "What's the weather in London?"
- LLM: "I don't have real-time data, but London is generally cool and rainy…"
Agent task: "What's the weather in London?"
- Agent calls
weather_api("London")→ gets current data - Agent formats and returns: "Currently 14°C, partly cloudy, wind 18 km/h NW"
The agent actually does the task rather than approximating around it.
The Four Pillars of an Agent
1. Tools
Tools are functions the agent can invoke. They connect the LLM to the real world:
- Search tools — Tavily, SerpAPI, Brave Search
- Code execution — Python REPL, bash shell
- File I/O — read/write documents, PDFs, spreadsheets
- API connectors — GitHub, Slack, email, databases
- Browser — navigate and extract web pages
2. Memory
Agents can access different types of memory:
- In-context memory — the current conversation window
- External memory — vector stores (ChromaDB, Pinecone) for long-term recall
- Episodic memory — logs of past runs and actions
- Semantic memory — structured facts about the world
3. Planning
Agents decompose goals into subtasks:
- ReAct — Reason then Act, interleaving thinking and tool use
- Chain-of-thought — explicit multi-step reasoning before acting
- Task decomposition — break complex goals into manageable sub-goals
- Tree of Thoughts — explore multiple reasoning paths
4. Reflection & Self-Correction
Agents can evaluate their own outputs:
- Check if a tool result makes sense
- Retry with a different approach if the first fails
- Ask clarifying questions when the goal is ambiguous
- Score and rank multiple candidate answers
from anthropic import Anthropic
client = Anthropic()
def run_agent(goal: str, tools: list[dict], max_steps: int = 10) -> str:
messages = [{"role": "user", "content": goal}]
for step in range(max_steps):
# Reason: ask the LLM what to do next
response = client.messages.create(
model="claude-sonnet-4-6",
max_tokens=4096,
tools=tools,
messages=messages,
)
# Check stopping condition
if response.stop_reason == "end_turn":
return response.content[0].text
# Act: execute tool calls
tool_results = []
for block in response.content:
if block.type == "tool_use":
result = execute_tool(block.name, block.input)
tool_results.append({
"type": "tool_result",
"tool_use_id": block.id,
"content": str(result),
})
# Observe: feed results back into the loop
messages.append({"role": "assistant", "content": response.content})
messages.append({"role": "user", "content": tool_results})
return "Max steps reached"Real-World Agentic Systems
Agentic AI is already deployed across many domains:
- Coding assistants — GitHub Copilot Workspace, Devin, Cursor. Agents that read codebases, write code, run tests, and iterate until the task is done.
- Research assistants — systems that search the web, read papers, synthesize findings, and write reports.
- Customer service — agents that look up orders, issue refunds, escalate to humans — without a script.
- Data analysis — agents that write and execute SQL/Python, interpret results, and produce insights.
- DevOps automation — agents that monitor alerts, diagnose failures, and apply fixes.
The Agentic AI Ecosystem
Several frameworks have emerged to make building agents easier:
| Framework | Creator | Key Strength |
|---|---|---|
| CrewAI | CrewAI Inc | Multi-agent collaboration with roles |
| LangGraph | LangChain | Stateful graph-based agent workflows |
| AutoGen | Microsoft | Conversational multi-agent systems |
| MCP | Anthropic | Standard protocol for tool/context access |
| LangChain | LangChain | Rich tool ecosystem and chains |
| Semantic Kernel | Microsoft | Enterprise .NET/Python integration |
In the following chapters, we'll explore each of these in depth.
Knowledge check
Which capability most distinguishes an AI agent from a plain LLM?
Summary
In this chapter you learned:
- An AI agent is an LLM plus tools, memory, planning, and a goal-pursuit loop
- The core perceive-reason-act loop is what makes agents autonomous
- Agents are practical today because modern LLMs reliably call structured tools
- Real agentic systems are deployed in coding, research, customer service, and more
- Frameworks like CrewAI, LangGraph, AutoGen, and MCP provide the scaffolding
In the next chapter, we'll look at the most important agent architecture patterns — ReAct, chain-of-thought, and structured tool use — with real code examples.