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.

8 min read • View on GitHub • More from VictorTaelin

A towering stack of fixed-width memory cards rises like a file cabinet, with raw entries near the base and compressed summaries higher up. A small agent stands below reading a strip of recent cards while a thin thread connects the whole stack, showing continuity across time. It explains how OptMem keeps memory local, append-only, and progressively compressed.
OptMem turns history into a file-shaped structure. Recent events stay raw, older ones collapse upward into summaries, and the agent reads both through one bounded window.

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.

Victor Taelin, Creator of OptMem / Founder of HigherOrderCO · GitHub - VictorTaelin/OptMem
Key Takeaways

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.

A close-up of a ruler etched with exact byte offsets alongside a strip of fixed-width log entries. One hand points to a specific position while another folds older strips into a smaller summary card, showing how retrieval and compaction work at human scale.
The offset is the index. That makes lookup deterministic and compaction legible, which is rare in agent memory systems.

Why this beats a vector database for one specific job

FeatureOptMemMainstream memory stack
RetrievalRegex and tree navigationSemantic vector search
StoragePlaintext append-only logVector DB, graph DB, or SQL
DependenciesNone in the core loopMultiple services and keys
Integration426-token prompt plus scriptSDKs and APIs
CompactionAgent-driven summariesPipeline-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 cover window is the real invention. It chooses resolution over time, so the agent gets recent detail and older continuity inside one bounded prompt.

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.

WSJ hedcut-style portrait of Victor Taelin based on a verified GitHub avatar. The portrait supports the origin story by identifying the creator behind the system design, without distracting from the mechanism.

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 needOptMem is a fitOptMem is not trying to be
A local, auditable memory fileYesA full knowledge platform
Deterministic storage and recoveryYesA semantic search engine
Minimal dependenciesYesA framework with broad integrations
Agent-owned compactionYesA 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?