Skip to main content

Privacy-aware memory isolation for AI agents

Project description

MemGate

Privacy-Aware Memory Isolation Layer for AI Agents

Website CI PyPI

🛡️ Current Version: 0.3.0 ("Little Crayfish" Protocol)

📖 Documentation & Website →

MemGate acts as a firewall between your AI agent's long-term memory and its output channels. It ensures that private information (like calendar events, financial data, or family details) is never leaked into public contexts (like group chats), even if the LLM attempts to generate it.

Features

  • Context-Aware Privacy: Automatically distinguishes between Private (DM) and Public (Group) contexts.
  • Pattern-Based Filtering: Regex-based interception for high-risk categories (Phone, Email, Finance, Calendar).
  • Knowledge Store: Simple JSON-based local vector store (extensible).
  • "Little Crayfish" Protocol: Strict CI/CD pipeline ensuring no privacy regressions.
  • Red Team Arena: Built-in adversarial testing framework (memgate/tests/red_team/).

Installation

git clone https://github.com/carlnoah6/memgate.git
cd memgate
pip install -e .

Usage

CLI

# Check a message for privacy violations
python3 scripts/privacy-check.py review \
  --message "My phone number is 13800138000" \
  --channel-type group \
  --participants "alice,bob"

Python API

from memgate.privacy_review import PrivacyReviewer
from memgate.knowledge_store import KnowledgeStore

store = KnowledgeStore("path/to/knowledge")
reviewer = PrivacyReviewer(store=store)

result = reviewer.review(
    "Check out my salary: $50k",
    channel_id="group_chat_1",
    participants={"alice", "alice"}
)

if not result.passed:
    print(f"BLOCKED: {result.violations}")

Development

Running Tests

MemGate uses pytest for its test suite, including the "Red Team" mock scenarios.

pip install pytest
pytest

Pre-commit Hooks

Ensure code quality and security (prevent API key leaks) before committing:

pip install pre-commit
pre-commit install

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

memgate-0.3.3.tar.gz (21.4 kB view details)

Uploaded Source

Built Distribution

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

memgate-0.3.3-py3-none-any.whl (26.6 kB view details)

Uploaded Python 3

File details

Details for the file memgate-0.3.3.tar.gz.

File metadata

  • Download URL: memgate-0.3.3.tar.gz
  • Upload date:
  • Size: 21.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for memgate-0.3.3.tar.gz
Algorithm Hash digest
SHA256 c4376302e6839326f828b63ae1bdab6d01b88e51c676eee1c33a5c20bcccbeac
MD5 599ec0221d3a72358a8d95138c373340
BLAKE2b-256 f8811f8a8e4d86ceab7199ba35918f75a0a1553d5ee149ba629067c2ac772fe5

See more details on using hashes here.

File details

Details for the file memgate-0.3.3-py3-none-any.whl.

File metadata

  • Download URL: memgate-0.3.3-py3-none-any.whl
  • Upload date:
  • Size: 26.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for memgate-0.3.3-py3-none-any.whl
Algorithm Hash digest
SHA256 a1bb75d6fa963a87bf0ca5101e78f2cbab6bd9311977db2f9e30330fa07eb659
MD5 4cb0f87f38f95454367c023e7b06a1d9
BLAKE2b-256 ada2a6600634b5298af01d0b19c97ffcbc4aa5087c02ad7453dd165f323b25f3

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