Blog
Agent memory and dreaming: how AI agents learn between sessions
An AI agent forgets everything when a session ends unless it writes things down. Dreaming is the step that turns many sessions of notes into something an agent can actually learn from.
Melvin Salas2 December 20268 min readVerified 2 December 2026
Agent memory is the set of notes an AI agent reads when a session starts and adds to while it works, so that a correction or a fact survives into the next session. Dreaming is a separate pass, run between sessions, that reads many past sessions together with those notes and writes a cleaner set. The model itself does not change. What changes is what it reads before it starts.
Read the transcript
An AI agent starts every session with a blank mind. Whatever it learned yesterday is gone, unless it wrote it down. So agents keep notes. A correction, a rule, a fact about a customer. Next session, they read the notes first. That's agent memory. But each session only sees itself. If the same mistake happens in three sessions, no single session notices. And over time, the notes fill up with duplicates, contradictions, and things that are no longer true. Dreaming fixes that. Between sessions, a separate agent reads many past sessions together, alongside the notes, and looks for patterns. Repeated mistakes. Tools that keep failing. Notes that have gone stale. Then it writes a cleaner set of notes: merged, corrected, with the new lessons added. Done well, the old notes stay untouched, so the new set can be reviewed, and thrown away if it's wrong. Nothing about the model changes. What changes is what it reads before it starts. So the next morning, the same agent works like it has more experience. At Riibon, each AI agent works on one client's ads. Each one saves what it learns, and anything an agent works out on its own is checked before it's kept. And now, every night, a review reads every agent's sessions together, tool errors included, so a mistake caught for one client can become a lesson for all of them, with no client's details carried across. The full guide is on the Riibon blog.
Why an agent needs notes at all
Our reading: an agent does not carry anything from one session to the next unless something writes it down and the next session reads it back. Ask the same agent the same question tomorrow and, without notes, it starts from the same blank page and can make yesterday's mistake again.
Anthropic's version of the notes is called a memory store. Its documentation describes a memory store as a workspace-scoped collection of text documents, mounted as a directory inside the session, which, in the default setup, the agent reads and writes with the same file tools it uses for the rest of its files. Every change to a memory creates a version, and Anthropic says those versions can be used to audit who changed what and when, and to restore a prior snapshot.
Our reading: the format matters less than the habit. Plain text files work because the agent already knows how to search and edit files, and because a person can open them and read exactly what the agent believes.
Where notes written in the moment run out
Anthropic's documentation names the problem directly: agents write to their memory stores as they work, but these writes are local and incremental, and over many sessions a store accumulates duplicates, contradictions and stale entries.
Our reading adds two limits we see when agents run every day. The first is attention. An agent taking notes is also trying to do the job in front of it, so the notes get whatever is left over. The second is sight. A session only sees itself, so a mistake that happens in three sessions looks like a one-off three times, and nothing in any one of them says it is a pattern.
What dreaming does
A dream, in Anthropic's terms, reads an existing memory store alongside past session transcripts, then produces a new, reorganised store: duplicates merged, stale or contradicted entries replaced with the latest value, and new insights surfaced. It takes one store and from 1 to 100 sessions. The input store is never modified, so the output can be reviewed and discarded if the result is wrong.
Anthropic describes dreaming as a scheduled process that surfaces patterns a single agent cannot see on its own, including recurring mistakes, workflows that agents converge on, and preferences shared across a team. An optional instructions field steers the pass, for example which areas to focus on and what to keep unchanged.
How a dreaming pass is built
Anthropic publishes a working recipe for building your own dream, where you choose when it runs, which transcripts it reads and what it does with them. In it, a lead agent writes the workflow, an analyzer agent handles each transcript, and an organizer agent runs once at the end to tidy the result.
The recipe treats transcripts as untrusted input, because a tool result in a transcript can carry an instruction. Its analyzer holds five file tools only, with no shell or web access. A run estimates its cost first and stops before creating anything if the estimate is over the budget you set.
On cost, the recipe reports that with its default settings, dreaming over its eleven example transcripts cost $0.36 at list price and took about two and a half minutes, and fifty long transcripts, about 12 MB of text, cost about $8 and took about ten minutes. Its nightly version updates the same store in place, runs from cron at 1 AM with no review by default, and saves a copy of the store's files before each run.
What makes a dream safe to trust
Our reading, from running agents on live ad accounts, comes down to four rules.
Keep the old notes. A pass that rewrites memory in place can only be judged after it has done damage. One that writes a new set beside the old one can be checked first, and undone.
Every change carries its evidence. A proposed lesson should say which sessions it came from and how often the problem happened. A change with no evidence is an opinion, and an agent's opinion read every morning becomes its habit.
Read the tool calls, not just the conversation. Most of the time an agent wastes is in failed calls, retries and long searches for one fact. Sometimes the right fix is a note. Sometimes it is a change to the tool, and no amount of note-taking replaces that.
Keep people's details where they belong. A lesson learned for one customer can help another only once it carries nothing that identifies the first.
How we do it at Riibon
Each Riibon AI agent works on one client's ads, and saves what it learns as it works. Anything an agent concludes on its own goes to a separate checker that tries to disprove it before it is kept, and every saved lesson can be undone. A lesson learned on one client can be raised to similar clients, but only after it is rewritten so that no name, figure or quote from the first client goes with it.
Since December 2026, a review is also scheduled to run every night at 03:20 UTC. If nothing has happened since the last run, it stops without calling a model. Otherwise it reads the last seven days of tool calls and end-of-task reflections across every agent and every client, and keeps only patterns that appeared in at least three separate sessions, because one bad session is an anecdote.
It looks for six kinds of pattern: the same tool failing the same way, a call that fails and then works on a retry, many calls to find one thing, a slow tool, a long stall between steps, and the same mistake described in different sessions' reflections. It acts on the 25 most harmful each night, and it reserves each one's maximum cost against a $3 nightly ceiling before calling any model, so a finding that would break the ceiling is left for tomorrow rather than dropped.
Each finding goes to the fix that removes it. If the agent did not know something, it becomes a lesson, checked like any other. If the tool is broken or confusing, it becomes an engineering bug with the sessions and error text attached, because teaching every agent to work around a broken tool is a patch. If the lesson holds for similar clients, or for all of them, it is shared with names, figures, links and quotes stripped out. The same review merges duplicate notes, sends contradicting pairs to a single model call that changes nothing when there is no clear winner, and retires time-bound notes seven days after they expire. Every one of those changes is checked and can be undone.
In a typical production week before the review existed, about one tool call in ten failed, and roughly one in eight of those failures carried no error text at all. The review's first run on real data, in a preview mode that changed nothing, found a couple of dozen cross-session patterns and proposed more than a dozen memory clean-ups in under two minutes, for a few US cents at API prices. It has no results to report yet. We will publish what it fixed once a few weeks of nightly runs exist.
What building it taught us about honest reporting
Absence from a filtered list is not evidence of absence. The review acts on 25 findings a night, so a weekly summary that called a problem stopped because it had gone missing would have been fooled by a problem still happening at rank 26. Each night now records what it saw separately from what it acted on, and claims nothing stopped if it could not read the whole log.
A zero needs its reason. That same run cost $0.00 on our bill, which was true, because our workspace runs on a subscription. The review now records which budget paid, so a zero can never be read as a missing number.
Errors without text cannot be learned from. Some of those failures said nothing about why, and no review can learn a lesson from a blank.
An agent may only edit its own client's memory. While building the review we found that an agent working for one client could propose edits to another client's notes. That is now refused, and in the 30 days before the fix, no call in production had used it on another client's notes.
Questions people ask
What is agent memory?
The notes an AI agent reads at the start of a session and adds to as it works, so that corrections and facts survive into the next session. In Anthropic's Managed Agents it is a memory store, a collection of text documents the agent reads and writes with its file tools.
What is dreaming in AI agents?
A pass that runs between sessions, reads many past sessions together with the agent's memory, and writes a reorganised memory with duplicates merged, out of date entries replaced and new lessons added.
Does dreaming retrain the model?
No. Our reading: dreaming produces a new set of notes, and the model stays exactly as it was. The agent improves because it reads better notes before it starts.
How often should a dream run?
Anthropic describes dreaming as a scheduled process, and its recipe includes a nightly version. Our reading: run it when there are enough new sessions to learn from, which for agents that work every day means nightly.
Is it safe to let a dream rewrite an agent's memory?
Only with guard rails. Anthropic's dream never modifies its input store, so the output can be reviewed first. Our reading: keep the old notes, require evidence for each change, and treat transcripts as untrusted input.
What working with Riibon looks like
Senior operators lead the account. AI watches it daily and prepares what it finds with the evidence attached. Nothing that touches money moves without your sign-off.
Ask the Riibon app anything about your own ad accounts, and see the evidence behind every answer. Access starts with a short call: we look at your ads together, then run them for you or set the app up with you.