agent-memory

RAG & Memory 💻 Python ⚖️ MIT 🟡 Quiet lately
1 stars

agent-memory is a Python library that gives AI agents human-like memory using cognitive-science-inspired architecture. It solves the problem of agents forgetting past interactions by providing episodic, semantic, and procedural memory with realistic decay and retrieval. It is for developers building AI agents with frameworks like OpenAI or LangChain.

✨ Key features

  • Three memory types: episodic, semantic, procedural
  • Ebbinghaus forgetting curve with spaced repetition
  • Graph relationships between memories
  • Hybrid retrieval scoring relevance, recency, importance
  • Framework-agnostic, works with OpenAI, LangChain, raw Python
  • SQLite + FTS5 storage, optional sentence-transformers embeddings

🎯 Use cases

  • Give a chatbot persistent memory of user preferences and facts
  • Let an agent learn from past successes and failures via procedural skills
  • Retrieve relevant context for LLM prompts based on conversation history
  • Consolidate episodic experiences into stable semantic knowledge

📦 Installation

🧰 Requirements: Python environment with pip; optional sentence-transformers for embeddings.

pip install agent-memory

With semantic embeddings (recommended for better retrieval):

pip install "agent-memory[embeddings]"

🚀 Usage

from agent_memory import AgentMemory

memory = AgentMemory()

# Store knowledge
memory.remember("User prefers Python over JavaScript", importance=0.8)
memory.remember("Paris is the capital of France",
                subject="Paris", predicate="capital_of", object_="France")

# Store experiences
memory.add_episode("User asked about sorting algorithms",
                   participants=["user", "agent"], emotional_valence=0.1)

# Learn from outcomes
memory.learn_skill("web_search", "Search the web for current information")
memory.record_skill_outcome("web_search", success=True)

# Retrieve relevant memories
results = memory.recall("what does the user like about Python?", top_k=5)
for r in results:
    print(f"[score={r.score:.3f}] {r.memory.content}")

❓ FAQ

How does agent-memory handle forgetting?

It implements the Ebbinghaus forgetting curve where memory strength decays exponentially over time, but retrieval boosts strength and stability, making frequently recalled memories harder to forget.

Can I use agent-memory with LangChain?

Yes, there is an example integration with LangChain using the AgentMemoryLangChain class as a memory backend.

What storage does agent-memory use?

It uses SQLite with FTS5 for persistent, zero-infrastructure storage.

Does agent-memory require sentence-transformers?

No, it is optional. If not installed, it falls back to TF-IDF for retrieval.

📊 Repository

Stars★ 1
Forks🍴 0
Open issues🐛 0
Last commit🕒 Mar 19, 2026
Created📅 Mar 2026
Language💻 Python
License⚖️ MIT

🤖 Overview, features, install steps and FAQ were generated from the project's README on Sep 4, 2026. Always check the original source before running commands.