Building a useful agent · Memory
How memories become knowledge
August 4, 2026 · 7 min read
You go to bed with a day of moments and wake up knowing things. Our agents do the same: a nightly pass turns repeated moments into knowledge that lasts.
The last post ended with the agent holding a growing pile of moments: what happened, when, who said it. But a pile of moments is not what knowing feels like. You do not replay every Monday morning to work out where the weekly meeting is. Somewhere along the way, moments that kept pointing the same way became a thing you simply know.
Here is that end state, as our agents store it: the knowledge on top, and threads down to the moments that earned it. By the end of this post you will have seen exactly this get built.
In your brain, most of that work happens while you sleep. The hippocampus replays the day, and what repeats settles into the neocortex as knowledge. Our agents keep the same schedule: once a night, a background pass reads the moments that have piled up and works them into facts. This post is about that pass.
What belongs together
Prose does not sort. A moment is written the way it happened, in whatever language it happened in, and no two are phrased alike. So before anything is grouped, a small model reads each moment once and pulls out the things it names. The phrasing, the when and the how much stay behind in the moment. The result is kept, so no night ever pays for the same moment twice.
The test for making the list is having a name. Book flights to Lisbon for the offsite with Sara, and Maya, Sara and Lisbon make the list while the flights do not: nothing names them. A word like flights turns up in any number of unrelated moments, but a name points at one particular place or person, which is exactly what can tie two moments together. The list is typed and kept whole, and everything about grouping ahead runs on it and nothing else.
With every moment reduced to its things, the night can start sorting. First, every thing in the night's window is counted. A thing mentioned only once cannot tie anything, and a thing mentioned everywhere would tie everything, so both are set aside. What remains gets a weight: the rarer the thing, the heavier it counts.
A tie between two moments is the sum over what they share in the band. Shared things add up, so two moments with several rare things in common bind hard, while a pair that shares nothing in the band gets no tie at all.
It matters what you group on. Group on the person, and you have grouped nothing: you are in every moment of your own life, so every moment matches every other. Group on the words, and moments that merely phrase alike get pulled together, a table at Lucia's in one and a flight to Lisbon in the other, chained by the word booked. So the night groups on the things a moment mentions, the named people, places and products on its list, and the threads of your life come apart cleanly.
The grouping itself is a joining game. Check every pair of moments once and record what they share in the band: that is the web, every moment a dot, every surviving connection a tie. Then every moment starts alone and drifts to the neighbor whose tie most beats the luck-bar, the tie chance alone would give them. Settled groups shrink into single dots and the game repeats, so threads assemble bottom-up: pairs first, then pairs of pairs, until nothing wants to move.
None of this sorting is our invention. Ignoring the things too common to mean anything is an idea from 1958, and the grouping itself is the Louvain method, the standard way of finding communities in a network. Each night places a moment in exactly one group, but that is not where it ends: the same moment can go on to support several pieces of knowledge, and a deeper pass on a later night can sort it differently as more of the story arrives.
Two guards finish the job. A group that grows past what one theme can hold is split and sorted again, so a large store cannot melt into one pile. And moments that are just the agent reminding you of things are set aside in a lane of their own, where they cannot pass for knowledge.
The bar for becoming a fact
Most groups never become knowledge. The bar is not how much happened but how it is spread: a group earns a fact when a few of its moments come from more than one day. A busy evening can fill a group on its own, but a burst is still one experience. Come back to the same thing tomorrow and it starts to look like a regularity. The gap is doing the work, and psychology has a name for that: the spacing effect. Post 1 stated it as a rule: importance alone doesn't make knowledge, repetition does. This is where that rule is enforced.
One kind of moment bends the bar. A correction never waits: set the agent straight on the meeting day and the fact is written the same night, even when that correction is the only moment on its side. Nobody should have to correct an agent three times before it takes. Other heavy moments get no such pass of their own: with company they can carry their whole group through the same night, but alone they stay what they are, a vivid moment. The view from the tower in post 1 never became a fact, and it never should. What counts as heavy here is exactly the salience post 2 built; the amygdala's number follows the moment all the way into the night.
The gate can only judge what a pass can see, and one night is a narrow window. So the same machine runs at three exposures. Every night it reads the day behind, enough to catch corrections and anything that ran hot within the day. About once a week it re-reads the month behind, wide enough for the rhythms of a week to show. And about once a month it re-reads everything, for the threads that move slowest of all. These are not retries, they are longer exposures: a weekly rhythm simply does not exist inside a single day, no matter how carefully you look.
Writing the fact
A group that passes the gate goes to a stronger model than the one that pulled out the things, and it gets the group whole: today's date, and every moment dated and numbered, in its own words. What it may answer is narrow. One sentence of knowledge, what kind of fact it is, which of the numbered moments actually support it, and whether it should ever expire. It is also allowed to answer nothing: a group can pass the gate and still hold no regularity worth keeping, and declining is the right call.
The sentence is phrased so it cannot silently rot. A truth that really is timeless, who someone is, what they own, what they can do, may be written that way; anything that only holds for now, a role, an arrangement, an open plan, is anchored to its time or written as a state with an expiry. And every date in a fact must come from the moments themselves; the writer is not allowed to guess one. The citing is not a courtesy either: every fact points at the exact moments that earned it, so it can always be opened back up, and the weight it starts with is inherited from the heaviest of them. A fact born of a correction starts heavy.
Changing its mind
Knowledge can be wrong, and the night is also when it gets fixed. A new fact is not simply added to the pile. Before it lands, it searches the store for what it might already mean; the store is indexed by meaning, so the newcomer pulls up its nearest neighbors, phrased however they were phrased. Usually nothing close comes up and the fact just lands. When something does, a judge reads the pair and rules: the store already says this, the two contradict, or they merely sit near each other.
A contradiction is where post 2's tag finally pays off. Who said it decides: a fact backed by your correction beats one the agent merely believed, however confident it sounded, and on equal footing the newer evidence wins. The loser is never deleted. Its validity is closed, it points at its successor, and it stays on the shelf as history.
Some retractions replace nothing. The agent takes back a claim, and there is no new truth to put in its place. The night does not have to notice this by rereading anything: capture already marked the moment for what it was when it was written, the same ladder from the last post. Each marked moment then searches the store itself, and it has to match tighter than a new fact does, because a candidate that lands loosely just starts a comparison, while a retraction that lands loosely kills the wrong knowledge. When it truly matches, the fact is closed with nothing after it. The agent knows less than it did the day before, on purpose.
What the night leaves behind
The store the night leaves behind holds two kinds of memory. Moments, which fade on their own schedule, and facts, which stand until something retires them, each pointing back at the moments that earned it. Ask where the weekly meeting is and the agent should not have to replay a month of Mondays. The fact is simply there, and the receipts are one hop away.
But a shelf of knowledge is only as good as what comes off it mid-conversation. The only memories that matter are the ones the agent can bring back at the right time, and that is the next post: how the right moment and the right fact find their way back into the conversation, exactly when they are needed.