Catalog PyPI
PACKAGE EXPLORERView in registry

agent-memory-toolkit

PyPI

Hybrid retrieval memory for AI agents - BM25 + vectors + knowledge graph with RRF fusion

agentsaibm25embeddingsfts5knowledge-graphmemoryragsqlitevector-search
Versions collected1
Direct dependencies20From release 0.1.0
Last observed20 Oct, 22:41 UTC

README

Version 0.1.0 documentation

🧠 agent-memory-toolkit

Hybrid retrieval memory for AI agents that actually remembers.

GitHub stars CI PyPI Python 3.11+ License: MIT

BM25 + Vectors + Knowledge Graph · RRF Fusion · Ebbinghaus Decay · Local-First

Features · Install · Quick Start · Benchmarks · Docs


🎯 Why agent-memory-toolkit?

Most agent memory is just "dump everything in a vector DB and pray." That doesn't scale.

agent-memory-toolkit uses hybrid retrieval:

  • 🔍 BM25 for exact keyword matches
  • 🧬 Vector search for semantic similarity
  • 🕸️ Knowledge graph for relational context
  • ⚡ RRF fusion to combine results intelligently
  • 📉 Ebbinghaus decay so recent memories surface naturally

95.2% R@5 on LongMemEval-S — state-of-the-art recall for long-term agent memory


🔐 Local-First. Your Data Stays Yours.

No cloud. No API calls for storage. Everything runs on SQLite.

  • ✅ Works offline
  • ✅ GDPR-friendly
  • ✅ Airgapped environments
  • ✅ Full control over your data

✨ Features

FeatureDescription
🔍Hybrid RetrievalBM25 + vectors + knowledge graph with RRF fusion
📉Ebbinghaus DecayRecent memories surface first, old ones fade naturally
📝Structured Extraction6 cognitive domains (bio, preferences, work, social, temporal, procedural)
🔒Security GuardPoison detection, confidence scoring, source validation
📦Smart CompressionToken-aware context compression for LLM context windows
👥Team CollaborationGit-like branching, merging, and sync for multi-agent systems
🔄Version ControlFull history tracking with commits and rollback

📦 Install

pip install agent-memory-toolkit

With all features:

pip install agent-memory-toolkit[all]

🚀 Quick Start

from agent_memory_toolkit import MemoryStore

# Create a local memory store
store = MemoryStore("memories.db", auto_embed=True)

# Add memories
store.add("User prefers dark mode and vim keybindings")
store.add("Project deadline is Friday, client is Acme Corp")
store.add("Last meeting discussed Q4 roadmap")

# Hybrid search (BM25 + vectors + recency decay)
results = store.search("vim preferences", mode="hybrid")

for r in results:
    print(f"[{r.score:.2f}] {r.memory.content}")

Extract Structured Memories

from agent_memory_toolkit import MemoryExtractor

extractor = MemoryExtractor()

text = """
Hi, I'm Sarah Chen. I work as a Senior Engineer at TechCorp.
I prefer Python over JavaScript and usually work 9-5 PST.
"""

memories = extractor.extract(text)

for m in memories.memories:
    print(f"[{m.domain.value}] {m.key}: {m.value}")
# [biography] name: Sarah Chen
# [work] role: Senior Engineer
# [preferences] preferred_language: Python

🏗️ Architecture

