Agentic AI Notebook
Agent Memory
Phase 5Module 13 of 15

Memory Ranking

Retrieval returns candidates. Ranking picks the ones that should change this answer.

Search results vs the three you actually open.

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%

Conflict

100%
Loading diagram...

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

Two prefs disagree. Recency and source win — not embedding score alone.

Key Takeaways

  • 1.Ranking decides which of the retrieved memories actually enter the prompt. Score by relevance, recency, and importance.
  • 2.A new fact should beat an old contradicting one. Cap how many memories you pack — ranking is how you cap.
  • 3.Combine similarity with recency and a manual importance flag. Deduplicate near-copies.
  • 4.Prefer newer facts when they conflict. Hard-cap the pack list.

Learn elsewhere

  • Memory Retrieval
  • Context Management

Real Example

Scenario

Retrieve 12 prefs. Rank drops duplicates, drops 2023 'likes Java', keeps 2026 'prefers Python' and 'no tabs'. Pack two memories.

What you would do

In Agent Memory, apply Memory Ranking to this scenario: Retrieve 12 prefs. Identify the inputs, run the technique, validate the output, and note one thing you would monitor in production.

Commands

Commands to Remember

  • Relevance + recency + importance
  • New beats old
  • Hard cap
  • Dedupe near copies

Cheat Sheet

Quick recap

quick ref
  • Candidates vs packed
  • Three scores
  • Conflicts: newer wins
  • Cap is mandatory

Common Mistakes

  • Packing every retrieve hit
  • Letting an old fact outrank a new one
  • Ranking only on cosine and ignoring time