Skip to content
langwatchPublic

About

Siesta: an append-only memory for AI agents inspired by OptMem, with naps to keep it compressed. The engine behind Laze memory.

Resources

Stars

24 stars

Watchers

0 watching

Forks

Latest commit

 

History

10 Commits

Folders and files

Repository files navigation

siesta's icon: a plush sloth fast asleep in a woven hammock between two wooden posts, a zz above and a yellow SIESTA tag on the hammock

siesta

memory for ai agents that stays small and stays true.
an append-only log, a short summary of it in every prompt, and naps the tool checks so nothing important gets dropped.

between the laze and the rush, it breaks work in two. siesta is the engine behind memory in laze, and it works on its own with any agent that can run a command, the same way optmem does.

why it matters

long agent sessions get compacted: the context is replaced by a summary, and whatever the summary drops is gone. a memory that is in every prompt brings back what the summary dropped. we measured it.

stacked bar: of 467 facts an agent acted on after compaction, 54% came from the compaction summary only, 15% from summary and memory both, 14% from memory only, 9% from repo files, 8% were lost and re-derived. memory-only share by compaction window: 13%, 10%, 13%, 23%.

one long agent session, 47 compactions, 14 to 26 october 2026, 467 facts traced to their source. measured on optmem, the memory siesta grew from, before the siesta changes below. chart source: node docs/charts/memory-sources.mjs.

  • 14% of the facts were only in memory. the compaction summary did not have them, so without memory the agent would have guessed or asked. counting facts both held, memory had 29%.
  • 23% in the last 7 compactions. the memory-only share was 10-13% early on and 23% in the last window, the highest of the session.
  • about 14 decisions turned on it. a server fix recipe, a person's contact ids, product defaults that only lived in memory: each time the summary had nothing and the memory line decided the action.
  • memory makes mistakes too, and siesta targets them. of 30 corrections from the person in those 12 days, 4 came from memory itself (3 facts lost in a nap, 1 agent guess stored as fact) and 11 were never noted at all. checked naps, provenance tags and the capture helpers below aim at those; we have not measured the effect yet.

the cost: naps took about 5% of the session's api calls, and 117 of 587 memory calls were retries for lines that were too long.

install

git clone https://github.com/langwatch/siesta && cd siesta
npm install && npm run build && npm link
siesta init

needs node 22.18 or newer. the memory lives in ~/.siesta, or wherever SIESTA_DIR points.

set up with claude code

three steps: a script that writes the wake to a file, two hooks that run it, and a block in CLAUDE.md that imports the file and tells the agent how to use siesta.

  1. copy the script:

    cp docs/claude-code/refresh-wake.sh ~/.siesta/refresh-wake.sh
    ~/.siesta/refresh-wake.sh   # writes ~/.siesta/WAKE.md
  2. add the hooks to ~/.claude/settings.json (merge with hooks you already have):

    {
      "hooks": {
        "SessionStart": [
          { "matcher": "", "hooks": [{ "type": "command", "command": "~/.siesta/refresh-wake.sh" }] }
        ],
        "PostToolUse": [
          { "matcher": "Bash", "hooks": [{ "type": "command", "command": "~/.siesta/refresh-wake.sh post-tool" }] }
        ]
      }
    }
  3. paste docs/claude-code/CLAUDE.md into ~/.claude/CLAUDE.md. its @~/.siesta/WAKE.md line imports the memory into every session and subagent, and the rest tells the agent when to note, nap, correct and recall. turn off the harness's own memory feature so the two don't compete.

start a new session: the memory block shows up at the top, and the first siesta note rewrites it.

use

siesta wake the memory, as the agent should read it at the start of every session
siesta note --verified "<line>" one memory, one line, 280 bytes at most
siesta nap the next summary to write, or siesta nap 16-31 "<line>" to save one
siesta recall <words> search every entry, any case, one typo forgiven
siesta zoom 16-31 open a summary into its two halves
siesta correct 569 --said '"<their words>"' fix an entry; every summary above it is redone
siesta forget 16-31 drop a bad summary; the next nap rebuilds it
siesta remove 874 blank an entry for good
siesta import-optmem ~/.optmem/memory bring an optmem memory over, ids kept, every line [you], [decided] where the line names the person and [unknown] otherwise; it only reads

