Agent memory and context

VictorTaelin/

OptMem

A 426-token prompt plus one Python script that gives any AI agent append-only, tree-summarized memory that persists across sessions and vendors.

What’s new here

OptMem is a single Python file with no dependencies, an append-only log of fixed-width lines, and a binary tree of summaries the agent builds and navigates itself. The whole integration is a 426-token prompt you paste into AGENTS.md or CLAUDE.md.

What it does

OptMem gives an AI agent persistent memory through a small tool (memo) and two files under ~/.optmem/memory/: LOG.txt, which is append-only and never edited, and a TREE/ directory of cached summaries rebuildable from the log alone.

The agent calls memo wake at the start of every session to read its memory, memo note "..." to record something new (one line, up to 280 bytes), and memo nap to answer any compression merges that came due. memo recall <regex> searches the full log. memo zoom <lo>-<hi> opens a tree node into its two halves for fine-grained navigation.

Because records are fixed width, position is identity and every lookup is a single seek. The README states that at one million memories (608 MB), wake runs in 0.03 seconds. WAKE_LINES controls how many lines the agent reads at startup; changing it never triggers recomputation.

Who it’s for

Developers who run AI agents and want memory that survives session resets, model upgrades, and vendor switches without standing up any external service. The installer targets agents that use AGENTS.md or CLAUDE.md. The design suits a single machine or a synced folder (set $MEMORY_DIR to keep memory/ elsewhere).

Try it

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

The installer prints a ## Memory block. Paste it at the top of your AGENTS.md (or CLAUDE.md). The tool lands at ~/.optmem/memo; add ~/.optmem to PATH to type memo directly.

memo wake           # read memory at session start
memo note "..."    # record one memory
memo nap            # handle pending merges
memo recall <regex> # search the full log

How mature is it

2,125 stars and 133 forks since the repo was created on 2026-07-25, with the last push on 2026-07-31. Two contributors, 42 commits in the past 90 days, no formal releases, and no license. The short activity window (one week of pushes) means the code is largely settled or early-stage; check the 8 open issues before depending on it in production.