Skip to main content

Privacy-aware memory isolation for AI agents

Project description

MemGate

Privacy-Aware Memory Isolation Layer for AI Agents

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

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.0.tar.gz (65.3 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.0-py3-none-any.whl (48.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: memgate-0.3.0.tar.gz
  • Upload date:
  • Size: 65.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.3

File hashes

Hashes for memgate-0.3.0.tar.gz
Algorithm Hash digest
SHA256 5bdf92cc8c59ce56ca4c8cf07d2a2f842e0b1552a4476bb576cbfff8b07e8224
MD5 aa4b7fd21b05da69e221dca4300e9034
BLAKE2b-256 539f12d3935026b17daa870c7a67fb0aa8b5101ff9b1faaf492123fa57dee49b

See more details on using hashes here.

File details

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

File metadata

  • Download URL: memgate-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 48.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.3

File hashes

Hashes for memgate-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 611e74ff74fe3397a5d671ef3304bd776f6a4a5b83ac4c7f2f10d7b8e2556aff
MD5 c208a3b4e7e58ad929652a2ecab43611
BLAKE2b-256 c55756350bc6209e951b5e0ba47f813ce4654a20fa6780d6e2ffff6a314aadfa

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