Module 15.1 introduced memory as a core agent primitive alongside the agent loop, tool calling, and human in the loop. Module 15.2 splits that primitive into types. Episodic memory is first: it stores what happened in a particular run, session, or trajectory—not general facts.
Next lectures contrast this with semantic memory (facts and concepts), working memory (the live scratchpad), and long-term memory (what you persist across sessions). Frameworks in LangGraph and CrewAI later wire these stores into agent graphs and crews.
Learning Objectives
By the end of this lesson, students should be able to:
- Define episodic memory for agents as time-stamped, contextual traces of past events.
- Distinguish an episode (a specific run) from a semantic fact and from working-memory scratch.
- Design a minimal episode record: goal, actions, observations, outcome, timestamp.
- Retrieve similar past episodes to improve planning and avoid repeating failures.
- Identify failure modes: noisy logs, privacy leaks, and treating every chat turn as an episode.
- Place episodic stores relative to RAG/vector stores used as long-term semantic memory.
Episodic memory (in cognitive science and in agent systems) is memory of specific experiences—events bound to time, place, actors, and outcome. For an AI agent, an episode is typically one task run or conversation session: the goal, the tool calls, the observations, the human interventions, and whether the run succeeded.
Why Agents Need Episodes, Not Just Facts
A support agent that only knows “refunds require a receipt” (semantic) still fails if it cannot recall “last Tuesday this user already submitted receipt R-441 and was denied for policy X.” Episodes capture situated history. They let the planner reuse successful trajectories and skip dead-ends—similar in spirit to how reinforcement-learning agents store trajectories, but here the “policy” is an LLM plus tools.
| Memory type | What is stored | Typical agent artifact |
|---|---|---|
| Episodic | Dated events and outcomes | Run logs, trajectories, session recaps |
| Semantic | Facts, concepts, policies | KB, wiki, vector RAG corpus |
| Working | Current task scratch | Context window, graph state |
| Long-term | Anything persisted across sessions | DB + vector store + episode archive |
Anatomy of an Agent Episode
Identity
- episode_id, user_id, thread_id
- started_at / ended_at
- goal or user intent
Trace
- Thoughts / plan steps
- Tool names + arguments
- Observations / errors
Outcome
- success / fail / aborted
- human overrides (HITL)
- short recap for retrieval
A Minimal Episode Store
Production systems often use a database plus embeddings of recaps. The sketch below is enough to teach write, retrieve-by-similarity, and recency—the three operations most agentic workflows need.
Retrieval Policies That Matter
Dumping every past episode into working memory blows the context window. Prefer: (1) recency for the same user/thread, (2) similarity of goal or error signature, (3) outcome filter (prefer successes when planning, failures when debugging). Summarize traces into recaps before embedding—raw tool JSON is a poor semantic query target.
Strengths
- Personalizes behavior without retraining
- Enables “do not repeat this failure” learning
- Supports audit and HITL review
- Natural fit for multi-step agent traces
Tradeoffs
- Storage and PII growth
- Noisy traces poison retrieval
- Stale episodes contradict new policy
- Easy to confuse with semantic KB
“Episodic memory is just the chat history.” Chat history is working memory while the thread is live. An episode is a compact, retrievable record of a completed (or aborted) experience, often stored outside the prompt and fetched only when relevant. Unbounded chat logs are not a memory architecture.
Knowledge Check
- Short Answer: What binds an episodic memory that a semantic fact lacks? Answer: Time/context—a specific event, actors, and outcome.
- True/False: A vector store of company policies is primarily episodic memory. Answer: False—that is semantic (and usually long-term).
- Multiple Choice: The best recap to embed is: (a) raw tool JSON dumps, (b) a short outcome-focused summary, (c) the full token stream. Answer: (b).
- Short Answer: Name two retrieval keys for episodes. Answer: Recency (same user/thread) and similarity of goal/error.
- True/False: HITL overrides belong in the episode trace. Answer: True—they explain why the agent changed course.
- Multiple Choice: Working memory during a live run is closest to: (a) the context window/scratchpad, (b) a wiki, (c) a cold archive. Answer: (a).
- Short Answer: Why not inject all past episodes into every prompt? Answer: Context limits, noise, cost, and privacy.
- True/False: Failed episodes are useless and should be deleted immediately. Answer: False—they help avoid repeating failures.
- Multiple Choice: An episode_id + user_id + recap is mainly for: (a) CNN pooling, (b) write/retrieve of experiences, (c) MCP transports. Answer: (b).
- Short Answer: Which next lecture covers facts and concepts rather than events? Answer: Semantic Memory.
Key Takeaways
- Episodic memory stores situated experiences: goal, trace, outcome, time.
- It is not chat history, not a policy wiki, and not the live scratchpad.
- Write compact recaps; retrieve by recency and similarity.
- Guard PII and stale traces; episodes can poison future plans.
- Continue with Semantic Memory for facts vs events.
Lab: Log three toy agent runs (one success, two distinct failures). Implement recency + keyword similar() and show which episodes a new “SSO contractor” goal retrieves.
Whiteboard: Draw one user journey with working memory (inside the loop), episodic write (after the loop), and semantic lookup (policy KB). Mark where HITL annotations attach.
Recap: Episodic memory is the agent’s dated experience log. Continue with Semantic Memory.