Module 2 Lesson 1: Agent Components
Dissecting the agent. Understanding the four pillars: LLM, Memory, Tools, and the Control Loop.
Agent Components: The Four Pillars
To build a professional agent, you must stop thinking of it as a "prompt" and start thinking of it as a System. Every agent is composed of four distinct components working in harmony. If one of these pillars is weak, the agent will fail.
1. The LLM (The Brain)
This is the reasoning engine. It takes in the current state and decides what happens next.
- Power level matters: A small model (8B) might be good for simple tool calls, but you usually need a larger model (30B+) to handle complex, multi-step planning or error recovery.
2. Tools (The Hands)
Tools are the interfaces through which the agent interacts with the world. A tool is essentially a function that the LLM has "permission" to run.
- Examples: A Google Search API, a SQL database connection, or a Python interpreter.
- Critical Requirement: Every tool needs a Description. The LLM doesn't see your Python code; it only sees the description you wrote for that code.
3. Memory (The Experience)
Memory allows the agent to maintain context over time. Without memory, every step of the loop would feel like the first step.
- Conversation History: What did the user just say?
- Action Log: Which tools have I already tried? (To avoid infinite loops).
- Knowledge Base: Private data the agent can "read" (RAG).
4. The Control Loop (The Orchestrator)
This is the "while loop" that keeps the agent running. It is the Glue that connects the LLM to the Tools and Memory.
- The Process:
- Send context to LLM.
- Parse the LLM's response for tool calls.
- Execute the tool and capture the output.
- Save the output to Memory.
- Repeat until the "Goal" is reached or a "Limit" is hit.
5. Architectural Diagram: The Agent Stack
graph TD
User[User Input] --> CL[Control Loop]
subgraph Agent System
CL <--> LLM[LLM Brain]
CL <--> MEM[Memory / State]
CL --> TOOLS[Toolbox]
TOOLS --> World[External Systems]
World --> CL
end
CL --> Out[Final Response]
6. Code Example: Dissecting the "Tool"
In a framework like LangChain, a "Tool" looks like this. Notice how the Docstring is actually "Code" for the LLM.
from langchain.tools import tool
@tool
def calculate_area(radius: float) -> str:
"""Useful for calculating the area of a circle.
The input should be a numeric radius."""
# The code below is for the COMPUTER
import math
area = math.pi * (radius ** 2)
return str(area)
# The LLM reads the description above and decides when to call this.
Key Takeaways
- The LLM is the "Reasoning Engine."
- Tools are "External Capabilities" described in plain language.
- Memory preserves state and prevents repetitive errors.
- The Control Loop is the operational cycle that manages the flow.
- Descriptions are Code: Writing a poor tool description is the #1 reason agents fail to use tools correctly.