OptMem provides AI agents with permanent, searchable memory via a lightweight tool and a 426-token prompt integration.

Stars

616

7-day growth

No data

Forks

32

Open issues

1

License

No data

Last updated

2026-07-26

Why it is worth attention

It offers a remarkably simple and fast persistent memory solution for AI agents using only a single Python script and a minimal prompt, with no external dependencies.

Who it is for

  • AI agent developers
  • LLM power users
  • Researchers in agent memory systems
  • Developers of self-aware AI tools

Use cases

  • Maintaining agent context across sessions and conversations
  • Logging decisions, facts, and user insights for future reference
  • Quick recall of past events using regex search or binary tree navigation
  • Enabling agents to remember long-term user preferences and history

Strengths

  • Ultra-lightweight: 426-token prompt and a single script with no dependencies
  • Fast performance: 0.03s wake time even with 1 million memories
  • Append-only log ensures data durability and easy rebuild of summary tree
  • Simple 'plug and play' installation via curl and paste

Considerations

  • Limited to 280 characters per memory note
  • No background processing; manual 'nap' command required for merging summaries
  • Text-only; cannot store structured or binary data
  • Relies on agent strictly following the provided prompt for proper function

README quick start

OptMem

Permanent memory for AI agents. A 426-token prompt, a script, plug and play.

Install

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

It prints a ## Memory block. Paste that at the top of your agent's AGENTS.md (or CLAUDE.md), and you are done. Run the same line again to update.

The tool lands at ~/.optmem/memo; put ~/.optmem on PATH to type memo.

Commands

memo wakeread the memory — the first command of every session
memo note "..."record one memory: one line, up to 280 chars
memo napanswer the merges that came due
memo recall search every memory ever recorded, word for word
memo zoom -open a tree node into its two halves
memo forget -drop a bad summary; the next nap rebuilds it

Merges arrive one at a time, in the output of note. Nothing ever runs in the background.

Files

~/.optmem/
  memo          the tool: one file of Python 3, no dependencies
  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, written by `memo config`
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.

Records are fixed width, so position is identity and every lookup is one seek. At a million memories (608 MB), wake takes 0.03s.

Set $MEMORY_DIR to keep memory/ elsewhere — a synced folder, a git repo.

The prompt

This is what the installer prints, and the whole of the integration.

## Memory

Your memory is OptMem:
- The tool is `~/.optmem/memo`
- Your memories are in `~/.optmem/memory`

OptMem outlives every session, compaction, model and vendor change.
Without it you do not know who you are, or what was decided and tried.

### At startup: activating OptMem (mandatory)

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.

### While working: register memories (mandatory)

Call `~/.optmem/memo note ""

Description

Permanent memory for AI agents. A 426-token prompt, a script, plug and play.

Related repositories

Similar projects matched by category, topics, and programming language.

lopopolo
Featured
lopopolo GitHub avatar

harness-engineering

Harness Engineering is a methodology for improving coding agent outputs by carefully crafting the environment around them—providing curated context, tools, and executable constraints that encode an organization’s nonfunctional requirements and cumulative lessons.

AI & Machine LearningAI Agents
2,320
xai-org
Featured
xai-org GitHub avatar

grok-build

Grok Build is SpaceXAI's terminal-based AI coding agent that runs as a full-screen TUI, understands codebases, edits files, executes commands, searches the web, and manages tasks interactively or headlessly.

AI & Machine LearningAI Agents
20,399
Jakubantalik
Featured
Jakubantalik GitHub avatar

thinking-orbs

A React component library that renders six hand-tuned animated thought orb loading indicators on a plain 2D canvas, with two purpose-tuned sizes and automatic theme detection for AI and agent UIs.

AI & Machine LearningAI Agents
1,159