The vector-memory forgetting policy: 3 dials + my exact values
The short version
Giving the assistant a long term memory made it worse. It recalled anything loosely related, which filled its context with noise, and it stored near-duplicates of the same fact forever alongside meaningless fragments like ok and thanks.
Three limits fixed it: a similarity floor so weak matches are never recalled, a length floor so trivia is never stored, and a deduplication check on write so near-identical memories collapse into one.
Copy these prompts
Paste them into Claude Code (or any AI that can see your project), in this order. Each one answers a different question, and the first is usually the one that matters.
1. Only recall what is genuinely close
My AI stores things it learns and recalls them later. Add a minimum similarity threshold below which nothing is recalled at all, and tell me what fraction of current recalls that would have blocked.
2. Stop storing trivia
Add a rule that skips storing very short or trivial messages such as ok, thanks, or yes. Show me how many of my existing stored memories are that kind of fragment.
3. Never store a near-duplicate
Add a check on write that refuses to store a memory almost identical to one I already have. Then tell me how many near-duplicates are sitting in my store today.
I gave my AI a memory (embeddings + pgvector recall of past intents) and it immediately became a hoarder. It recalled everything vaguely similar, poisoning prompts with noise, and wrote near-duplicate memories forever. AI memory needs a forgetting policy more than a remembering one. Three dials fixed it.
The 3 dials (my exact production values)
1. RECALL FLOOR: similarity ≥ 0.6 below this, a memory does NOT enter the prompt
2. TRIVIA FILTER: skip utterances ≤ 8 chars ("yes", "ok", "hmm" are not memories)
3. WRITE DEDUP: if an existing memory is ≥ 0.92 similar, DON'T write the new one
Why each dial exists
- Recall floor (≥ 0.6). Vector search always returns something. Nearest-neighbor has no concept of "nothing relevant." Without a floor, every query drags its k-nearest garbage into the prompt, and the model treats noise as context. The floor turns "here's whatever was closest" into "here's what's actually related."
- Trivia filter (≤ 8 chars → skip). Short utterances embed poorly and mean nothing later. Memorizing "yes" gives you a memory that's spuriously similar to everything. Cheap length gate at write time kills the whole class.
- Write dedup (≥ 0.92 → already known). Users repeat themselves; agents re-observe the same facts. Without dedup, your store fills with near-copies, which then dominate recall (five copies of one fact crowd out four other facts in top-k) and grow storage forever.
Implementation notes
- Enforce at the boundaries: floor at query time, filter + dedup at write time. Three
ifstatements around your vector store, an afternoon of work:
// write path
if (text.trim().length <= 8) return;
const nearest = await store.topK(embedding, 1);
if (nearest[0]?.score >= 0.92) return; // already known
// read path
const recalled = (await store.topK(qEmbedding, k)).filter(m => m.score >= 0.6);
- Tune from your own distribution. Log similarity scores for a week; the gap between "obviously related" and "obviously junk" clusters tells you where YOUR floor goes. 0.6/0.92 are my values for my embedding model. Start there, verify with data.
- Watch prompt size as the health metric. The symptom of hoarding is recalled-context tokens creeping up while answer quality drops. Track a recalled-memories count, stamped on every trace.
- Consider decay later. Age-weighting and usage-based eviction are the next dials, but the three above got me 90% of the cleanup at 10% of the complexity.
Steal this for your app
- Any RAG/memory feature has these same three failure modes: no floor, trivia ingestion, duplicate accumulation. Audit yours against the three dials whether it's user memory, doc retrieval, or support-ticket context.
- "More context" is not better context: a model with 5 sharp memories beats one with 50 fuzzy ones.
- Design the forgetting policy the same day you design the remembering. Retrofitting one onto a polluted store means re-embedding or bulk-deleting later.
Run this on your codebase
Paste this into Claude Code in your repo:
Audit this repo's vector or memory layer for hoarding.
Find every write to a vector store or memory table and check for a write-dedup similarity threshold; flag writes with no check against existing entries.
Find every recall or top-k query and check for a similarity floor; flag any result set that enters a prompt unfiltered.
Check for a minimum-length or trivia gate at write time; flag ingestion of short utterances.
Check whether recalled-context size or count is stamped on logs or traces.
Propose concrete values for the three dials: recall floor, skip-short filter, write-dedup threshold.
Report findings as a checklist before changing anything.