Memory that forgets, like humans do.
A production-grade memory system for AI agents with intelligent forgetting.
Built on cognitive science principles: decay, rehearsal, consolidation, and importance-based retention.
Problem β’ Solution β’ Architecture β’ Quick Start β’ Docs β’ Contributing
Current agent memory solutions accumulate memories forever. This causes:
| Issue | Impact |
|---|---|
| ποΈ Context Pollution | Irrelevant old memories dilute retrieval quality |
| πΈ Cost Explosion | Vector stores grow unbounded |
| β° Temporal Confusion | No distinction between recent and ancient context |
| π¦ No Consolidation | Raw events never become structured knowledge |
Humans don't work this way. We forget. And that's a feature, not a bug.
Cognitive Memory implements a biologically-inspired memory architecture:
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β HOW HUMAN MEMORY WORKS β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β β
β π₯ Experience βββΆ π§ Working Memory βββΆ πΎ Long-term Memory β
β β β β
β β βΌ β
β β βββββββββββββββββ β
β β β Consolidation β β
β β β (during sleep)β β
β β βββββββββ¬ββββββββ β
β β β β
β βΌ βΌ β
β βββββββββββββββ βββββββββββββββ β
β β Decay β β Semantic β β
β β (forgetting)β β Facts β β
β βββββββββββββββ βββββββββββββββ β
β β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
| Feature | Description |
|---|---|
| β³ Decay | Memories weaken over time (exponential decay) |
| π Rehearsal | Accessing a memory strengthens it |
| β Importance | Multi-factor scoring determines retention priority |
| π Consolidation | Weak episodic memories become semantic facts |
| ποΈ Forgetting | Below-threshold memories are pruned |
| Tier | Purpose | Retention | Storage |
|---|---|---|---|
| Working | Current conversation | Session | In-memory |
| Episodic | Past interactions | Days-weeks | Vector DB |
| Semantic | Extracted facts | Months-years | Knowledge Graph |
| Procedural | Skills, patterns | Permanent | PostgreSQL |
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β MEMORY SYSTEM β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β β
β βββββββββββββββ βββββββββββββββ βββββββββββββββ β
β β WORKING β β EPISODIC β β SEMANTIC β β
β β MEMORY β β MEMORY β β MEMORY β β
β β (context) β β (events) β β (facts) β β
β ββββββββ¬βββββββ ββββββββ¬βββββββ ββββββββ¬βββββββ β
β β β β β
β βΌ βΌ βΌ β
β βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β RETRIEVAL ENGINE β β
β β (decay-aware scoring + MMR diversity) β β
β βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β β
β βΌ β
β βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β CONSOLIDATION ENGINE β β
β β (clustering β summarization β fact extraction) β β
β βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
pip install cognitive-memoryfrom cognitive_memory import MemoryManager
# Initialize
memory = MemoryManager()
# Remember something
memory.remember(
content="User prefers dark mode and vim keybindings",
source="conversation",
)
# Recall relevant memories (decay-aware)
results = memory.recall(
query="What are the user's preferences?",
k=5,
)
# Build context for LLM
context = memory.get_context(
query="Help configure their editor",
max_tokens=4000,
)from cognitive_memory.integrations import CognitiveCheckpointer
checkpointer = CognitiveCheckpointer()
graph = builder.compile(checkpointer=checkpointer)from cognitive_memory.integrations import CognitiveMemory
memory = CognitiveMemory()
chain = ConversationChain(llm=llm, memory=memory)Every memory has a strength that decays exponentially:
S(t) = Sβ Γ e^(-Ξ» Γ Ξt)
| Variable | Meaning |
|---|---|
S(t) |
Strength at time t |
Sβ |
Initial strength |
Ξ» |
Decay rate |
Ξt |
Time elapsed |
Rehearsal Effect: When you retrieve a memory, its strength is boostedβjust like how recalling something helps you remember it.
| Factor | Weight | Description |
|---|---|---|
| Access frequency | 25% | How often retrieved |
| Recency | 20% | How recently accessed |
| Emotional salience | 15% | Strong reactions |
| Surprise | 10% | Unexpected information |
| Explicit markers | 20% | User said "remember this" |
| Entity relevance | 10% | Contains important entities |
Periodically, weak episodic memories are:
- Clustered by semantic similarity
- Summarized into semantic facts
- Stored in the knowledge graph
- Pruned from episodic storage
This mimics how human memory consolidates during sleep.
| Feature | Mem0 | Zep | MemGPT | Cognitive Memory |
|---|---|---|---|---|
| Decay function | β | β | β | β |
| Importance scoring | Basic | Basic | β | β Multi-factor |
| Auto consolidation | β | β | Manual | β |
| Principled forgetting | β | β | β | β |
| Multi-tier | β | Partial | β | β 4 tiers |
| Knowledge graph | β | β | β | β |
| LangGraph native | β | β | β | β |
| Document | Description |
|---|---|
| Architecture | System design and components |
| Algorithms | Decay, importance, consolidation |
| Configuration | All configuration options |
| Integrations | LangGraph, LangChain setup |
| Deployment | Production deployment guide |
| Benchmarks | Performance measurements |
π§ In Active Development
This project is under active development. The core architecture is designed, and implementation is in progress.
- Core memory models and configuration
- Decay and importance engines
- Retrieval with decay-aware scoring
- Consolidation engine
- LangGraph integration
- LangChain integration
- REST API
- Benchmarks and evaluation
- v0.1.0 release
Want to contribute? Check out CONTRIBUTING.md or join the Discussions.
We welcome contributions! See CONTRIBUTING.md for guidelines.
# Clone and setup
git clone https://github.com/NP-compete/cognitive-memory.git
cd cognitive-memory
pip install -e ".[dev]"
# Run tests
make test
# Run linters
make lintIf you use Cognitive Memory in your research, please cite:
@software{cognitive_memory,
author = {Dutta, Soham},
title = {Cognitive Memory: Memory that forgets, like humans do},
url = {https://github.com/NP-compete/cognitive-memory},
year = {2026}
}MIT License - see LICENSE for details.
- Inspired by cognitive science research on human memory
- Built for the LangGraph and LangChain ecosystems
- Vector storage: Qdrant, Pinecone
- Knowledge graph: Neo4j
Memory that forgets, so your agents remember what matters.