pi-optmem

extensionmaintained

Permanent, append-only memory for pi agents

by · v1.0.0 · published 1w ago

$ pi install npm:pi-optmem
downloads/mo
161
stars
1
last push
1w ago
open issues
0

Signals

license: nonetestspi manifest: missinginstall size: —deps: 0peer deps: 0

Download trend

161 downloads · last 12 weeks (weekly)

README

OptMem for pi

Permanent memory for pi agents. OptMem keeps an append-only log and a compact binary summary tree, so memory survives sessions, compaction, model changes, and vendor changes.

how OptMem works

Install

pi install npm:pi-optmem

Python 3.7 or newer is required. Restart pi after installation. On the first session, the extension creates ~/.optmem/memory. It then wakes automatically before the first model turn; there is no AGENTS.md block to paste.

Use a project-local installation with:

pi install -l npm:pi-optmem

To install the latest unreleased source directly from GitHub instead:

pi install git:github.com/pi-pod/pi-optmem

Update later with pi update --extensions.

What the extension does

  • Runs memo wake at every pi session start and injects the result into the first turn.
  • Registers the optmem tool for recording, compressing, searching, and navigating memory.
  • Adds concise system guidance so durable facts and completed work are noted, and requested compressions are completed immediately.
  • Initializes a missing memory store only after the extension is deliberately installed and started.

The agent-facing tool supports these actions:

ActionPurposeFields
noteSave one durable, non-redundant memorytext
napAsk for the next compression, or submit onenone, or block + text
recallSearch every raw memory with a regexquery
zoomOpen a summary block into its halvesblock
wakeContinue paged startup outputoptional part + snapshot
forgetDrop a bad summary so it can be rebuiltblock

Storage and configuration

~/.optmem/
  memory/
    LOG.txt     every memory, append-only
    TREE/       rebuildable summary cache
    config      size settings

Set MEMORY_DIR before starting pi to use another location, such as a synced folder or Git repository.

The bundled memo program remains the storage engine. To inspect or tune a store outside pi, run it from this checkout:

./memo config
./memo config WAKE_LINES=300
./memo recall 'project name'

Never edit LOG.txt or TREE/ directly.

Standalone CLI integration

OptMem can still be installed for other agent harnesses with the original single-file installer:

curl -fsSL https://raw.githubusercontent.com/VictorTaelin/OptMem/main/install.sh | sh

That installer prints the instruction block used by non-pi agents. The pi extension does not need it.

Development

python3 test.py
pi -e .

The Python test suite checks tree coverage, persistence, paging, UTF-8, concurrency, and crash recovery. pi -e . loads this repository as a temporary package for interactive testing.