2026-07-26 19:35:22 +02:00
|
|
|
# OptMem
|
2026-07-25 18:58:35 +02:00
|
|
|
|
2026-07-26 19:45:37 +02:00
|
|
|
Permanent memory for AI agents. Nothing is ever deleted, and what the agent
|
|
|
|
|
reads at wake is always the same size.
|
2026-07-25 18:58:35 +02:00
|
|
|
|
2026-07-26 19:45:37 +02:00
|
|
|

|
2026-07-25 18:58:35 +02:00
|
|
|
|
2026-07-26 20:07:10 +02:00
|
|
|
## Install
|
2026-07-25 18:58:35 +02:00
|
|
|
|
2026-07-26 19:28:25 +02:00
|
|
|
```sh
|
2026-07-26 20:07:10 +02:00
|
|
|
curl -fsSL https://raw.githubusercontent.com/VictorTaelin/OptMem/main/install.sh | sh
|
2026-07-25 18:58:35 +02:00
|
|
|
```
|
|
|
|
|
|
2026-07-26 20:07:10 +02:00
|
|
|
It prints a `## Memory` block. Paste that at the top of your agent's
|
|
|
|
|
`AGENTS.md` (or `CLAUDE.md`), and you are done: no daemon, no database, no
|
|
|
|
|
embeddings, no plugin. Run the same line again to update.
|
2026-07-25 18:58:35 +02:00
|
|
|
|
2026-07-26 19:28:25 +02:00
|
|
|
## Commands
|
2026-07-25 18:58:35 +02:00
|
|
|
|
2026-07-26 19:45:37 +02:00
|
|
|
| | |
|
|
|
|
|
|---|---|
|
2026-07-26 20:07:10 +02:00
|
|
|
| `memo wake` | read the memory — the first command of every session |
|
|
|
|
|
| `memo note "..."` | record one memory: one line, up to 280 chars |
|
|
|
|
|
| `memo sleep` | answer the merges that came due |
|
|
|
|
|
| `memo recall <regex>` | search every memory ever recorded, word for word |
|
2026-07-26 19:45:37 +02:00
|
|
|
| `memo forget <lo>-<hi>` | drop a bad summary; the next sleep rebuilds it |
|
2026-07-25 18:58:35 +02:00
|
|
|
|
2026-07-26 20:07:10 +02:00
|
|
|
Merges arrive one at a time, in the output of `note`. Nothing ever runs in the
|
|
|
|
|
background.
|
2026-07-25 18:58:35 +02:00
|
|
|
|
2026-07-26 20:07:10 +02:00
|
|
|
## Files
|
2026-07-25 18:58:35 +02:00
|
|
|
|
2026-07-26 19:28:25 +02:00
|
|
|
```
|
2026-07-26 20:07:10 +02:00
|
|
|
~/.optmem/
|
|
|
|
|
memo the tool (Python 3, no dependencies)
|
|
|
|
|
blocks.py which memories to read, and which to merge
|
|
|
|
|
memory/
|
|
|
|
|
LOG.txt every memory, one per line, append-only, never edited
|
|
|
|
|
TREE/ the summaries: a cache, rebuildable from the log alone
|
|
|
|
|
config the sizes, all commented out
|
2026-07-26 19:45:37 +02:00
|
|
|
```
|
|
|
|
|
|
2026-07-26 20:07:10 +02:00
|
|
|
`WAKE_LINES` is the only size worth touching: how many lines `wake` prints
|
|
|
|
|
(208 ≈ 16k tokens). It is a reading budget, not a storage budget — change it
|
|
|
|
|
whenever, in either direction, and nothing is recomputed.
|
2026-07-25 18:58:35 +02:00
|
|
|
|
2026-07-26 19:45:37 +02:00
|
|
|
Records are fixed width, so position *is* identity and every lookup is one
|
2026-07-26 20:07:10 +02:00
|
|
|
seek. At a million memories (607 MB), `wake` takes 0.03s.
|
2026-07-26 19:28:25 +02:00
|
|
|
|
2026-07-26 20:07:10 +02:00
|
|
|
Set `$MEMORY_DIR` to keep `memory/` elsewhere — a synced folder, a git repo.
|
2026-07-25 18:58:35 +02:00
|
|
|
|
2026-07-26 19:28:25 +02:00
|
|
|
## Limitations
|
|
|
|
|
|
2026-07-26 20:07:10 +02:00
|
|
|
Recency is the only axis: an old memory fades however important it was, and
|
|
|
|
|
the one defence is rehearsal — note it again and it is recent again. `recall`
|
|
|
|
|
is regex, not semantic search. Summaries are written by the agent out of other
|
|
|
|
|
summaries, so a bad one spreads upward until you `forget` it. And a wake costs
|
|
|
|
|
~16k tokens, which is deliberate but not free. If you need a fact database,
|
|
|
|
|
use a wiki — this is for *who the agent is*.
|