← all repositories
VictorTaelin/OptMem

A 426-token prompt that makes AI agents remember everything

OptMem gives AI agents permanent memory by making them run their own note-taking tool via a 426-token system prompt.

1k stars Python Agents
OptMem
Collecting fresh signals — velocity needs a few days of history.
collecting data…
star history

What it does

OptMem is a single-file Python script that gives AI agents persistent memory across sessions. You paste a short prompt into the agent’s system instructions, and the agent itself runs commands like memo note to log insights and memo wake to reload prior context. Memories live in an append-only text file, with a binary tree of summaries keeping retrieval fast.

The interesting bit

The agent is the UI. Instead of a background service watching the conversation, OptMem instructs the LLM to manage its own memory: run memo wake at startup, record one-line notes when it learns something, and handle compression tasks when asked. Fixed-width records make position identical to identity, so every lookup is a single seek; at a million entries, waking takes 0.03 seconds.

Key highlights

  • One 426-token prompt and one dependency-free Python file
  • Append-only LOG.txt plus a rebuildable binary summary tree (TREE/)
  • Fixed-width records mean O(1) seeks; 1M memories wake in 0.03s
  • WAKE_LINES is a reading budget adjustable anytime without recompute
  • Parallel sessions can all write, but subagents are explicitly forbidden from running memo

Caveats

  • The whole system relies on the LLM actually following the prompt’s mandatory commands; there is no external enforcement
  • Notes are capped at one line and 280 bytes, and compression tasks interrupt the agent inline
  • Subagents must be explicitly told not to run memo, or their notes arrive duplicated and incorrect

Verdict

Try it if you want durable agent memory without databases, background jobs, or vendor lock-in. Skip it if you need fully automatic, transparent memory or rich multi-line entries.

Frequently asked

What is VictorTaelin/OptMem?
OptMem gives AI agents permanent memory by making them run their own note-taking tool via a 426-token system prompt.
Is OptMem open source?
Yes — VictorTaelin/OptMem is an open-source project tracked on heatdrop.
What language is OptMem written in?
VictorTaelin/OptMem is primarily written in Python.
How popular is OptMem?
VictorTaelin/OptMem has 1k stars on GitHub.
Where can I find OptMem?
VictorTaelin/OptMem is on GitHub at https://github.com/VictorTaelin/OptMem.

heatdrop uses Google Analytics to see which pages get read — nothing else. Your call. How we handle data.