Antoine Grondin
writingaboutrss···
← writing
July 11, 2026english·한국어·français

Compaction Is Dreaming§

Antoine Grondin

At the end of a long day filled with adventures, detours, ups and downs, we get exhausted and our mental capacity declines. There are only so many things, so many threads, we can keep open in our minds at the same time, and so many thoughts we can carry on in a day before running out of steam and needing to take a nap.

Dreaming is how the brain cleans up its accumulated "stuff" in general: flushing accumulated molecules of the wrong type from the day's chemical processes; taking the day's ideas and organizing them, filing them to memory, processing them, revisiting old and recent worries and hopes, whatever is on our subconscious.

Dreaming is what compaction should be for AI agents. LLMs have a finite context window: they can only hold so many thoughts in context at the same time. And as their context window fills up, their thought processes start to degrade. They become sloppy. They make simple mistakes. They omit things they ought to know. As of today, compaction is a process that usually takes whatever is the accumulated context of an LLM, and summarizes it into a smaller context that hopefully leaves enough breadcrumbs to continue what was going on before, while clearing up most of the noise of the accumulated day's thoughts. Not every word said or heard in a day has equal usefulness, and not all of it needs to stay in live memory. Humans also have a finite context window. Sleeping and dreaming are also related to "human brains approach saturation every ~16h". Social exhaustion, emotional exhaustion, cognitive exhaustion. Our performance declines, our patience runs out, we need to rest to recover our steady-state capacity.

Hierarchy And Delegation Of Memory§

Humans have various levels of memory. We don't keep everything in the foreground of our mind: only the most pressing issues, information we need soon, or things that freshly happened to us. We then file (subconsciously) things to our long term memory. Some two-level memory hierarchy is going on.. And then for things that don't fit our internal memory's capacity, we use tools. We write books, we write text somewhere, we talk to other people and tell them our stories. And we rely on the external world to keep some of our memories for us. We outsource our daily planning to our phone's calendar app. We store years and years of memory in email. We write stories and epics in drawings inside caves. We encode navigational maps of the Pacific Islands in songs. And we mostly keep a rough index of "if I ever want to remember about the car I had in 2012, I should search in my old pictures". We don't store the facts, we store vague information about how we would go about retrieving the information if we needed it again. Like search, like RAG.

The same way of compacting and storing facts is how AI agents should work. Rely on the world, rely on others, rely on externalized recording systems. And like humans don't die every night, agents should be able to maintain 100-years-long sessions without having to start fresh every time. They just need to dream more like humans.

A Metaphor§

So what predictive power does "Compaction is dreaming" have as a metaphor? Here are things that dreams do:

  • They organize and summarize: they file episodic traces to synapses.
  • They connect dots across levels of memory, with old and new facts.
  • Critically: they forget. They erase things that weren't relevant or (ideally) proved out wrong.
  • They happen on a schedule, not only when humans are saturated. But humans take naps when overwhelmed.

Strangely, humans don't half-dream: we fully go offline while dreaming. We don't do it concurrently. Yet one would think that AI agent compaction should be able to happen concurrently. I wouldn't be surprised if this proved to have the same tradeoffs as dreaming synchronously or asynchronously in the animal kingdom. Or how asynchronous garbage collectors usually cannot move objects: safely forgetting is hard without stop-the-world.

How does compaction differ from dreaming?

  • It doesn't forget or tombstone. Dead ends, wrong turns, are not removed. It hoards information, it doesn't dream.
  • It happens at saturation, not on a fixed schedule. Are dreams only on a schedule because of evolutionary pressure to be awake during daylight and use nighttime to catch up?

How would dreaming work in humans if we had evolved on a planet where there is no night time?

Other animals dream differently:

  • Unihemispheric slow-wave sleep: certain animals sleep with just one hemisphere dreaming while the other one maintains awareness.
  • Hyper-local: birds are thought to dream only in the regions of their brain that were used. Sleep pressure is not global.

There is a relationship between how we dream (how compaction is implemented) and intellectual power over long horizons. Some animals dream in different ways because of environmental constraints and take tradeoffs between availability and quality.

Note§

LLMs, AIs, agents... don't flush molecules, they simply organize their thoughts when they do compaction. Maybe they also need to flush something? In the case of humans, the "flushing" is about taking care of the accumulated byproduct of "being an awake brain". How would that map to the physical way by which AIs execute? An open thread to mine for inspiration.

tamuning - seoul