Working memory, retrieval and forgetting
medium 6 minMemory is an application policy for carrying information between decisions.
Video lesson · Chapter 1 of 4
Two home addresses in the drawer
Theory
Read or listen first. About 2 min.
What it is
Memory is an application policy for carrying information between decisions. It governs what is written, who can retrieve it, which source wins a conflict, and how information expires or is removed. The current prompt contains only the memories selected for this turn.
Why it exists
Test correction and deletion, not just successful recall. Old preferences can survive in summaries or caches, and highly similar records can belong to different users. Trace each recalled fact to a current permitted source.
Which shipping address should be recalled?
Inside this chapter
Chapter sources- Memory and continuity
- Memory lets later decisions use observations outside the current prompt. The quality problem becomes deciding what to write, retrieve and discard. A stale preference can be worse than no preference, so record who supplied a fact, when it applied and how it may be corrected.
Memory turns a question of recall into a question of curation: what to write, what to bring back and what to retire. Provenance is the safety net. If each entry records who supplied it, when it took effect and what superseded it, a wrong recall can be traced and corrected; without that, an old preference keeps resurfacing and nobody can say why.
Example. Quote shipping to the user’s corrected address. Check which memory entry supplied it and when the earlier entry was superseded.
Two address memories for one customer
Entry Value Supplied by Effective Status addr-1 12 Elm Road user, signup form Jan superseded by addr-2 addr-2 8 Quay Street user, chat correction Mar current Illustrative entries. The quote must cite addr-2 and the record must show when addr-1 stopped applying. - Types of Memory
- Working memory holds immediate task state. Episodic memory records events, semantic memory stores facts and procedural memory represents reusable strategies. These are design categories, not mandatory separate databases. A user’s preferred language and a record of yesterday’s failed booking have different update rules.
The categories matter because their update rules differ. A semantic fact is overwritten when corrected, an episodic event is appended and never edited (it happened), and working memory is discarded when the task ends. They can live in one database; what matters is that each record knows which kind it is.
Example. Separate “customer prefers email” from “yesterday’s email bounced.” One is a revisable fact; the other is a dated event.
Four design categories
Working
Current task state: order 42, step 3 of 5.
Episodic
Dated events: yesterday's email to them bounced.
Semantic
Revisable facts: prefers email, speaks Welsh.
Procedural
Reusable strategy: check stock before quoting delivery.
- Memory Storage Patterns
- Store exact transactional facts in a typed record with an owner. Store searchable narratives with provenance and permissions. Summaries reduce context cost but can discard important exceptions. Retain a route back to authoritative evidence for facts that affect downstream decisions.
Put anything you will act on exactly, such as booking IDs, amounts and addresses, in typed records with an owner. Put soft context, such as preferences and history, where it can be searched by meaning, with provenance and access rules. Summaries save context but compress away exceptions, so any fact that drives a decision needs a path back to the authoritative record.
Example. Keep a booking ID in structured state while storing the customer’s natural-language preferences in searchable notes. Link both to the correct owner.
Typed records and searchable notes, linked by owner
Exact facts live in typed fields; narrative preferences live in a searchable store with provenance. - Memory Retrieval Strategies
- Retrieve memories using identity, scope, relevance, recency and authority. Filter by access before packing the prompt. A high-similarity note from an old project may conflict with a current explicit instruction. Define precedence rules and test contradictions, deletions and wrong-user retrieval.
Similarity search has no idea who is allowed to see what, so access filtering has to come first. After ranking, precedence rules resolve conflicts: an explicit current instruction beats an old inferred preference however similar it scores. Test with deliberately confusing data, such as two projects with the same customer name, plus a deleted note that would otherwise rank first.
Example. Two projects use the same customer name. Filter by authorized project identity before ranking semantically similar notes.
Another example. A sales assistant serving two accounts both called Northwind must filter by account ID before searching notes, or it will quote one account's discount to the other.
Filter first, rank second - 1Identify scopeuser U-3, project Atlas
- 2Filter by accessdrop other projects' notes
- 3Rank eligible notesrelevance and recency
- 4Apply precedenceexplicit instruction wins
- 5Pack the prompttop items with sources
Ranking before filtering lets a high-similarity note from the wrong project into the prompt.
- Memory Decay & Forgetting
- Forgetting can mean expiration, explicit deletion, supersession or reduced retrieval weight. These operations have different guarantees. Lowering a score does not delete a record. Propagate required deletions to indexes, summaries and caches, and verify the item no longer reappears.
Forgetting covers four different operations: expiry (gone after a date), deletion (removed on request), supersession (still stored but replaced) and down-weighting (still retrievable, just less likely). Only deletion carries a guarantee that the data cannot reappear, and it only holds if it reaches every copy, including summaries written before the deletion. Verify by searching for the old content rather than trusting the delete call.
Example. Remove one address and search its old wording in both the vector index and derived summaries. Both paths must respect the deletion.
A deletion must reach every derived copy
Search for the old wording on every path afterwards. Any hit means the deletion is incomplete.
How it works
Step through the idea, or press Play.
Candidate facts. Old home · new home
Understand it
Worked example
Which shipping address should be recalled?
- 1
Old home · new home
Both entries belong to the same customer. Each has a source, effective date and correction history.
- 2
User-confirmed new home
Remove superseded or unauthorized entries. Similarity and recency can rank eligible facts but cannot override an explicit correction rule.
- 3
Use confirmed address for a quote
For a consequential shipment, confirm the destination under the product policy. Memory is evidence, not blanket permission to commit.
Follow the handoffs
Eligibility before ranking
Summary
The whole topic in one minute.
Derived memory can continue surfacing a removed fact. Eligibility, deletion and ranking must be handled distinctly.
Test correction and deletion, not just successful recall. Old preferences can survive in summaries or caches, and highly similar records can belong to different users. Trace each recalled fact to a current permitted source.