Docs / Example apps

Permanent memory (after OptMem)

An agent whose memory outlives its sessions, after VictorTaelin's OptMem, built as an instance tree.

The cover is cover in views/strategies/context.tsx, OptMem's tiling. Recent memories stay verbatim and older ones collapse into tree nodes, in at most wake_lines lines. A block is compressed by asking for one line of at most N bytes that keeps what will still matter later and adds nothing.

Where it differs from OptMem:

Props: sessions (one task per session), template (messages for a hosted chat API, glm53), wake_lines (default 96), chars (the maximum length of a memory or summary, default 280).

Run it on a hosted model. Four sessions on DeepSeek V4.1 Flash took 27 turns and about 40K prompt tokens, under $0.01. The root needs a model binding (root.model) for its compressions.

Its deployment is affordance.yaml: set the provider's url and model, export its key as API_KEY, and run affordance run views/demo/memory.

The memory ends in .affordance/root/snapshot.json (state.__ui), and each session's wake is in .affordance/root/session-<n>/snapshot.json. The offline test is a_memory_outlives_its_sessions_compresses_old_notes_and_recalls_them in tests/runtime.rs.

Source: views/demo/memory/README.md, about 2 minutes to read.