Skip to main content

Module dream_run

Module dream_run 

Source
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_next hands 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 running before 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 person dream, 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 .md notes 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. account says which account an agent’s pass runs on; call makes the model call for the pass. call is 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 running by a srv that quit, or by a loop that died, mid-pass: nothing else moves them, and a running dream blocks every later pass and its agent’s next dream. A dream running for older_than_ms or more is moved to failed; 0 at 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.