Module · 5 lessons

Memory and State

Give your agent memory — manage the running conversation, summarize long histories, and store durable facts in a vector memory the agent can retrieve across sessions.

At a glance

Level
Intermediate
Lessons
5 lessons
Time to complete
1 week
Cost
Free forever · no sign-up

Welcome to Memory and State, the fourth module. So far Atlas remembers everything within a single run — but only because the agent loop keeps appending to one growing list. That list is the agent’s memory, and once you see that clearly, two problems follow: the list grows without bound (eventually overflowing the model’s context window and running up cost), and it vanishes when the session ends (so the agent never remembers a returning user). This module solves both.

You’ll start by recognizing that the messages list is short-term memory, then learn to keep it manageable — truncating old turns and summarizing long histories so the agent stays within the context window without losing the thread. Then you’ll add long-term memory: a vector store where the agent saves durable facts and retrieves the relevant ones by meaning, across sessions. The module ends by giving Atlas both — a managed conversation and a memory of the traveler’s preferences.

The memory mechanics here — truncation, summarization compaction, and vector retrieval — are all real, runnable Python, verified end to end. The long-term store runs locally (no API key); for production-quality semantic search you’ll swap in the same sentence-transformers/chromadb stack used in the Generative AI course. Start with Lesson 1.

Lessons in this module

Achievement

Complete all 5 lessons to finish the Memory and State module.

Start module