31.2 Two loops over one memory
- Approved by
- Panaversity ·
In everyday life. A restaurant kitchen cooks all evening. Nobody stops service to rewrite the recipes. After closing, the head chef reads the night's orders and the plates that came back, and sees that three tables sent back the same dish as too salty. The next morning she changes the recipe card, tastes the new version, and only then puts it on the line. The cooks work the night; the chef improves the recipes the next morning, from many nights at once.
What you will learn. What the task loop and the dreaming loop each do, and why they share one memory but never write to it in the same way. You practise it in Lab 31, Task 2.
Why it matters. If the worker that does the job also has to keep its memory tidy, it splits its attention, and it can only see one day. Two loops give each job its own time and its own view.
What does each loop do?
The task loop does the work. It is the loop you built in 23.16, now with a memory. It runs often, every weekday morning for each company. It reads the published memory at the start, does the triage, and may leave small notes in a scratch folder of its own. Writing a note in the middle of a task is called writing in band.
The dreaming loop improves the memory. It runs on its own schedule, less often, here once a week. It reads the memory and many task sessions at once, and proposes changes. It works out of band: outside any task, with its own budget. A dream is the same kind of loop as the task loop. Its task is the memory itself.
| Task loop | Dreaming loop | |
|---|---|---|
| Runs | Every weekday, per company | Once a week, or after a set number of sessions |
| Reads | One published memory version, and that day's invoices | The memory, plus up to a hundred past sessions |
| Writes | Small notes, in its own scratch folder | Proposals, in a separate folder. Never the published memory |
| Sees | One session | Patterns across sessions, and across companies |
| Its budget | The run's, $0.50 | Its own |
Why not let the task loop keep its own memory?
Two limits, both from the talk.1 First, a worker that must finish the triage and also tend its memory splits its budget between them. There is no good rule for how much to give each. Second, a session can see only itself. Monday's session cannot know that the worker asked Luis about the same kind of NA- document on Wednesday and the next Monday too. A pattern that shows up only across many runs needs a job that reads many runs.
What kinds of loop are there?
Anthropic's loops article sorts loops by what the person hands off.2 The four kinds are new here. They build on loop engineering, from 23.16, and on the clock and the event as the two ways work starts, from 9.2. Read here, they show where dreaming sits:
| Loop | Starts with | Stops when | The person hands off | In Claude Code |
|---|---|---|---|---|
| Turn-based | A person's request | The worker judges it done, or needs more context | The check | The default loop, and skills that check the work |
| Goal-based | A request with a test for done | The test passes, or a cap on tries is reached | The stop | /goal, where a separate model checks the test |
| Time-based | A schedule | Someone cancels it, or the work runs out | The trigger | /loop on your machine, /schedule in the cloud |
| Proactive | An event or a schedule, with no person present | Each task at its goal; it runs until turned off | The request itself | All of these, with auto mode |
Each step down the table removes one more thing the person must do while the work happens. The article's proactive example runs every hour and reads a feedback channel. For each bug, it tries three fixes in parallel, each in its own copy of the code, and a judge chooses among them.
The morning triage is time-based. The dreaming loop is time-based too, and its "request" is "improve the memory".

Figure 31.3. Dreaming is not a new kind of loop. It is a time-based loop whose task is the memory.
Do the three sources agree?
Yes. The loops article, the talk and the always-on article each describe one part of the same system. The chapter's reference page compares them, concern by concern.
Check yourself
Question 1 / 2
0 answered
Where does the dreaming loop write its proposals?
Sources
- Owner
- Panaversity