┌─────────────────────────────────────────────────────────────────────────────┐
│                             AGENTMEMORY                                     │
├─────────────────────────────────────────────────────────────────────────────┤
│                                                                             │
│  ┌─────────────┐   ┌──────────────┐   ┌───────────────┐   ┌─────────────┐  │
│  │ Extraction  │   │   Storage    │   │  Compression  │   │  Security   │  │
│  │   Module    │   │    Store     │   │    Engine     │   │   Guard     │  │
│  │             │   │              │   │               │   │             │  │
│  │ • Rule-based│   │ • SQLite     │   │ • Token aware │   │ • Poison    │  │
│  │ • LLM-based │   │ • FTS5/BM25  │   │ • Importance  │   │   detection │  │
│  │ • Hybrid    │   │ • Vectors    │   │   ranking     │   │ • Confidence│  │
│  │ • 6 domains │   │ • RRF Fusion │   │ • Strategies  │   │   scoring   │  │
│  └─────────────┘   └──────────────┘   └───────────────┘   └─────────────┘  │
│         │                  │                   │                  │        │
│         └──────────────────┴───────────────────┴──────────────────┘        │
│                                    │                                        │
│                        ┌───────────┴───────────┐                           │
│                        │   Team Memory Store   │                           │
│                        │                       │                           │
│                        │ • Git-like branching  │                           │
│                        │ • Conflict resolution │                           │
│                        │ • Filesystem sync     │                           │
│                        │ • Access control      │                           │
│                        └───────────────────────┘                           │
│                                                                             │
└─────────────────────────────────────────────────────────────────────────────┘

📊 Benchmarks

Metricagent-memory-toolkitVector-onlyBM25-only
R@5 (LongMemEval-S)95.2%78.4%71.2%
Latency (p50)8ms5ms0.5ms
Memory Usage120MB200MB40MB

Hybrid retrieval with RRF fusion significantly outperforms single-strategy approaches.


⚡ Performance

OperationTime
Rule-based extraction~1ms per 1KB
BM25 search (FTS5)~0.5ms
Vector search~5ms
Hybrid search~8ms
Security validation~2ms

📖 API Reference

MemoryStore

from agent_memory_toolkit import MemoryStore

store = MemoryStore(
    db_path="memories.db",
    auto_embed=True,
    embedding_model="all-MiniLM-L6-v2"
)

# Core operations
store.add(content, metadata=None)
store.get(memory_id)
store.update(memory_id, content=None, metadata=None)
store.delete(memory_id)

# Search modes
store.search(query, mode="hybrid")  # BM25 + vectors + decay
store.search_fts(query)             # BM25 only
store.search_vector(query)          # Vectors only

MemoryExtractor

from agent_memory_toolkit import MemoryExtractor, CognitiveDomain

extractor = MemoryExtractor(mode="rule")  # or "llm", "hybrid"
result = extractor.extract(text)

MemoryGuard

from agent_memory_toolkit import MemoryGuard, SecurityLevel

guard = MemoryGuard(level=SecurityLevel.HIGH)
result = guard.validate_content(content)

if result.is_safe:
    store.add(content)

TeamMemoryStore

from agent_memory_toolkit.team import TeamMemoryStore

store = TeamMemoryStore("team.db", agent_id="alice")

# Git-like operations
store.create_branch("experiment")
store.checkout("experiment")
store.commit("Added new findings")
store.push("/shared/memories")
store.pull("/shared/memories")

📂 Examples

See examples/ for working demos:


🧪 Testing

pytest
pytest --cov=agent_memory_toolkit

🤝 Contributing

  1. Fork the repo
  2. Create a feature branch (git checkout -b feature/amazing)
  3. Commit changes (git commit -m 'Add amazing feature')
  4. Push to branch (git push origin feature/amazing)
  5. Open a Pull Request

📄 License

MIT License — see LICENSE


⭐ Star us on GitHub — it helps!

Built with ❤️ by autosre.ai

Downloads & popularity

Awaiting observations

No metric observations yet

Download counts and popularity will appear here as the collector receives them.

Versions 1

Collected releases
VersionPublishedDirect dependenciesOpen version
0.1.023 May 202620

Package advisories

0
No matching advisories collected

This describes our collected data; it is not a security assessment.

Repository

PENDING
autosre-ai/agent-memory-toolkit

Shared repository data · GitHub

License detected in repository
Not collected

Metadata history

Meaningful changes
Current collected state Current

Observed since 20 Oct, 22:41 UTC

No superseded metadata states collected. Unchanged observations do not create new revisions.

Record identity

package:d23861b6a665c95e18146da8cbd6ca2c042c9b1af70c6f7115cf41135fddb81b