Agent Architecture: Tools, Memory and Decisions
You understand how agents use tools, retain context and make autonomous decisions.
Why this lesson matters
Building an agent without understanding the architecture is like building a house without foundations. You get something that works sometimes, but you don't know why it fails. In this lesson you learn exactly how an agent works under the bonnet: which tools it uses, how memory works, and how it makes decisions.
You need this knowledge to build agents of your own that are reliable, instead of agents that happen to get it right now and then.
Tools: what an agent can "do"
An LLM can only generate text. Tools give an agent hands. Each tool is an action the agent can carry out:
| Tool type | What it does | Example |
|---|---|---|
| API calls | Talk to external services | Fetch the weather, send an email |
| Reading files | Analyse documents | Summarise a PDF report |
| Database queries | Fetch or write data | Pull customer details from the CRM |
| Web search | Find current information | Latest news on a topic |
| Running code | Do calculations | Run an Excel analysis |
| Triggering actions | Start processes | Create an invoice in the accounting system |
The power of an agent comes from its tools. An agent without tools is a chatbot. An agent with the right tools can automate the work of a whole department.
Memory: short vs long term
Agents have two kinds of memory:
┌─────────────────────────────────────┐
│ AGENT MEMORY │
│ │
│ Short term Long term │
│ ┌─────────────┐ ┌──────────────┐ │
│ │ Current │ │ Knowledge │ │
│ │ conversation│ │ Base │ │
│ │ │ │ (documents, │ │
│ │ Context │ │ FAQ, rules) │ │
│ │ window │ │ │ │
│ └─────────────┘ │ Earlier │ │
│ │ interactions │ │
│ └──────────────┘ │
└─────────────────────────────────────┘Keep reading
Leave your name and email address and you can read the rest
You get the whole lesson right away, and every other lesson stays open after that. No password, no confirmation email.
Short-term memory is everything in the current conversation. Just like your working memory: you remember what was just said, but after the conversation it's gone. With LLMs this is called the context window. It has a limit.
Long-term memory is stored knowledge the agent can always consult: manuals, customer data, earlier conversations, company rules. This is often stored in a Knowledge Base or vector database.
The context window of a language model is limited. Where that limit sits differs per model and moves up every six months. If a conversation gets too long, the agent "forgets" the beginning. Long-term memory through a Knowledge Base solves this.
Decisions: how an agent chooses
The clever part of an agent is that it decides for itself which tool to use. It works like this:
- 1The agent receives a question
- 2The LLM analyses what's needed
- 3The LLM picks the right tool (or combination of tools)
- 4The tool runs
- 5The result goes back to the LLM
- 6The LLM writes an answer or picks the next step
This sounds simple, but it's what makes agents truly different from a script. A script always follows the same steps. An agent adjusts its approach to the situation.
The ReAct pattern
Most agents work along the ReAct pattern: Reason → Act → Observe → repeat.
Question: "How many open invoices does customer Jansen have?"
→ REASON: I need to look up customer details. I'll use the CRM tool.
→ ACT: [CRM tool] Search customer "Jansen"
→ OBSERVE: Customer found: ID 4821, 3 open invoices
→ REASON: I've found the invoices. Let me fetch the details.
→ ACT: [CRM tool] Fetch invoices for customer 4821
→ OBSERVE: Invoice #891 (€1,200), #903 (€450), #917 (€3,100)
→ REASON: I have all the info. I can answer now.
→ ACT: [Answer] "Customer Jansen has 3 open
invoices, €4,750 in total."The ReAct pattern works well because the agent thinks again after every step. If a tool returns an error, the agent can try a different approach, just like a person who notices plan A isn't working and switches to plan B.
Example: handling a customer question step by step
A customer emails: "I ordered a laptop last week but haven't received anything yet. Can you check the status? Order number: ORD-29481."
The agent runs through the ReAct pattern:
| Step | Action | Result |
|---|---|---|
| 1. Reason | Email contains an order number, I'll look up the status | -- |
| 2. Act | [Order system] Search ORD-29481 | Status: shipped, tracking: 3SABC123 |
| 3. Observe | Order has shipped, but tracking shows a delay | -- |
| 4. Reason | Customer wants to know where the parcel is, I'll check tracking | -- |
| 5. Act | [Tracking API] Check 3SABC123 | Delayed, expected tomorrow |
| 6. Reason | I have all the info, I'll draft a reply | -- |
| 7. Act | [Email tool] Send reply to customer | Sent |
What is the difference between short-term and long-term memory in an agent?
In the ReAct pattern, what does the agent do after the "Act" step?
Why is an agent truly different from a script?
Want to keep your progress, get the practice files and sign up for the free evening? Create a free account. All you do is click a link in your email.
Create a free account