Building a useful agent · Memory
How memories become knowledge
July 28, 2026 · 7 min read
While you dream, your experiences become facts. The same is true for our agents.
Things you know, like Paris being the capital of France or that the local Italian restaurant always serves arrabiata on Thursdays, all come from experience, consolidated while you dream.
In the last post we talked about how memories are created by experiences. In this post we will talk about how the neocortex groups these memories to find facts and patterns.
What belongs together
When we dream, we sort and group memories. For our agents that grouping is based on names. Maya's trip is Lisbon, the friend is Sara, and every moment that belongs to the trip says so. A name points at one particular thing however a moment was phrased, while a word like flights shows up everywhere and means something different each time.
Names are scored on how often they are present, a higher value if uncommon but removed if unique or too common. The idea comes from Hans Peter Luhn, who used it in 1958 to summarize texts by keeping the words that carry significant meaning.
Ties can then be calculated as the sum of the scores of the names two moments share. Rare names in common make a strong tie, sharing only a common name makes a weak one, and a pair that shares nothing gets no tie at all.
The moments are then grouped on the strength of their ties, using a method called Louvain. The idea is to make the groups as large as they can get while each group still hangs together more strongly than chance would explain. Like the groups of friends you can spot at a large party.
Writing the fact
A well-studied phenomenon in psychology is the spacing effect, that learning is more effective when study sessions are spaced out. A group of moments from one busy evening will stay as moments, but a group of moments spread over time can become facts. The exception is corrections, they take effect the same night, nobody should have to say them twice.
The nightly read only sees one day, enough for corrections and the heaviest moments. The repeated patterns show up on the wider reads, the month behind about once a week, and everything about once a month.
From each group that passes we create zero or more facts. A fact is a single sentence about how things are now, the when and how of the moments removed. It can be a world fact that simply is, like Paris being the capital of France. A habit, something that repeats, like the arrabiata on Thursdays. Or a state, true for now but expected to change, which gets an expiry date so it can retire instead of going stale. And every fact points back to the moments it came from, like how thinking about something you know brings back the times you learned it, so the agent can go back to when and where it happened.
Changing its mind
Sometimes things change, and sometimes the agent misunderstood. So each new fact is compared against what the agent already knows. Saying the same thing again just makes the old fact stronger. A contradiction is settled by who said it, a correction from the user beats something the agent believed on its own, and newer evidence beats older. The losing fact is retired, not deleted, and it keeps a reference to what replaced it. And sometimes the agent takes back a claim with nothing new to put in its place, then the fact is closed.
What the night leaves behind
The agent ends up with two types of memories. The moments fade away with time, the knowledge stays until something retires it. Ask where the weekly meeting is and the agent does not have to replay a month of Thursdays, the fact is there, with the moments behind it one step away.
But knowledge is only useful if it comes back mid-conversation. How the agent brings the right memory back at the right time is the next post.