Before you can read the parent note comfortably, you need to own every symbol and word it throws at you. This page builds each one from nothing, in an order where every idea rests on the one before it. Nothing here assumes you have seen the notation before.
Every idea on this page lives inside one loop: a user speaks, the agent thinks with a language model, and a memory store sits on the side that the agent writes to and reads from. Hold this picture in your head.
Reading the figure: the yellow box on the left is the user; the blue box in the middle is the agent (the program running the loop); the red box on the right is the language model. Yellow arrows carry the user's message into the agent; the blue arrow labelled prompt is the text the agent sends to the model; the red arrow labelled reply is the text coming back. The green box at the bottom is the memory store, with two green arrows — write (agent saves something) and read (agent looks something up). The red note on the right reminds you the model itself forgets after every reply, which is precisely why the green filing cabinet has to exist.
Why the topic needs it: every memory limit in the parent note is measured in tokens, not words. When it says "8K token window," it means the model can only look at about 8000 chunks at once.
Reading the figure, step by step: along the bottom runs a strip of little squares — each square is one token of text, laid out left to right in reading order. The yellow triangle is the context window, the "beam" the model can actually see. The blue (lit) squares sit inside the beam: these are the tokens the model reads and can use for its reply. The grey squares on the left are labelled "lost / out of view" — they were part of the conversation earlier but have scrolled out of the beam and are gone unless something saved them. The grey squares on the right ("not yet seen") are future text that hasn't entered the beam yet. The one takeaway: only the blue tokens inside the beam influence the reply. Everything outside must live in the memory store or be lost.
Now we can define the three chunks that share the beam.
With those defined, the parent's constraint reads cleanly:
Working Memory Size≤Context Window−Prompt−Output Buffer
In words: your scratchpad (working memory) can be at most the whole beam minus the always-present system-prompt instructions minus the reserved reply space. Managing this budget is the job of LM Context Window Management.
The parent writes an episode as {timestamp,user_id,summary,…}. You must know what the braces mean here.
Why the topic needs it: episodic and semantic memory both store bundles of named fields. The braces are just the notation for "these things travel together as one item."
This is the single most important new object in the topic. Take it slowly.
Reading the figure: the two grey axes are two of the (hundreds of) "meaning dimensions" — we only draw two so it fits on a page. Each labelled arrow is one short text turned into an embedding. Notice the green arrows "refund status" and "billing error" point almost the same way and land near each other, while the red arrows "cat photo" and "kitten picture" cluster somewhere else entirely, and "weather today" sits off on its own. Nearby arrows = related meanings. That clustering is the whole reason embeddings are useful.
Why the topic needs it: the parent stores episodes in a vector database and retrieves them by finding embeddings that point in a similar direction to the query's embedding. No embeddings → no semantic search.
Now that meaning is an arrow, how do we score "these two arrows point the same way"?
Reading the figure: the two axes are again meaning-dimensions. The blue arrow is vold and the yellow arrow is vnew — two embeddings drawn from the same origin. The red wedge between them is the angle θ. Cosine similarity is a number that depends only on that wedge, not on how long either arrow is: squeeze the wedge toward zero and the score climbs toward 1; open it to a right angle and the score drops to 0. The two lines of white text spell out the two anchor cases so you can read any picture at a glance.
First we need the length symbol used in the formula.
So the parent's rule
cosine_sim(vnew,vold)>0.95⟹merge or delete
reads: "if the new arrow points almost exactly the same way as an old one (angle nearly zero), they mean nearly the same thing — don't store both."
Here is a concrete forgetting rule from the parent, with the dials filled in so you can see them work. Suppose we score how much an episode e is worth keeping:
Importance(e)=w1⋅AccessCount(e)+w2⋅Recency(e)+w3⋅Feedback(e)
The diagram below is written in Mermaid, a tiny text-to-diagram language. You do not need to write it, only read it: each NAME["label"] is a box, and each --> is an arrow meaning "feeds into / is needed for." Follow the arrows upward and you see how the small ideas at the edges build toward the topic in the centre-bottom.
Cover the right side and test yourself. If any line surprises you, reread that section.
What is a token, in one line?
A small chunk of text (≈ 0.75 of a word for English, but varies by tokenizer and language) the model reads one at a time.
Is "1 token ≈ 0.75 words" reliable across models and languages?
No — it's a rough English average for one tokenizer; other models and non-English text can cost 2–3× more per word, so re-measure.
What does the context window limit?
The total number of tokens the model can see in a single call.
What is the difference between the prompt and the system prompt?
The prompt is all text sent into the model on one call; the system prompt is the fixed instructions placed first, one part of the prompt.
What is the output buffer?
The tokens reserved (kept empty) for the model's own reply so it isn't cut off.
What is working memory?
The leftover tokens reserved for conversation history and retrieved memories — the active scratchpad.
Why do agents need memory at all?
Because a raw LM call is stateless and the context window is finite, so old information falls out of view and must be stored outside.
What does "stateful" mean?
The system carries information from past calls forward to shape the present.
Record braces vs a mathematical set — why do order and duplicates not matter in a record?
Because each field has a unique name that is its address; the name pins the slot down, so sequence is irrelevant and you cannot repeat a slot.
What is an embedding?
A list of numbers (a vector) representing a text's meaning, placed so similar meanings sit close together.
What is a vector database?
A store built to hold many embeddings and quickly find those pointing most nearly the same way as a query.
Why is v written in bold?
To signal it is a whole vector (arrow / list), not a single number.
What is the norm ∥v∥ and how is it computed?
The Euclidean length of the arrow, v12+⋯+vn2.
What does cosine similarity measure, and its range?
The angle (direction match) between two vectors; from −1 (opposite) through 0 (unrelated) to 1 (identical).
What happens if a vector is the zero vector?
Its length is 0, so cosine divides by zero and is undefined; systems skip such items.
Does ℓ2-normalisation make cosine similarity non-negative?
No — normalising rescales length but never flips signs, so cosine can still be negative; scores often look like they sit in [0,1] only as an empirical tendency.
Why cosine rather than straight-line distance?
It ignores vector length and compares only direction, i.e. meaning, not text length.
What does ⟹ mean?
"Therefore / this leads to."
What are tnow and te, and what is tnow−te?
The current time and episode e's timestamp; their difference is the episode's age (how old the memory is).
What do the weights w1,w2,w3 do, and are the subscripts powers?
They set how much each factor contributes to a summed score (bigger = more influence); the subscripts are just labels, not powers.
What is a fact triple?
A stored fact of the form (entity, relation, value), often with a confidence number.
What is semantic search?
Retrieval by meaning using embeddings and cosine similarity, not exact word matching.