OptMem: The Memory System That Treats Position as Identity
A single-file agent memory layer that skips vector databases, stores history in fixed-width logs, and compresses the past into a navigable summary tree.

Update: just added a command to let agents expand a short memory into two larger parts. This allows the agent to navigate the memory tree, allowing it to seek and recall information from ages ago, with arbitrary precision.
- OptMem replaces vector-search memory with a file-native index where byte offset, not embeddings, determines identity.
- Its real breakthrough is the cover window, which mixes verbatim recent history with older summaries inside a fixed token budget.
- The system makes the agent its own archivist by turning note, nap, and wake into a maintenance loop instead of a retrieval pipeline.
- This is a narrow tool by design, and that is why it is appealing for local, auditable agents that do not want memory infrastructure.
Most agent memory products add another platform layer. OptMem does the opposite. It makes the file system do the indexing, then asks the agent to participate in keeping that index usable.
That is the useful shock here. A memory is not found because it is semantically similar to something else. It is found because it lives at a known position in an append-only log, and older memories are folded into a tree of summaries the agent can navigate.
The weird part: memory is just file offsets
OptMem’s core move is brutally simple. It stores memory in fixed-width records, so a given entry can be reached with a direct seek instead of a search. In other words, position becomes identity.
# Conceptual shape of the storage model
record_size = 320
memory_id = 500
byte_offset = memory_id * record_size
with open('LOG.txt', 'rb') as f:
f.seek(byte_offset)
record = f.read(record_size)
That matters because it changes failure modes. There is no vector index to rebuild, no external service to sync, and no opaque retrieval layer deciding what counts as relevant. The log is inspectable, append-only, and cheap to recover.
Why this beats a vector database for one specific job
| Feature | OptMem | Mainstream memory stack |
|---|---|---|
| Retrieval | Regex and tree navigation | Semantic vector search |
| Storage | Plaintext append-only log | Vector DB, graph DB, or SQL |
| Dependencies | None in the core loop | Multiple services and keys |
| Integration | 426-token prompt plus script | SDKs and APIs |
| Compaction | Agent-driven summaries | Pipeline-driven ingestion |
This is not a universal replacement. It is a cleaner answer for a narrower problem: one agent, one local loop, transparent state, and memory that needs to survive resets without becoming a platform.
The real invention: a summary tree the agent can read
OptMem’s summary tree is not just compression. It is a mixed-resolution memory model. Raw entries stay at the leaves, summaries accumulate upward, and the cover logic chooses which parts of the tree should appear in the next wake.
That is why the system feels different from sliding-window memory. Older history is not simply pushed out. It is collapsed into higher-level nodes that preserve shape, then reintroduced when the agent needs a broader view.
How wake, note, and nap turn the agent into its own archivist
The operational loop is the point. note appends facts, nap compacts adjacent memories into summaries, and wake reconstructs a context window that mixes fresh logs with compressed history.
That means the agent is not only retrieving memory. It is maintaining it. The design makes memory a behavior, not a backend.
Why the prompt matters as much as the Python
The core script is minimal, but the prompt carries a lot of policy. It tells the agent how to wake, how to journal, and how to behave when memory has to be compressed instead of merely stored.
# Mental model
- wake: reconstruct context
- note: append a memory
- nap: compress older memories
- subagent safety: avoid recursive corruption
The prompt is not decoration. It is the operating contract.
That is the quiet strength of the project. It keeps infrastructure boring and makes behavior explicit.
What the tests reveal about the design
The test suite matters because it treats memory integrity as a first-class property. Synthetic life tests, block math checks, and locking behavior all point to the same idea: a memory system is only useful if it stays coherent under pressure.
def test_cover_math():
# Verify no gaps and no overlaps in the selected memory window
...
def test_locking():
# Ensure concurrent writes do not corrupt the append-only log
...
That is the right kind of boring. If the log breaks, the agent loses its past. OptMem’s tests show that the project understands that risk.
Victor Taelin’s broader signature: compression as a philosophy
OptMem fits a larger pattern in Taelin’s work. The through-line is structural compression: binary trees, sparse representations, and efficient reduction. In that sense, the project feels less like a memory product and more like a systems argument.
The argument is simple. Keep the representation small. Let the structure do the work. Preserve enough detail to remain useful, then fold the rest into a form the agent can still read.
The narrow use case where OptMem is the right answer
| If you need | OptMem is a fit | OptMem is not trying to be |
|---|---|---|
| A local, auditable memory file | Yes | A full knowledge platform |
| Deterministic storage and recovery | Yes | A semantic search engine |
| Minimal dependencies | Yes | A framework with broad integrations |
| Agent-owned compaction | Yes | A managed memory service |
That narrowness is the product. OptMem is not the biggest memory stack. It is the cleanest answer to a very specific question: how do you give one agent a durable past without building a database around it?





