Skip to main content

The official AEGIS OS Tripartite Memory SDK for Autonomous Agents.

Project description

AEGIS Tripartite Memory SDK 🧠

Available on PyPI as tripartite-memory

PyPI Version 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.

tripartite-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 ⚡

tripartite-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 tripartite-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 tripartite-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 🛡️

tripartite-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

Managed Cloud Support ☁️

tripartite-memory is compatible with major managed database providers. Just update your .env with the cloud connection strings:

  • Vector (Qdrant): Works with Qdrant Cloud. Set QDRANT_API_KEY in your environment.
  • Graph (Neo4j): Works with Neo4j AuraDB. Use your provided bolt:// URI and password.
  • Ledger (Postgres): Works with Neon or Supabase.
# Cloud Example
QDRANT_URL=https://your-cluster.qdrant.tech
QDRANT_API_KEY=your-api-key
NEO4J_URI=bolt+s://your-instance.databases.neo4j.io

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. tripartite-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.

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.4.tar.gz (15.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.4-py3-none-any.whl (12.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: tripartite_memory-0.1.4.tar.gz
  • Upload date:
  • Size: 15.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.4.tar.gz
Algorithm Hash digest
SHA256 62454b7038874d793c5f03b08336b27b720d131e07099f6883639166db9121c9
MD5 d204ef25f590a1a15bb61f47b0306355
BLAKE2b-256 2501f19ef15e531b7ee04a871e48d976519d10fc8ddc04e04e6a7cf2a36197e7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for tripartite_memory-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 f82420a8dc2cd0f4f1c3982b749b25bee6ed18caae284f5b64c06dbf3a4b7f09
MD5 f3aafeec74533095d6923cac8e1b997b
BLAKE2b-256 62589c7ba780503450f4446f1e63313ce4069bb576dc7e39f77b7abd2dd8f403

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