Expand description
Queueing and running a personal-memory dream (docs/specs/SPEC_DREAMS_BACKGROUND_MEMORY_ORGANIZING_2026_11_27.md
§3, §5, §10 step 2): queue_dream adds one to the record, run_next takes the queued dream the schedule says may
run now and runs one pass over the agent’s memory files, and start_loop calls it once a minute.
Dreams are off until the person turns them on (dreams:enabled in settings, default off): while off every queued
dream waits and nothing is sent to a model. The model (dreams:model) and the most tokens one pass reads
(dreams:maxtokens) are settings too. The account is the dreamed agent’s own (dream_model).
Not here yet: the triggers that queue a dream by themselves (a compaction, idle, the nightly sweep), the session text
a pass reads (sessions is empty: a pass reads the memory files only), and Global Memory.
Structs§
- Call 🔒
- What
run_nexthands the model call: the model and the account’s config folder (None: the default sign-in). - Settings 🔒
- What the person set for Dreams.
Constants§
- SETTING_
ENABLED 🔒 - SETTING_
MAX_ 🔒TOKENS - SETTING_
MODEL 🔒 - STALE_
AFTER_ 🔒MS - How long a pass may be
runningbefore it is taken for dead: the gate and the call each have the call limit, and a minute is left for reading the notes and writing the record.
Functions§
- call_
cli 🔒 - The real call: the CLI of the provider, on the agent’s account.
- dream_
now 🔒 - A pass the person asked for: queued as a
persondream, which the loop runs at its next round. - memory_
files 🔒 - The memory folder’s notes, newest change first, each with its hash. Files that are not
.mdnotes are not memory. - queue_
dream 🔒 - Queue a dream of an agent’s personal memory. One at a time per agent: an agent that has a dream queued or running gets none more.
- run_
next 🔒 - Run the one queued dream the schedule allows now, if any: returns its id and how it ended.
accountsays which account an agent’s pass runs on;callmakes the model call for the pass.callis not called when a rule holds the pass back, nor when the agent’s account cannot be resolved: that pass is held with the reason, and no other account is tried. - settings 🔒
- settings_
from_ 🔒extra - start_
loop 🔒 - Start the loop once per srv: a round a minute. Without a runtime (a test that registers every handler) it starts nothing and a later call may still start it.
- sweep_
interrupted 🔒 - End the dreams left
runningby a srv that quit, or by a loop that died, mid-pass: nothing else moves them, and arunningdream blocks every later pass and its agent’s next dream. A dream running forolder_than_msor more is moved tofailed;0at startup takes them all, since no pass of this srv has begun. Returns how many it ended. - tick 🔒
- One round of the loop: nothing happens while Dreams are off.