My Assistant's Memory Problem
I built a chatbot with OpenAI, but every time I restarted the process, it had no recollection of our previous conversations. Serialization wasn't cutting it – context windows filled up, token costs skyrocketed, and my assistant started truncating history.
What I really needed was:
- To store facts as they happened
- Retrieve only what's relevant
- Synthesize when necessary
Enter MrMemory, a library that lets you add memory to your OpenAI Agents with minimal fuss.
The Simple Loop
Here's the entire workflow in three API calls:
-
recall(query)- pull relevant memories -
OpenAI completion- inject memory into system prompt -
retain(exchange)- store conversation
Let's dive into each step.
Step 1 — Initializing MrMemory
First, install MrMemory using pip:
pip install mrmemory
Then, initialize the client with your API key:
from mrmemory import MrMemory
client = MrMemory(api_key="your-key")
Now you can start storing facts about user interactions.
Step 2 — Storing and Retrieving Facts
Store a fact like this:
client.remember("user prefers dark mode", tags=["preferences"])
And retrieve it when needed:
results = client.recall("what theme does the user like?")
Why MrMemory?
Other solutions, like Mem0 and Zep, require vector databases or RAG pipelines. Not MrMemory – its simple API lets you add memory in just three calls.
Conclusion
Adding memory to your OpenAI Agents doesn't have to be a headache. With MrMemory, you can store facts as they happen, retrieve only what's relevant, and synthesize when necessary.
Try it out today with our 7-day free trial:
Related Posts
Top comments (0)