every entry carries one of six tags, and the wake explains them to the agent reading it:

tag means
[said] the person's words, quoted
[decided] the person's decision
[verified] an agent checked it
[inferred] a guess, check before acting
[observed] a system event
[unknown] imported with no record of who said it (an optmem line that does not name the person); check before acting

and where it was learned: [you] for a dm with the person, [team], or [#channel]. a line only shows where everyone in the conversation could already see where it came from. the host says who can see what, live, so a channel locked down later takes its lines with it.

naps

when the wake gets bigger than its budget, the oldest neighbours get squashed into one line. the agent that's working writes that line, same as optmem: it has the context and it's on the same account. siesta checks it with plain string rules, no model, and says no when:

  • a quote from a [said] or [decided] line went missing
  • a pinned span went missing (--pin on a note, for commands and key names)
  • an [inferred] line came out sounding like a fact
  • it's too long (it prints the byte count and the bit past the limit, so you only cut once)
$ siesta nap 712-715 "OpenClaw gateway wedge fix: systemctl --user kill -s KILL --kill-whom=main openclaw-gateway."
refused: nap 712-715 loses 2 verbatim spans
  pin missing:
    `XDG_RUNTIME_DIR=/run/user/0 systemctl --user kill -s KILL --kill-whom=main openclaw-gateway`
  quote missing:
    "Forge gets no fixes"
fix the line and run the same command again. Nothing was written.

the byte limit grows by the size of what has to be kept, so a nap is never impossible.

what changed from optmem

siesta is built on optmem by victor taelin. the core is optmem's: an append-only log of one-line memories, a bounded wake made of summaries of aligned power-of-two ranges, compressed in pairs by the working agent, zoom down to raw entries and recall over everything. the block cover in src/tree.ts is a port of optmem's.

what's different, and why. the numbers are from 12 days of optmem on the agents that build laze, audited on 2026-10-26.

  • the wake goes in the prompt every turn. we first did this by hand, rendering optmem's wake into the system prompt. 14% of the facts agents used after a compaction only existed in the wake (23% in the last week), and it settled things about 14 times. so summaries have to be right, and agents shouldn't have to remember to read them.
  • provenance tags. an agent's guess about a licence went in as a fact and a nap carried it along until the owner corrected it.
  • checked quotes and pins. a nap dropped XDG_RUNTIME_DIR=/run/user/0 from a command, which then failed as root.
  • scope per entry. one memory serves dms and channels without leaking one into the other.
  • correct redoes the summaries. in optmem a correction is a new note and the old summary keeps saying the wrong thing until someone runs forget and nap. one sat next to its correction for three days.
  • capture helpers. the owner corrected agents 30 times in 12 days (4.5% of his messages), and 11 of the 30 were never noted. ruleCandidates spots rule-like sentences in a message and rulesMissing spots rules in a compaction summary that memory doesn't have. both only suggest a note; the agent decides.
  • wake never refuses. optmem won't wake until a pending nap is done, which a system prompt can't wait for. a missing summary shows as its halves, and past 125% of the budget the oldest lines are left out with a line saying so.
  • recall forgives. any case, one typo per word. optmem's case-sensitive regex made agents miss things.
  • markdown log. one section per entry with a meta comment, so the file reads fine and parses back to the same entries. hosts keep entries wherever they like through MemoryStore; laze keeps them in postgres, encrypted per workspace.

in other apps

import { MemoryBook, ArrayStore, DEFAULT_LIMITS } from "siesta";

const book = new MemoryBook({ store: new ArrayStore(), limits: DEFAULT_LIMITS, command: "my-agent memory" });
await book.note({ text: '"never deploy on fridays"', tag: "said", author, source: { kind: "you" }, at });
const { text } = await book.wake({ title: "Owen (person)", visible: (source) => true, view: "DM", now: new Date() });

command is the name the host gives its own commands, so laze's agents read laze memory nap in their prompts and never see the word siesta.

build

npm test            # node's test runner, about 3 s
npm run typecheck
npm run pack:laze   # the tarball laze vendors

license

private for now.

About

Siesta: an append-only memory for AI agents inspired by OptMem, with naps to keep it compressed. The engine behind Laze memory.

Resources

Stars

24 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages