Skip to main content

Zero-trust memory toolkit for AI Agents. Pure Python, zero infrastructure, self-defending.

Project description

Your AI remembers every conversation. But โ€”

  • Is someone writing garbage into your memory?
  • Did that private info you discussed yesterday leak into a file?
  • Context window full โ€” will you lose what matters?

MOYU is a security-first memory layer for AI Agents. Pure Python, one folder, plug and play. LLM-enhanced features are on by default; no API key? Silent degrade, core memory keeps working.

Install and go:

pip install moyu-memory
moyu quickstart    # 5-minute interactive demo, zero config

Three things that make MOYU different

  • ๐Ÿ›ก๏ธ Security built in โ€” Injection detection (regex + 8-class LLM guard), PII redaction, file integrity verification, write burst protection. Security isn't an add-on, it's default.
  • โณ Lifecycle on autopilot โ€” Context compression, forgetting curve, memory merge โ€” all automatic. No more losing important things when context fills up.
  • ๐Ÿง  Retrieval + adaptive tuning โ€” Semantic + keyword + recency + entity hybrid search with configurable weights. Search feedback feeds moyu tune which auto-adjusts weights over time.

๐Ÿ† Comparison

Dimension MOYU Mem0 Letta Zep Cognee
Setup pip, zero config pip + API Key Runtime setup Cloud simple, self-host complex uv pip install
External deps Storage layer zero-dependency LLM API + vector DB LLM API + storage Self-host needs graph DB LLM API
Security Injection defense + PII redaction + integrity + zero-trust, on by default API Key + compliance Framework isolation Cloud SOC2/HIPAA Tenant isolation
Retrieval Semantic+BM25+time+entity, configurable weights + adaptive tuning Semantic+BM25+entity 3-way fusion Agent tool pagination Temporal graph Graph+vector hybrid
Lifecycle Compression/forgetting/merge/scene classification, fully automatic ADD-only, no forgetting 3-tier, auto pagination Temporal graph auto versioning Feedback learning, needs config
Knowledge Graph Entity extraction + time-travel + distillation Pro $249/mo Indirect (external tools) Temporal graph, all tiers Core feature, full OSS
Offline Fully offline Partial (local embed) Self-hostable Self-host only Fully local

Bottom line: MOYU excels at security, offline capability, lifecycle management, and configurable retrieval โ€” areas where alternatives offer little to none. Choose by your scenario, not by feature count.


๐ŸŽฎ Who is it for

  • Your AI Agent needs persistent memory with real security
  • Frequently hit context limits, need auto-compression without losing important content
  • Worried about PII leaks โ€” don't want phone numbers, IDs, API keys in memory files
  • Want zero infrastructure โ€” no Docker, no databases, no signups

๐Ÿ”ฌ Full Capability Index

New here? Start with the "Three things that make MOYU different" section above, then the comparison table.

๐Ÿ›ก๏ธ Defense Layer (9)

# Capability Description
1 Content Security Gate Pre-write injection blocking โ€” 516 regex patterns + 8-class LLM recheck
2 Forensic Analysis Detect injection patterns, JSON corruption, file tampering
3 Write Burst Protection >30 writes/60s โ†’ rollback + 5-min lock
4 Tool Call Loop Detection SHA256 fingerprint + exhaustive cycle scan + hard abort
5 PII Redaction Bilingual: phones, IDs, bank cards, emails, SSNs, IPs, API keys
6 Password Verification Pre-op confirmation + auto-lock after 3 failures (30 min)
7 Integrity Check & Recovery SHA256 manifest + daily backups (3-day retention)
8 User Isolation & Encryption (opt-in) Per-user directories + AES-256-GCM encryption
9 LLM Security Guard Regex-untouched inputs โ†’ LLM verdict (8 classes). Never blocks legitimate writes

๐Ÿง  Memory & Retrieval Layer (7) 2 LLM-Enhanced

# Capability Description
1 TEMPR Multi-Strategy Retrieval Semantic + BM25 + time-weighted + entity, configurable weights
2 Search Rerank LLM LLM re-ranks candidates by semantic relevance (on by default, degrades without key)
3 Smart Summary LLM Writes auto-refined by LLM โ€” filler out, facts in
4 FastEmbed Local Embedding Local ONNX vectorization, no API needed, auto-degrades to n-gram
5 SQLite FTS5 + MD5 Dedup Full-text index + in-memory/batch double dedup
6 Search Feedback Collection Explicit votes + implicit ref/correction signals โ€” feeds adaptive tuning
7 Adaptive Weight Tuning moyu tune โ€” auto-optimizes retrieval weights from feedback data

๐Ÿ“Š Knowledge Layer (3) 1 LLM-Enhanced

# Capability Description
1 Knowledge Graph LLM Entity extraction + time-travel + relation invalidation + distillation
2 Workflow Knowledge Base Markdown indexing + keyword search
3 User Profile Auto-extract preferences, habits, facts from conversation

โณ Lifecycle Layer (4) 3 LLM-Enhanced

# Capability Description
1 Context-Aware Compression + Warning Two-tier compression, originals preserved, auto-warning before compression
2 Task Map Auto-generated Mermaid task graph on wake
3 Forgetting Curve LLM Four gates (safety/access/scene/LLM semantic review) + LLM scene classification
4 Memory Merge LLM Related memories auto-merged with LLM summary, originals preserved

๐Ÿ”„ Learning & Reflection (2)

# Capability Description
1 Learn from Corrections Auto-detect correction signals, 3 identical โ†’ permanent behavioral rule
2 Self-Reflection Cross-time association, contradiction detection, topic shift analysis

๐Ÿ”— Integration Layer (5)

# Capability Description
1 Working Memory Independent file, survives context compression
2 Cross-Session Bridge Summaries auto-synced to prefill + current_context
3 Auto-Update GitHub release check + TOFU checksum + in-place update
4 Wake Orchestration Checkโ†’backupโ†’forgetโ†’mergeโ†’reflectโ†’contextโ†’bridge โ€” fully automatic
5 Memory Injection moyu inject โ€” standardized injection with built-in context warning

๐Ÿ›ก๏ธ Security Assessment

MOYU's defense chain is a layered deterrent, not a silver bullet. Honest assessment:

Level Threat Coverage
๐ŸŸข Accidental misuse (fat-finger, mis-script) ~90%
๐ŸŸข Script-kiddie injection (known patterns) ~70%
๐ŸŸก Simple prompt injection (standard variants) ~65%
๐ŸŸ  Professional adversarial injection (targeted bypass) ~25%
๐ŸŸ  Semantic injection (metaphor, no keywords) ~60% (LLM layer)
๐ŸŸข Combined defense 1,769 test cases, 15 attack categories, 0% false positives. Run moyu benchmark --full to reproduce

๐Ÿš€ Quick Start

One-line install:

pip install moyu-memory

5-minute interactive demo:

moyu quickstart
# โ†’ Auto-stores sample memories, runs injection attack tests,
# โ†’ shows defense chain in action, reports results.
# โ†’ Zero config, no API key needed

Integrate with your Agent:

moyu inject "current conversation topic"
# โ†’ Outputs relevant memories (with context warning), ready for System Prompt injection

Or from your code:

from moyu_toolkit.moyu import inject_context
inject_context("current conversation topic")  # Auto-search, format, inject

Copy the toolkit (no pip needed):

pip install -r requirements.txt

Copy the moyu_toolkit/ folder into your project, run python3 moyu.py.


๐Ÿ“‹ Command Reference

Defense & Security

moyu setup moyu verify moyu unlock moyu check moyu audit moyu init moyu rules moyu benchmark moyu demo-attack moyu doctor moyu mutate

Memory & Retrieval

