A five-layer memory system for AI agents. Gives agents persistent, searchable, structured memory that improves over time.
Also available as a Moltbot Skill — drop into any OpenClaw agent.
┌─────────────────────────────────────────────────────────────────┐
│ Memory System Architecture │
├─────────────────┬─────────────────┬─────────────────────────────┤
│ Layer │ Storage │ Purpose │
├─────────────────┼─────────────────┼─────────────────────────────┤
│ Episodic │ Markdown+Qdrant │ Conversation logs │
│ Semantic │ Qdrant │ Similarity search │
│ Knowledge Graph │ FalkorDBLite │ Entities & relationships │
│ Procedural │ heuristics.md │ Learned rules │
│ Meta-Cognition │ JSONL stats │ Self-improvement tracking │
└─────────────────┴─────────────────┴─────────────────────────────┘
Conversation → Episode logged → Chunked → Embedded (Ollama) → Indexed (Qdrant)
│
├──→ Entity extraction → Knowledge Graph (FalkorDB)
│
└──→ Implicit feedback → Lessons → Heuristics
Raw conversation logs with timestamps, participants, and topics. The "what happened" layer.
Vector embeddings of all memory content for similarity search. "Find memories related to X."
Structured entities (people, places, concepts) and their relationships with bi-temporal tracking:
- Valid time: When the fact was true in the real world
- Transaction time: When the agent learned the fact
Learned rules and heuristics from successes and failures. "Don't do X because Y happened."
Tracks retrieval quality for self-improvement. "Did I find the right memory? How can I do better?"
# Install
pip install agent-memory
# Or run from source
git clone https://github.com/pipaitrader/agent-memory
cd agent-memory
pip install -e .
# Initialize memory system
agent-memory init
# Log an episode
agent-memory log "Had a conversation with Andy about trading strategies"
# Search memories
agent-memory search "trading strategies"
# Add a heuristic
agent-memory learn "Always verify stop losses manually - automated ones may fail"
# Query knowledge graph
agent-memory graph query "What do I know about Andy?"# config.yaml
memory:
episodic:
path: ./memory/episodes
semantic:
backend: qdrant # or chromadb, pinecone
embedding_model: ollama/nomic-embed-text
graph:
backend: falkordb # or neo4j, memgraph
procedural:
path: ./memory/heuristics.md
metacognition:
path: ./memory/stats.jsonl- Python 3.10+
- Ollama (for embeddings) or OpenAI API key
- Qdrant (vector store) - can run locally via Docker
- FalkorDBLite (graph store) - embedded, no setup needed
- Project structure
- Episodic layer (markdown logging)
- Procedural layer (heuristics.md)
- Semantic layer (Qdrant integration)
- Knowledge graph (FalkorDBLite)
- Meta-cognition tracking
- CLI tool
- Python SDK
- MCP server integration
PRs welcome! See CONTRIBUTING.md.
MIT
Built by @pipaitrader 🎯