Skip to content

feat(agent): let an agent sleep on it - #18

Merged
meocong merged 1 commit into
masterfrom
feat/agent-dreams
Aug 14, 2026
Merged

feat(agent): let an agent sleep on it#18
meocong merged 1 commit into
masterfrom
feat/agent-dreams

Conversation

@meocong

@meocong meocong commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

Memory only ever grew. MEMORY.md gains a line every time an agent is told something and loses one only when a person deletes it — so after a month it holds the same fact written three ways, a correction sitting above the thing it corrected, and a note about a project that finished in March. All of it goes into every prompt.

Optionally, once a night, the agent re-reads what it knows and writes back a shorter version that says the same things.

Three rules, enforced in code and not merely asked for

  • Nothing is invented. The model sees only what the agent already wrote down.
  • Nothing is lost. The old memory is copied into DREAMS.md verbatim before the new one is written.
  • It refuses rather than guesses. Empty, longer than the input, or more than half the lines gone → discarded, memory untouched.

Off by default

A language-model call per agent per day, for no benefit on day one. The daemon checks on a timer instead of scheduling for 3 a.m. — a laptop is asleep at 3 a.m., and a cron-shaped design only works for people who leave a desktop running. Never while recording. A night that refused still counts as slept, or the daemon would ask the same question every half hour forever.

Measured

On the running daemon against a stub provider: 6 lines in, 4 out, the duplicate pair merged, the original six still readable in DREAMS.md, and the prompt confirmed to carry the "add nothing" rule.

Plus unit tests for every refusal path, and the whole browser suite still green.

🤖 Generated with Claude Code

…hings in fewer words

Memory only ever grew. `MEMORY.md` gains a line every time an agent is told something and
loses one only when a person deletes it, so after a month it holds the same fact written
three ways, a correction sitting above the thing it corrected, and a note about a project
that finished in March — all of it in every prompt, forever.

So, optionally, once a night: the agent re-reads what it knows and writes back a shorter
version that says the same things. Duplicates merge, the later correction wins, what is
plainly finished falls away.

Three rules make it safe to leave running, and they are enforced in code rather than asked
for in the prompt:

* **Nothing is invented.** The model sees only what the agent already wrote down. A dream
  that could add a belief would be a system quietly rewriting what it thinks of you,
  overnight, forever.
* **Nothing is lost.** The previous memory is copied into `DREAMS.md` — verbatim, before
  the new one is written — so a bad night is one file to open and one block to paste back.
* **It refuses rather than guesses.** An empty answer, an answer longer than what it was
  given, or one that dropped more than half the lines is discarded and the memory left
  untouched. "The model returned nothing useful" must never mean "the agent forgot
  everything".

Off by default: it costs a language-model call per agent per day, and on the first day
there is nothing to consolidate — a memory of four lines is already as short as it gets.
The daemon checks on a timer rather than scheduling for 3 a.m., because a laptop is asleep
at 3 a.m. and a cron-shaped design would only work for people who leave a desktop running.
Never while recording. A night that refused still counts as slept, or the daemon would ask
the same question every half hour until the memory changed.

Measured on the running daemon against a stub provider: six lines in, four out, the
duplicate pair merged, and the old six still readable in `DREAMS.md`.
@meocong
meocong merged commit d064845 into master Aug 14, 2026
10 checks passed
@meocong
meocong deleted the feat/agent-dreams branch August 14, 2026 10:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant