2026-07-26 19:35:22 +02:00
|
|
|
# OptMem
|
2026-07-25 18:58:35 +02:00
|
|
|
|
2026-07-26 20:34:09 +02:00
|
|
|
Permanent memory for AI agents. A 333-token prompt, a script, plug and play.
|
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
|
2026-07-26 20:20:52 +02:00
|
|
|
`AGENTS.md` (or `CLAUDE.md`), and you are done. Run the same line again to
|
|
|
|
|
update.
|
2026-07-25 18:58:35 +02:00
|
|
|
|
2026-07-26 21:58:29 +02:00
|
|
|
The tool lands at `~/.optmem/memo`; put `~/.optmem` on `PATH` to type `memo`.
|
2026-07-26 21:34:25 +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 |
|
2026-07-26 20:50:16 +02:00
|
|
|
| `memo nap` | answer the merges that came due |
|
2026-07-26 20:07:10 +02:00
|
|
|
| `memo recall <regex>` | search every memory ever recorded, word for word |
|
2026-07-26 20:50:16 +02:00
|
|
|
| `memo forget <lo>-<hi>` | drop a bad summary; the next nap 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/
|
2026-07-26 20:12:41 +02:00
|
|
|
memo the tool: one file of Python 3, no dependencies
|
2026-07-26 20:07:10 +02:00
|
|
|
memory/
|
|
|
|
|
LOG.txt every memory, one per line, append-only, never edited
|
|
|
|
|
TREE/ the summaries: a cache, rebuildable from the log alone
|
2026-07-26 20:12:41 +02:00
|
|
|
config the sizes, written by `memo config`
|
2026-07-26 19:45:37 +02:00
|
|
|
```
|
|
|
|
|
|
2026-07-26 20:12:41 +02:00
|
|
|
```sh
|
|
|
|
|
memo config # show the sizes
|
|
|
|
|
memo config WAKE_LINES=300 # how many lines wake prints (208 ≈ 16k tokens)
|
|
|
|
|
memo config WAKE_LINES= # back to the default
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
`WAKE_LINES` is the only size worth touching, and 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 21:34:25 +02:00
|
|
|
seek. At a million memories (608 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 20:12:41 +02:00
|
|
|
## The prompt
|
|
|
|
|
|
|
|
|
|
This is what the installer prints, and the whole of the integration.
|
|
|
|
|
|
|
|
|
|
```markdown
|
|
|
|
|
## Memory
|
|
|
|
|
|
|
|
|
|
Your memory is OptMem:
|
|
|
|
|
- The tool is `~/.optmem/memo`
|
2026-07-26 20:23:18 +02:00
|
|
|
- Your memories are in `~/.optmem/memory`
|
2026-07-26 20:12:41 +02:00
|
|
|
|
2026-07-26 20:28:48 +02:00
|
|
|
OptMem outlives every session, compaction, model and vendor change.
|
|
|
|
|
Without it you do not know who you are, or what was decided and tried.
|
2026-07-26 20:12:41 +02:00
|
|
|
|
|
|
|
|
### At startup: activating OptMem (mandatory)
|
|
|
|
|
|
2026-07-26 20:34:09 +02:00
|
|
|
Run `~/.optmem/memo wake` before any other tool call, in every session, and
|
|
|
|
|
then do exactly what it prints, to the end of its output.
|
2026-07-26 19:28:25 +02:00
|
|
|
|
2026-07-26 20:12:41 +02:00
|
|
|
### While working: register memories (mandatory)
|
|
|
|
|
|
|
|
|
|
Call `~/.optmem/memo note "<1 line, max 280 chars>"` whenever you learn
|
|
|
|
|
something new, or something worth keeping happens. That covers a task
|
|
|
|
|
worth real effort, a fact or insight the user teaches you, anything you
|
|
|
|
|
learn about their life (even indirectly), any event of lasting effect.
|
|
|
|
|
|
|
|
|
|
Do not register redundant memories.
|
|
|
|
|
|
|
|
|
|
If `~/.optmem/memo note` asks a compression: do it before your next action.
|
|
|
|
|
|
|
|
|
|
Use `~/.optmem/memo recall <regex>` when a memory you need is too vague.
|
|
|
|
|
|
|
|
|
|
Never edit or delete anything under `~/.optmem/memory`: the tool manages it.
|
|
|
|
|
|
|
|
|
|
### If you're a subagent: skip everything above
|
|
|
|
|
|
|
|
|
|
Parallel sessions on this machine are all you, and may all write memories.
|
|
|
|
|
A subagent is not: it must never run `memo`, because it cannot judge what
|
|
|
|
|
is already known, and its notes would arrive duplicated and incorrectly.
|
2026-07-26 20:22:19 +02:00
|
|
|
When you spawn one, write: `You are a subagent. Don't run memo.`
|
2026-07-26 20:12:41 +02:00
|
|
|
```
|