GuideIntermediate

Agent Memory And State

This guide gives a Reservo agent memory that survives the end of a session — and directly resolves the limitation left open by the Agent Fundamentals and Tool Calling Guide: there, Ana would book Focus pro, and in a new session the agent remembered nothing because the history only lived as long as the process did. This guide separates that working/short-term memory (already built) from long-term/persistent memory, its actual subject, and within long-term memory distinguishes episodic memory (what happened, dated events) from semantic memory (stable facts and preferences), grounded in real research (Generative Agents, Park et al. 2023; MemGPT, Packer et al. 2023) as its conceptual framework. You build a real persistent store with `sqlite3` (a file on disk, never `:memory:`), extract facts and episodes from an already-run session — never the raw transcript — retrieve relevant memory by user key, recency, and lexical keyword matching (deliberately without embeddings or semantic search, which are named as the production option covered by other guides), update and expire facts that change, and let a member's memory be forgotten entirely on request. Persistence is demonstrated between genuinely separate Python processes, not a variable cleared within the same process. All the engineering runs on Python 3.14 and its standard library; the LLM call is treated as a concept with realistic examples.

64
lessons
8
modules
English · Spanish
available in
Yes
certificate
Free
access
NIEVA

Outcomes

What you'll be able to do

  • Demonstrate, using separate Python processes (not just a cleared variable), why an agent without persistent memory forgets everything the moment its process ends
  • Distinguish working/short-term memory from long-term/persistent memory, and within long-term memory, episodic from semantic memory, grounded in cited real research
  • Design and build a persistent store with `sqlite3` — a real file on disk — with separate tables for episodic memory (dated events) and semantic memory (key-value facts)
  • Extract facts and episodes from an already-run session deterministically, by walking its structured results — never by saving the raw conversation transcript
  • Retrieve a member's relevant memory at the start of a new session by user key, by recency, and by lexical keyword matching, measuring how many results come back and whether the expected one is among them
  • Update a fact that changed, expire one that's stale using a fixed TTL, and fully erase a member's memory on request (forgetting)
  • Inject the retrieved memory into the `system`/initial history of a new session, shaping a memory block ready for the model
  • Measure retrieval quality (whether the expected facts show up) with deterministic Python functions, never a semantic judgment
  • Build the complete memory cycle — write when a session closes, read when the next one opens — verified across two genuinely separate processes that share no Python state
  • Recognize the boundary with memory shared across multiple agents, semantic retrieval at scale (vector DBs), and compaction within an active session, and know which guide to reach for each

Before you start

What you need to bring

It's for you if...

  • Developers who've already built an agent with tool calling and need it to remember users across separate sessions
  • Backend developers who will design a persistent memory store for a production agent without relying on a memory framework
  • Anyone who needs judgment for when key/recency memory is enough and when semantic retrieval with vector DBs is actually needed
  • Anyone who completed the Agent Fundamentals and Tool Calling Guide and wants to resolve the short-term memory limitation that guide left open

Requirements and materials

  • Agent Fundamentals and Tool Calling Guide completed (or equivalent: the agent loop, `messages`, `tool_result`)
  • Basic Python and basic SQL (simple CRUD, a first idea of `sqlite3`)
  • Python 3.14 installed with its standard library; no API key or internet connection required

Content

The syllabus, module by module

Open any of them to see its lessons.

Common questions

What people usually ask

Start whenever you like

Reviews

What students say

These reviews are from enrolled students who completed at least 50% of the course. We moderate reviews only on content grounds (spam, offensive language, personal data), never for being critical or negative.

No approved reviews yet.

Be the first to share your experience!