AI agents work with a fixed context window. When the window fills, older information is dropped. The loss makes it hard for an agent to remember past interactions across sessions.
OptMem, an open‑source project by Victor Taelin, adds a permanent memory layer on top of the model. The system stores key facts in a vector database. When a new request arrives, it retrieves the most relevant memories and injects them into the prompt. This lets the model see a larger history without expanding the raw token count.
The approach is simple. After each turn, the agent extracts a short summary of what happened. The summary is embedded and saved. Later, a similarity search returns the top matches. Those matches are appended to the prompt as a "memory block". The model then continues as if it had seen the whole conversation.
Because the memory lives outside the model, the size of the context window no longer caps the amount of knowledge an agent can use. The system can keep thousands of interactions and still stay within the token limit for each call. This makes multi‑session agents feel more persistent.
Masterphub.io lists a skill built on this idea. Users can add the memory prompt to any OpenAI‑compatible model. The skill handles embedding, storage, and retrieval automatically. It works with GPT‑3.5, GPT‑4, and other models that support function calls.
OptMem also shows how to keep the memory relevant. A decay rule removes items that haven’t been accessed for a set number of calls. A weight system boosts facts that are frequently referenced. The result is a lean, focused memory that improves response quality without adding noise.
Developers who need agents that remember user preferences, project details, or long‑term goals can adopt this pattern. The code is lightweight, uses Python and the popular FAISS library, and can be dropped into existing pipelines.
In short, permanent memory sidesteps the context window bottleneck. It gives agents a way to learn across sessions without retraining. The open‑source community can now build more consistent assistants, and marketplaces like Masterphub can surface ready‑to‑use skills that bring this capability to anyone.
We turned this idea into a ready-to-use skill on Masterphub: "persistent memory prompt for any OpenAI model".