Agentic AI Notebook
Agent Memory
Phase 5Module 12 of 15

Memory Retrieval

A store with 10k facts is useless if you inject the wrong 20 — or all 10k.

Asking the librarian for two books, not dumping the shelves on the desk.

Visual Workflows

Start here — scroll inside each diagram frame to explore, then use + / to zoom up to 200% if needed.

Overview

100%
Loading diagram...

Scroll inside the frame to explore · use + / − to zoom up to 200%

100%
Loading diagram...

Scroll inside the frame to explore · use + / − to zoom up to 200%

Retrieve then pack

100%
Loading diagram...

Scroll inside the frame to explore · use + / − to zoom up to 200%

Filter, retrieve, then pack. Skip if nothing matches.

Key Takeaways

  • 1.Retrieval is fetching the few memories that help this turn. Query with the user message plus a bit of session state.
  • 2.Filter by user, time, and type before you rank. Zero hits is valid — do not invent a memory.
  • 3.Build a query from the latest user text and metadata. Filter tenant and type.
  • 4.Retrieve a small k. If empty, proceed without fake memories.
  • 5.Log what you retrieved for debug.

Learn elsewhere

  • Memory Ranking
  • RAG retrievers — Phase 3

Real Example

Scenario

User: 'same as last refund.' Filter user=12, type=episode, last 90 days. Hit: refund #4412. Pack that recap only.

What you would do

In Agent Memory, apply Memory Retrieval to this scenario: User: 'same as last refund. Identify the inputs, run the technique, validate the output, and note one thing you would monitor in production.

Commands

Commands to Remember

  • Query + filter + top-k
  • Always scope by user
  • Empty is allowed
  • Log what you fetched

Cheat Sheet

Quick recap

quick ref
  • Librarian, not a dump
  • Filter then rank
  • Small k
  • Do not invent hits

Common Mistakes

  • Global search across all users
  • k=50 into a 4k window
  • Hallucinating a memory when retrieval is empty