moyu search <query> moyu search --vote <id> good|bad moyu search --ns <ns> moyu inject <query> moyu config show moyu config set retrieval.weights.<dim> <val> moyu tune / --dry-run / --reset moyu stats moyu status

Knowledge Layer

moyu kg search <entity> moyu kg history <entity> moyu kb search <keyword>

Lifecycle & Context

moyu compress moyu context moyu forget moyu ref <name> moyu snapshot

Learning & Maintenance

moyu learn <text> moyu quickstart moyu reflect moyu setup agents moyu update


๐Ÿ“ File Structure

moyu_toolkit/
โ”œโ”€โ”€ _llm_client.py            # Unified LLM client
โ”œโ”€โ”€ agent_memory.py           # Vector memory engine + TEMPR retrieval
โ”œโ”€โ”€ agent_memory_sqlite.py    # SQLite FTS5 search index
โ”œโ”€โ”€ active_context.py         # Working memory
โ”œโ”€โ”€ context_manager.py        # Context compression + warning + task map
โ”œโ”€โ”€ forgetting_curve.py       # Forgetting curve + LLM review
โ”œโ”€โ”€ memory_merge.py           # Memory merge
โ”œโ”€โ”€ knowledge_graph.py        # Entity-relation knowledge graph
โ”œโ”€โ”€ knowledge_base.py         # Workflow knowledge base
โ”œโ”€โ”€ learner.py                # Learn from corrections
โ”œโ”€โ”€ security.py               # Password + lockout
โ”œโ”€โ”€ feedback.py               # Search feedback collection
โ”œโ”€โ”€ tune.py                   # Adaptive weight tuning
โ”œโ”€โ”€ quickstart.py             # 5-minute interactive demo
โ”œโ”€โ”€ moyu.py                   # CLI entry point
โ”œโ”€โ”€ moyu_wake.py              # Startup pipeline
โ”œโ”€โ”€ defense_toolkit/
โ”‚   โ”œโ”€โ”€ integrity_checker.py  # File integrity + LLM guard
โ”‚   โ”œโ”€โ”€ forensic_patterns.json # 516 injection detection patterns
โ”‚   โ””โ”€โ”€ pii_redactor.py       # PII redaction
โ”œโ”€โ”€ tests/
โ”‚   โ””โ”€โ”€ test_all.py           # Automated tests
โ”œโ”€โ”€ config.yaml               # Configuration
โ””โ”€โ”€ requirements.txt

๐Ÿ“œ License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

moyu_memory-2.7.0.tar.gz (173.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

moyu_memory-2.7.0-py3-none-any.whl (190.5 kB view details)

Uploaded Python 3

File details

Details for the file moyu_memory-2.7.0.tar.gz.

File metadata

  • Download URL: moyu_memory-2.7.0.tar.gz
  • Upload date:
  • Size: 173.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.15

File hashes

Hashes for moyu_memory-2.7.0.tar.gz
Algorithm Hash digest
SHA256 4ed49a867c0d8b43f73781e44166168633a09378aba3a9b6efa17afd1ed370d4
MD5 46d5611476903a51f1c7c23ae6cee7e7
BLAKE2b-256 b642b2e38ef8524f9075ae95aa6b1e9c241b3eefd9d4ccd3fff0bfa97d44f304

See more details on using hashes here.

File details

Details for the file moyu_memory-2.7.0-py3-none-any.whl.

File metadata

  • Download URL: moyu_memory-2.7.0-py3-none-any.whl
  • Upload date:
  • Size: 190.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.15

File hashes

Hashes for moyu_memory-2.7.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7c60ac8d1c8db88d8624f140712933712361b4d3cbe8337224b3792710f3e104
MD5 c36314d602fbe2940d0b5d11ec2452bb
BLAKE2b-256 90bd8feb71eaf4a73bb8419f5e2df5004a55b92b842d650ff3e9d723f73c9e0e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page