Week 03: Memory & Context Management
What You'll Learn
Memory is where most agents break in production. You'll learn when to use in-context memory vs vector retrieval vs external storage, and how to build systems that remember what matters without ballooning costs.
Session Schedule
| Day | Time | Focus |
|---|---|---|
| Saturday | 8:00 - 11:00 PM WAT | Memory Architecture & Vector DBs |
| Sunday | 8:00 - 11:00 PM WAT | Persistent Memory Build |
Pre-Requisites
- Weeks 01-02 completed
- Docker Desktop installed (for PGVector)
- Understanding of embeddings concept
Topics Covered
Short vs Long-Term Memory
ConversationBufferMemory, ConversationSummaryMemory, token budgets. Understanding the tradeoffs between remembering everything and remembering what matters.
Buffer Memory Summary Memory Token BudgetContext Window Management
Sliding window, summarization chains, priority-based context selection. How to keep your agent informed without blowing through your token budget.
Sliding Window Summarization Context SelectionFAISS & Vector Similarity Search
Embeddings, cosine similarity, FAISS index creation, k-NN retrieval. Building fast, local vector search from scratch.
FAISS Embeddings Cosine SimilarityPGVector with PostgreSQL
Docker setup, pgvector extension, CRUD operations, hybrid queries. Production-grade vector storage that scales with your application.
PGVector PostgreSQL DockerMemory Summarization Strategies
Entity extraction, fact storage, cross-session persistence, memory decay. Building memory systems that get smarter over time, not just bigger.
Entity Extraction Persistence Memory DecayWeekly Build: Personalized AI Assistant
Build an assistant that remembers user preferences, past conversations, and extracted entities across sessions using Redis + PostgreSQL.
Architecture
User Message
|
v
Context Loader
├── Redis: Last 6 messages (session)
├── PostgreSQL: Entity store (cross-session)
└── FAISS: Relevant past conversations
|
v
LLM (with full context)
|
v
Response + Memory Update
├── Update Redis session
├── Extract & store entities
└── Index conversation in FAISS
Key Files
| File | Purpose |
|---|---|
main.py | CLI entry point |
memory/session.py | Redis sliding window |
memory/entities.py | PostgreSQL entity store |
memory/vector.py | FAISS retrieval |
assistant.py | Main assistant logic |
Resources
Required Reading
- LangChain Memory documentation
- FAISS wiki — Getting Started
- PGVector GitHub README & usage guide
Code Repository
Switch to the week-03 branch:
git checkout week-03
Session Recording
Recording will be available within 24 hours after the live session. Check the WhatsApp group for the link.
Homework
Due before Week 4 live session.
- Complete the personalized assistant build — push your code to the bootcamp repo
- Add memory decay — implement a strategy that deprioritizes old, unused memories
- Benchmark FAISS vs PGVector — compare retrieval speed and relevance on 1,000+ stored messages
- Write a 1-page reflection on memory tradeoffs — when is more memory actually worse? Share in the WhatsApp group