Program 03 · Module 04 of 10
Module 04: State, Memory and Retrieval
Manage what an agent knows. You separate conversation state from persistent memory, control context windows, ground answers in retrieved sources, and set retention and privacy rules for stored data.
- Suggested study time
- 7-9 hours
- Prerequisites
- Modules 1 to 3.; Familiarity with embeddings at a conceptual level helps but is taught as needed.
Sign in to track your progress. Every lesson stays free to read without an account.
Learning outcomes
By the end of this module you will be able to:
- Distinguish conversation state from persistent memory.
- Trim and summarise history within a context budget.
- Build a retrieval step that grounds answers in cited sources.
- Use metadata filters so retrieval respects scope and permissions.
- Define retention, deletion and privacy rules for stored data.
Lessons
- 4.1
Conversation State vs. Persistent Memory
Learn the three things people call "memory" in an AI agent, how long each one lives, what each one costs and risks, and how to decide which one a task really needs.
35 min - 4.2
Managing Context Windows and Conversation History
Set a token budget for an agent's context, pin the facts that must never be lost, trim and summarise old messages safely, and shrink tool results once they have been used.
40 min - 4.3
Retrieval-Augmented Generation for Agent Knowledge
Learn how an agent looks up passages from your own documents before it answers, how to cite them, and what can go wrong when the lookup fails.
45 min - 4.4
Vector Search, Metadata Filters and Source Grounding
Learn how vector search finds passages by meaning, how metadata filters keep private documents away from the wrong user, and how to check that an answer cites only what was retrieved.
45 min - 4.5
Memory Retention, Privacy and Data Lifecycle
Decide what an AI agent may remember, for how long, who can see it, and how a person can correct or delete it, then write those decisions down in a memory and retention note.
40 min - 4.6
Practical Lab: Add Retrieval to a Support Agent
Give your agent a help-centre search tool with a staff-only filter, make every answer cite its sources, check those sources in code and test the agent with answerable and unanswerable questions.
1 h 30 min
About 4 h 55 min of lessons in total.
Practical assignment
Practical Lab: Add Retrieval to a Support Agent
Add a retrieval tool over a small fictional knowledge base to a support agent. Answers must cite passages, and the agent must say so when nothing relevant is found.
Deliverables
- Source code for the retrieval tool and the agent.
- A knowledge base of at least 15 fictional documents with metadata.
- A short test report covering answered, unanswerable and out-of-scope questions.
- A memory and retention note for any data the agent stores.
Validation checklist
Use this to check your assignment before you move on.
Knowledge check
Show the answer and explanation
Answer: B. Grounding means a reader can check each claim against a source. Length and tone are not evidence.
Show the answer and explanation
Answer: B. Similarity alone ignores permissions and scope. Filters enforce them before the model sees any text.
PromptFable is independent and is not affiliated with, endorsed by or sponsored by Anthropic, Google, OpenAI or any other vendor. Claude, Gemini, Google AI Studio and other product names are trademarks of their respective owners.