6.2.5 · D5AI Agents & Tool Use
Question bank — Memory systems for agents
Before we start, some plain-word anchors so nothing below uses a term you haven't met.




True or false — justify
Working memory is just a fancy name for the conversation history file on disk.
False. Working memory is the active text inside the context window for the current step; conversation history on disk is episodic storage that must be retrieved into working memory to be used.
A bigger context window removes the need for episodic and semantic memory.
False. A bigger window delays the ceiling but doesn't remove it — it's finite, costs grow with tokens, and stuffing everything in adds retrieval noise; you still want to select what matters.
Semantic memory should store facts even when they are event-specific like "the user asked about billing on June 26."
False. That's episodic — tied to a timestamp and an event. Semantic memory holds the timeless distillate, e.g. "user_123 had a billing dispute," not the specific conversation turn.
Cosine similarity of between two episodes always means one should be deleted.
False. High similarity flags candidate redundancy, but two near-identical queries can have different outcomes; you merge/delete only when the stored value is genuinely duplicated, not just the query text.
Forgetting old memories always makes the agent worse.
False. Pruning stale, low-importance items reduces retrieval noise and cost, so the relevant memories rank higher and responses stay sharp — forgetting is an optimisation, not just a loss.
The four memory primitives (Write, Read, Update, Forget) are independent operations.
Partly false. Update is logically Read-then-Write on the same key, and Forget is a Write of "nothing"; they're grouped separately because their policies (dedup, decay, privacy) differ, not because they're mechanically unrelated.
A recency-only forgetting policy is safe for a personal assistant.
False. Pure recency deletes an old-but-frequently-used fact (e.g. the user's home address) just because it's old; importance-based scoring using access count and feedback protects such items.
Retrieval by semantic search and retrieval by timestamp answer the same question.
False. Semantic search answers "what is about this topic?"; temporal lookup answers "what happened when?" — an agent asked "what did we discuss last Tuesday?" needs time, not meaning.
Storing everything in a vector database (a store that indexes embeddings for fast similarity search) makes exact-match lookups (like a user ID) efficient.
False. Vector DBs excel at approximate similarity; an exact key like
user_123 is better served by a key-value index. Use the right store for the query type.Spot the error
Write(m, k, v) returns a Value.
Wrong return type. With the memory store, the key and the value, Write returns a new memory state , not a value; it's Read that maps memory + query → value.
"We embed the user query, then delete the closest episode to save space."
Broken logic. The closest episode is the most relevant one to retrieve, not to delete. Redundancy pruning compares stored episodes to each other, never a live query to the store.
An agent loads all 500 past episodes into working memory each turn "so it never misses context."
Overflow error. That blows the budget () and buries the relevant turn in noise; retrieve the top- (say ) relevant episodes instead.
Semantic facts are stored with confidence=1.0 for everything, including "Alice prefers 9am meetings."
Miscalibrated confidence. A hard rule ("Python is 0-based") deserves ; a learned preference should carry lower confidence (e.g. ) so newer contradicting evidence can override it.
"Episodic memory needs no summarisation — just store the raw transcript."
Scaling error. Raw transcripts bloat storage and retrieval; each episode stores a summary + key facts + outcome so retrieval returns compact, usable context.
A refund follow-up on Day 5 fails to find the Day-1 episode because the search used the exact string "refund" as a keyword.
Wrong retrieval mode. Keyword match misses paraphrases; embedding the query and using cosine similarity catches "Is my money back?" against a "refund" episode.
Update is implemented by appending a new fact and never touching the old one.
Missing dedup. Blind appends leave contradictory duplicates ("Alice prefers 9am" AND "Alice prefers 2pm"); Update must merge or replace so retrieval doesn't surface stale values.
Why questions
Why split memory into three layers instead of one big store?
Because the layers answer different questions with different lifetimes — concretely, working holds "the search results I'm filtering right now", episodic holds "the billing chat from Day 1", and semantic holds "pandas reads CSVs". One flat store forced to serve all three would either overflow the window or drown the right item in noise (see the flow sketch above).
Why use cosine similarity rather than raw distance between embeddings for retrieval?
Cosine compares direction (meaning) and ignores vector length. In the embedding sketch, "refund" and "money back" point the same way and score high even if one text is far longer — length shouldn't change relevance.
Why does episodic memory feed back into semantic memory over time?
Repeated episodes reveal timeless patterns — three separate "billing error" episodes distil into the one durable fact "user is billing-sensitive," moving event data into general knowledge and freeing episodic space.
Why is a token budget preferred over a fixed number of past turns for working memory?
Turns vary wildly in length; "last 5 turns" could be 200 tokens or 5000. As the budget sketch shows, only tokens count against the window, so a token budget directly respects the hard context window limit while a turn count can silently overflow.
Why might a knowledge graph (facts stored as entity–relation–value links) beat a flat key-value store for semantic memory?
A graph encodes relations (
pandas —function_for→ CSV_reading), letting the agent hop from "pandas" to the related "import pandas as pd" fact during answer construction, which isolated key-value pairs can't express.Why does importance scoring combine access count, recency, and user feedback rather than any single one?
Each catches a different kind of value — a frequently-read address (access), a fresh appointment (recency), a user-starred note (feedback). Any single factor alone would wrongly discard items the others would save.
Edge cases
What happens on the very first interaction, when episodic and semantic memory are empty?
Retrieval returns nothing, so the agent runs on working memory alone (a clean stateless call) and seeds the stores by writing this interaction — degenerate but correct behaviour.
A user asks the same trivial question ("What's the weather?") 50 times. What should forgetting do?
High access count suggests importance, but low intrinsic value and staleness (last-year weather) mean these should be pruned; importance policies weight feedback and semantic value, not access count alone, so noise doesn't survive.
Two stored facts directly contradict: ("Alice","prefers_time","09:00") and ("Alice","prefers_time","14:00").
The newer/higher-confidence fact should override via Update+pruning; keeping both breaks retrieval, so the system must resolve contradictions rather than store both.
A retrieved episode is highly similar to the query but from a different user.
Semantic similarity isn't enough — retrieval must filter by entity/user_id first, else the agent leaks or misapplies another person's context (a privacy and correctness failure).
The context window is smaller than the system prompt plus required output buffer.
Working memory size goes to zero or negative — the task can't fit; the agent must summarise/compress prior context or offload to episodic memory before it can proceed at all.
An embedding model is swapped mid-deployment. Do old stored embeddings still work?
No. Similarity is only meaningful within one embedding space. Concretely, if the old model mapped "refund" to but the new model maps the same word to , the old vector and a new query vector are in different coordinate systems, so cosine similarity returns nonsense — the store must be re-embedded.
A user requests deletion of all their data ("right to be forgotten").
Forget must cascade across all layers — working (drop on session end), episodic (delete by user_id), and any semantic facts derived from them — a single-layer delete leaves recoverable traces.
Recall The mantra, as a picture
Every failure on this page is one of three ideas ignored — match query type to store, match data lifetime to layer, and prune by value not just age. The mind-map below ties them together.
