🧠 AgentMemory
Persistent memory for your OpenAI agents — store, recall, and forget.
The problem
Every OpenAI agent starts from zero. No memory of past conversations, preferences, decisions, or context. Every session is a blank slate.
AgentMemory solves this — giving your agent durable, queryable memory that persists across sessions.
Quickstart
Install dependencies:
pip install openai python-dotenv
Set your OpenAI API key:
# .env
OPENAI_API_KEY=your_key_here
Run your first memory session:
from agentmemory import AgentMemory
memory = AgentMemory(memory_path="agent_memory.json")
# Store memories from any text
memory.remember(
"I am building a RAG application using Python and OpenAI. "
"I prefer concise answers and clean code."
)
# Recall relevant memories
results = memory.recall("What is the user building?")
print(results)
Output:
Found 2 relevant memories:
• [CONTEXT] User is building a RAG application using Python and OpenAI
• [CONTEXT] User prefers concise answers and clean code
API Reference
memory = AgentMemory(
memory_path="agent_memory.json", # local storage file
model="gpt-4o-mini", # judge model
max_memories=100, # max memories to store
)
memory.remember(text) # extract and store memories from text
memory.recall(query, top_k) # retrieve relevant memories
memory.forget(memory_id) # delete a specific memory
memory.forget_all() # clear all memories
memory.list_all() # return all stored memories
memory.count # total number of memories
Memory categories
| Category | Description |
|---|---|
fact |
Factual statements about the user or domain |
preference |
User preferences and style choices |
decision |
Decisions made during conversations |
context |
Project or situational context |
Streamlit demo
Run the interactive demo locally:
streamlit run app.py
Features:
- Store memories from any text input
- Search memories with semantic recall
- View all stored memories in the sidebar
- Delete individual memories or clear all
How it works
remember(text)sends the text to GPT-4o-mini which extracts individual factual claims, preferences, decisions, and context.- Each memory is stored as a structured object in a local JSON file.
recall(query)sends the query and all stored memories to GPT-4o-mini which scores each memory for relevance.- Memories are returned ranked by relevance score.
All storage is local — no cloud, no database, no infrastructure. Just a JSON file on your machine.
Cost
Each remember() call: ~$0.001
Each recall() call: ~$0.001
Both use GPT-4o-mini as the judge.
Roadmap
- Vector embedding search for faster recall at scale
- Memory expiry and TTL support
- Memory categories and filtering
- LangChain and LlamaIndex integration hooks
- Multi-agent shared memory support
Project structure
agentmemory/
├── agentmemory/
│ ├── __init__.py # public API
│ ├── memory.py # AgentMemory core class
│ └── models.py # Memory and MemorySearchResult dataclasses
├── app.py # Streamlit demo
├── example.py # quickstart example
├── requirements.txt
├── .env.example
└── README.md
License
MIT — free to use, modify, and distribute.
Contributing
Pull requests are welcome. Please open an issue first to discuss what you would like to change.
Built with OpenAI GPT-4o-mini as the memory extraction and recall judge.
Metadata
Release files for agentmemory-openai 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| agentmemory_openai-0.1.0.tar.gz | 6.8 kB | Without provenance | Details for agentmemory_openai-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| agentmemory_openai-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for agentmemory_openai-0.1.0-py3-none-any.whl |
Total release size: 14.5 kB
Release files / agentmemory_openai-0.1.0.tar.gz
| Download URL | agentmemory_openai-0.1.0.tar.gz |
|---|---|
| Size | 6.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
bed41c2f947019575eaa31c8443195c345f18a1a7b84f605d52f77ee70611c78
|
|
BLAKE2b-256 checksum How to use checksums |
1fd8c3a36c4cf529a3a9d0326331de8e0e4dec28efe07ea1cd341226481d1b4d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.0
|
Release files / agentmemory_openai-0.1.0-py3-none-any.whl
| Download URL | agentmemory_openai-0.1.0-py3-none-any.whl |
|---|---|
| Size | 7.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
dece93747fc8101c1ca96c9b49236099d1a71f3dd9b1f7c6ba057d7df0d31a9f
|
|
BLAKE2b-256 checksum How to use checksums |
e28c5750b822ce1e6e58dafeb40a9851c3c92a84018e71bde6d8c8ecd307465a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.0
|
Security for agentmemory-openai 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.