DevInterviewMasterStart free →
Agentic AI PatternsFree to read

Anatomy of an Agent: Brain, Tools, Memory

Let's open the agent up and look inside

Think of an agent like a worker at a desk : they have a brain (to think), tools on the desk (phone, calculator), a notebook (memory), and a goal pinned on the wall. Let's meet each part.

Key points

The full picture of an agent

┌───────────────────────────┐ GOAL ──────►│ THE AGENT │ │ │ │ ┌──────────────────┐ │ │ │ 🧠 BRAIN (LLM) │ │ │ │ thinks & decides│ │ │ └───────┬──────────┘ │ │ │ decides │ ┌───────────┼───────────┼───────────┐ │ ▼ │ ▼ │ │ ┌──────────┐ │ ┌──────────┐ │ │ │ 📓 MEMORY │◄────►│ │ 🛠️ TOOLS │ │ │ │ remembers│ │ │ act on │ │ │ │ context │ │ │ the world│ │ │ └──────────┘ │ └────┬─────┘ │ │ │ │ results │ │ └──────────┼────────────┘ │ ▼ │ ✅ ANSWER ─────────────┘

The 4 building blocks

Two kinds of memory (very important)

Beginners often miss that agents have two kinds of memory:

We'll dedicate a whole pattern to memory later.

How a single step flows through the parts

Step N: ┌────────┐ reads ┌────────┐ picks ┌────────┐ │ MEMORY │ ───────► │ BRAIN │ ───────► │ TOOL │ └────────┘ └────────┘ └───┬────┘ ▲ │ │ writes result back │ └───────────────────────────────────────┘ (then Step N+1 begins)

▶ Try it: brain + tools + memory + a capped loop

Try changing MAX_STEPS, or add a new tool to the agent dict.

agent = {"brain": "LLM", "tools": ["search", "calc"], "memory": []}

def do_step(thought):
    agent["memory"].append(thought)   # write to memory
    return f"completed: {thought}"

MAX_STEPS = 3                          # always cap the loop!
for i in range(MAX_STEPS):
    print(do_step(f"step {i + 1}"))

print("\nFinal memory:", agent["memory"])

Anatomy mistakes

MistakeConsequenceFix
Stuffing everything into the prompt forever.You blow past the context window; the agent forgets early steps.Summarise old steps or move facts into long-term memory.
No max-step limit on the loop.The agent can loop forever and burn money.Always cap the loop (e.g., 10 steps) and handle the limit gracefully.
Giving the agent too many tools at once.It gets confused about which tool to pick.Give the smallest useful set of clearly-described tools.

Anatomy cheat-sheet

Key takeaways

Frequently Asked Questions

What is Anatomy of an Agent: Brain, Tools, Memory?

Think of an agent like a worker at a desk : they have a brain (to think), tools on the desk (phone, calculator), a notebook (memory), and a goal pinned on the wall. Let's meet each part.

How does Anatomy of an Agent: Brain, Tools, Memory work?

┌───────────────────────────┐ GOAL ──────►│ THE AGENT │ │ │ │ ┌──────────────────┐ │ │ │ 🧠 BRAIN (LLM) │ │ │ │ thinks & decides│ │ │ └───────┬──────────┘ │ │ │ decides │ ┌───────────┼───────────┼───────────┐ │ ▼ │ ▼ │ │ ┌──────────┐ │ ┌──────────┐ │ │ │ 📓 MEMORY │◄────►│ │ 🛠️ TOOLS │ │ │ │ remembers│ │ │ act on │ │ │…

What are the key takeaways about Anatomy of an Agent: Brain, Tools, Memory?

Every agent = Brain (LLM) + Tools + Memory + a Control Loop. The brain only decides; tools perform actions; memory keeps context. Agents have short-term (context) and long-term (database) memory. Always cap the loop and keep tools minimal and clearly described.

Browse all Agentic AI Patterns topics →

Practice this on DevInterviewMaster

Read the full Anatomy of an Agent: Brain, Tools, Memory breakdown with interactive demos, quizzes, and Hinglish notes.

Open the interactive topic →

800+ system-design, LLD, coding, and design-pattern topics. Unlock everything with Pro (₹499, one-time) or Ultimate (₹999, one-time) — lifetime access, no subscription.