M9-B — Memory, Planning, and Execution
An agent without memory forgets. Without planning it jumps randomly. Without execution it only talks. This note explains all three — simply.
🧠 Part 1 — Memory
Memory = what the agent carries from earlier steps.
Three memory types
| Type | Lasts how long | Example |
|---|---|---|
| Short-term | Current task / chat | "User asked for Mumbai weather" |
| Working | Current multi-step job | "I already searched — now summarising" |
| Long-term | Across days/sessions | User preferences in a .md file |
Open notebook analogy
Short-term = what you hold in your head during one conversation
Working = sticky notes on desk for today's project
Long-term = diary on shelf you open tomorrow
Tools like OpenClaw use markdown files (MEMORY.md, SOUL.md) as long-term memory — the agent reads them before every reply.
User message arrives
↓
Agent loads: MEMORY.md + recent chat + task file
↓
Bigger prompt → smarter continuity
Your Obsidian vault is agent memory if you design it that way — structured notes the AI reads first.
🗺️ Part 2 — Planning
Planning = turning a big goal into ordered steps before or while acting.
Without planning
Goal: "Prepare me for Module 7 exam"
Agent: writes random paragraph about AI history ❌
With planning
Goal: "Prepare me for Module 7 exam"
Plan:
Step 1 — List all Module 7 topics from uploaded syllabus
Step 2 — For each topic, generate 3 MCQs
Step 3 — Ask student to answer
Step 4 — Explain wrong answers using notes
Two planning styles
| ReAct style | Plan-first style |
|---|---|
| Think → act → think → act | Write full plan → execute step by step |
| Good for exploration | Good for predictable workflows |
| Like fixing bike while riding | Like following recipe card |
Backend (simplified):
LLM output: "Thought: I need syllabus first"
LLM output: "Action: read_file(syllabus.pdf)"
Tool returns: [file text]
LLM output: "Thought: now I can list topics…"
⚡ Part 3 — Execution
Execution = actually calling tools and using results — not just describing what you would do.
PLAN says: "Search web for today's news"
EXECUTION: HTTP request → search API → JSON results back
PLAN says: "Save to notes.md"
EXECUTION: write_file("notes.md", content)
| Talk only | Execute |
|---|---|
| "I would search Google" | Search runs, results appear |
| "You should save this" | File saved on disk |
| Stops at advice | Changes something in the world |
Execution is what makes agents dangerous and useful. Dangerous if unchecked. Useful if tools + limits are designed well.
🔗 How memory + plan + execution connect
┌──────────┐
│ MEMORY │──┐
└──────────┘ │
▼
┌─────────┐ ┌───────────┐
GOAL → │ PLAN │ ──→ │ EXECUTE │ ──→ tool results
└─────────┘ └───────────┘
↑ │
└──── update memory ─┘
Each tool result updates memory → next plan step gets smarter.
🛑 Safety rails (must teach)
| Rail | Why |
|---|---|
| Max steps (example: 10) | Stops infinite loops |
| Allowed tools list | No random email sending |
| Human approval gate | "Draft ready — send? Y/N" |
| Log every action | Debug when agent goes wrong |
From Module 6: human-in-the-loop still applies to agents.
✅ Mini exercise
Goal: "Organise my desktop study PDFs list"
Write on paper:
- What memory does agent need?
- What 3-step plan?
- What tools (file list, rename, move)?
- Where does human approve?
Previous: M9-A — What Are AI Agents
Next: M9-C — Autonomous Workflows
Bonus read: Open claw — real system using markdown memory files