Skip to main content

The Tripartite Memory SDK for Autonomous AI Agents. Unify State, Semantic, and Graph memory.

Project description

aegis-memory 🧠

Stop AI agents from repeating the same mistakes.

License Python 3.10+

Most LLM agents fail in the same way: they forget what already happened. They retry failed approaches, ignore system state, and confidently suggest things that already broke production.

This is AI Amnesia.

aegis-memory is a unified async Python SDK that gives AI agents persistent, structured memory across three distinct layers. Before an agent takes action, it can answer:

“Has this failed before?”
“What will this impact?”
“Is this safe to execute?”

Instead of guessing, it knows.

Memory & Context Optimization ⚡

aegis-memory significantly reduces the cost and improves the performance of running large models:

  • 60-80% Token Reduction: Instead of dumping massive chat histories into the prompt, recall() injects only the 3-5 most relevant precedents.
  • VRAM Relief: By keeping context windows lean, models consume less VRAM (which scales quadratically with sequence length). Run larger models (32B/70B) on consumer-grade hardware.
  • Improved Reasoning: Providing specific "Hard Constraints" from the Ledger prevents the LLM from making up rules, leading to deterministic and reliable outputs.

What This Fixes

Without memory:

  • Agents loop on failed solutions.
  • Context windows explode with irrelevant history.
  • Risky actions happen without awareness of dependencies.

With aegis-memory:

  • Agents avoid known failure paths.
  • Context stays small and relevant.
  • Actions are informed by real system state and "trace the real blast radius."

The Tripartite Architecture

To make an LLM safe for production, it needs an operating-system-level memory stack:

  1. The Ledger (Postgres): Immutable state, strict constraints, and audit logs.
  2. The Semantic Engine (Qdrant): High-dimensional vector search for historical precedents and documentation.
  3. The Capability Graph (Neo4j): Dependency mapping to understand how modifying Component A impacts System B.

Installation

pip install aegis-memory

Quickstart

Initialize the MemoryCore with your database credentials (or use a .env file).

import asyncio
from tripartite_memory.core import MemoryCore

async def main():
    # Automatically loads from .env
    memory = MemoryCore()

    # 1. Unified Ingestion (Write to all 3 databases simultaneously)
    await memory.ingest(
        content="Modified the Nginx reverse proxy to route /api/v2 traffic to staging.",
        actor="agent:InfrastructureOps",
        tags=["nginx", "networking", "staging"]
    )

    # 2. Pre-Action Context Check (The Blast Radius)
    # Give your agent complete situational awareness before it touches production.
    context = await memory.recall(
        intent="Restart the Nginx service to apply new SSL certificates.",
        graph_depth=2
    )

    print(context.status) # "KNOWN", "ADJACENT", or "UNKNOWN"
    print(context.blast_radius) # Neo4j dependent nodes
    print(context.historical_precedents) # Qdrant vector matches

if __name__ == "__main__":
    asyncio.run(main())

The Agent Protocol 🛡️

aegis-memory works best when the agent is "forced" to use it. We recommend adding a Memory Protocol to your agent's system prompt. See SYSTEM_PROMPT.md for the exact snippet.

Universal Integration

  • Local Models (Ollama/LM Studio): Inject the recall() JSON directly into the context window before the user's prompt.
  • CLI Clients (Claude Code/Gemini CLI): Wrap the SDK in a tool or use the provided Bridge Script.

Bi-directional Memory Bridge 🔄

We provide a ready-to-use bridge in examples/bridge.py that works on Linux, Mac, and Windows.

# Get Context
python examples/bridge.py recall "How do I optimize VRAM on Pascal?"

# Store Knowledge
python examples/bridge.py ingest "Successfully tuned batch size to 4 for Qwen-32B." --tags optimization

Remote Connection Guide (LAN) 🌐

If testing from a remote machine, point the SDK to your server's IP in your .env:

POSTGRES_URL=postgresql://user:password@10.0.0.100:5432/aegis_local
QDRANT_URL=http://10.0.0.100:6333
NEO4J_URI=bolt://10.0.0.100:7687
NEO4J_PASSWORD=your-secure-password
OLLAMA_URL=http://10.0.0.100:11434

SBOM & Transparency 🛡️

In alignment with AEGIS OS security standards, this repository includes a Software Bill of Materials (SBOM) in CycloneDX format.

  • View SBOM: sbom.json
  • Generate Fresh SBOM: python scripts/generate_sbom.py

Why We Built This

We built this SDK as the foundational memory layer for AEGIS OS—a bare-metal orchestration layer designed to govern AI agents on real infrastructure using deterministic safety tiers (T0/T1/T2).

While the core OS uses a Business Source License (BSL), we believe fundamental agentic memory should be open and standardized. aegis-memory is 100% open-source (Apache 2.0).

Contributing

PRs are welcome. If you are building agentic systems that require strict intent multiplexing and deterministic safety, we'd love to collaborate. e'd love to collaborate. equire strict intent multiplexing and deterministic safety, we'd love to collaborate.

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

tripartite_memory-0.1.0.tar.gz (13.7 kB view details)

Uploaded Source

Built Distribution

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

tripartite_memory-0.1.0-py3-none-any.whl (11.4 kB view details)

Uploaded Python 3

File details

Details for the file tripartite_memory-0.1.0.tar.gz.

File metadata

  • Download URL: tripartite_memory-0.1.0.tar.gz
  • Upload date:
  • Size: 13.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for tripartite_memory-0.1.0.tar.gz
Algorithm Hash digest
SHA256 f7c182333bc4025fa85d4f22994a31a13cad5cc7bed3a78dcdc7186bb9b881d2
MD5 a515ca1ee9111e41e9ae2ebcf1ac2702
BLAKE2b-256 b31a016c4c36ee35c65efdb5f9a74fe107af75b04f28e280873bb2bc258ce593

See more details on using hashes here.

File details

Details for the file tripartite_memory-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for tripartite_memory-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e5fe9adadd7f89ae64027e7e4f6d701c5259d51e7f45d17317a6283457724e5e
MD5 0c22ab97fe538fa30a22112ef25857ce
BLAKE2b-256 6073d889ac2cd462d7f68ac959769c4795f231e8cf0fafc64c01d721b5165398

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