convez.ai
MCP Server
quantifylabs

aegis-memory

quantifylabs/aegis-memory

Ver no GitHub
BomPluginScore · de 0 a 100

Secure context engineering for AI agents. Content security · integrity verification · trust hierarchy · ACE patterns. Self-hosted, Apache 2.0.

Instalação

$npx convez-ai quantifylabs/aegis-memory

1 comando no terminal: detecta o formato do repositório (marketplace ou plugin avulso) e instala via Claude Code. Requer Node 18+ e o Claude Code instalado.

Métricas

Estrelas
27
Forks
7
Acompanhando
2
Saúde
71%
Último commit
há 3 meses
Versão
v2.7.0
Issues abertas
14
Contribuidores
3

README

A tradução para o português deste README ainda está na fila.


The Problem Nobody Else Is Solving

Agents are getting compromised. Not theoretically — right now.

  • EchoLeak (CVE-2025-32711, CVSS 9.3) — a single email triggered zero-click data exfiltration from Microsoft 365 Copilot1
  • CrewAI + GPT-4o — researchers achieved 65% exfiltration success rate against multi-agent systems (COLM 2025)2
  • Drift chatbot cascade — one compromised chatbot integration cascaded into 700+ organizations via Salesforce, Google Workspace, Slack, S3, and Azure3
  • OWASP Top 10 for Agentic Applications published December 2025 — memory and context manipulation is a top risk category4

Agent A's output is Agent B's instruction. Memory is the vector.

Every other memory layer trusts content by default. That is the vulnerability.

What Your Context Layer Is Missing

We audited the docs, repos, and changelogs of every major memory tool.5 These protections do not exist anywhere else:

Security Featuremem0ZepLettaAegis
Content injection detection———4-stage pipeline
Memory integrity———HMAC-SHA256
Agent identity binding———Cryptographic API key
Trust hierarchy———4-tier OWASP model
Per-agent rate limiting———Sliding window
Security audit trail———Immutable event log
Sensitive data protection———Auto-detect + reject/redact/flag

Guard every write (the firewall)

Agent A's output is Agent B's instruction. Memory is the vector. So gate the write — and the topology stops mattering. Across every multi-agent shape (cooperative blackboard, hierarchical handoff, swarm, competitive), the invariant is the same: something becomes durable memory and a later/other step reads it back and acts. aegis_memory.guard is the one scope-aware gate every topology funnels through. It runs the same benchmark-validated ContentSecurityScanner the server does — offline, deterministic, no server required:

from aegis_memory import guard

# Wrap any store (LangGraph / vector DB / custom) — every write is screened before it persists.
store = guard.protect(my_store, scope="agent-shared")
store.put(ns, key, {"text": untrusted_web_content})   # a poisoned write never reaches memory

# …or screen a single value inline before you persist it.
verdict = guard.write(content, trust_level="untrusted", scope="agent-shared", on_reject="return")
if verdict.allowed:
    my_store.put(ns, key, {"text": verdict.content})

The gate rejects prompt-injection and secrets, flags PII, and refuses to let untrusted content land in global scope (where every agent would read it). aegis inspect finds the unsafe write sites; guard is the fix it points you at.

The Context Hub (v2.3.0+)

Aegis is the only OSS context hub. Four artifacts, one secure surface, one API call to load them all:

ArtifactWhat it isEndpoint
PromptsVersioned, with one active version per name/prompts/*
MemoryWhat we've always done — secure, ranked, decayed/memories/*
SkillsAnthropic Agent Skills spec, semantic activation/skills/*
SubagentsDelegation surface with tool + scope policy/subagents/*
BundleLoad all four in one call, token-budgetedPOST /context/load

Every artifact: HMAC integrity-signed. Content-scanned. Trust-gated. Audit-logged.

from aegis_memory import AegisClient
client = AegisClient(api_key="...")

bundle = client.load_context(
    agent_id="executor",
    query="paginate the orders API",
    token_budget=8000,
)
# → ranked memories + active prompt + matched skills + available subagents
# → integrity-verified across all four
# → token-budgeted to fit your model

Other context hubs (LangSmith, MindStudio) are closed-source. Other memory layers (mem0, Zep, Letta) stop at memory. Aegis does both, with security as the foundation.

Memory Depth (v2.4.0)

Beyond storing memories, Aegis owns their lifecycle. mem0, Zep, and Letta ship variants of these primitives; what's distinct in Aegis is the audit-preserving and human-reviewable shape of each one — typed edges with explicit resolution states, consolidation that soft-deprecates rather than deletes.

Hybrid retrieval. Every query runs through dense (pgvector cosine) and sparse (PostgreSQL tsvector) channels, fused with Reciprocal Rank Fusion. Catches the exact-match cases (entity names, error codes, tool names, file paths) that pure embedding similarity blurs.

results = client.hybrid_query(query="ZX7-PAGE-94 cursor pagination", agent_id="executor")

Contradiction detection. When two memories make incompatible claims, Aegis surfaces the conflict as a contradicts edge — a typed link with confidence and rationale. Resolve via API.

client.scan_contradictions(namespace="default")
unresolved = client.list_contradictions()
client.resolve_edge(edge_id=..., resolution="kept_source")
metrics = client.contradiction_metrics()
# → {"unresolved_contradictions": 3, "total_contradictions_detected": 17}

Semantic consolidation. Real merge, not prefix matching. Embedding-similar memories above threshold get merged via heuristic or LLM, with full audit trail (losing memory stays queryable with is_deprecated=True and metadata.consolidated_into).

plan = client.consolidate_memories(dry_run=True)   # review first
client.consolidate_memories(dry_run=False)         # then apply

Built for a World Where Agents Get Compromised

Aegis implements OWASP AI Agent Security recommendations natively. Six capabilities, none optional:

  1. 4-stage content security pipeline — input validation, sensitive data scanning, prompt injection detection, optional LLM-based injection classification. Every memory write. Not optional.
  2. HMAC-SHA256 integrity signing — tamper detection on store, verification on demand. You know if a memory was modified.
  3. OWASP 4-tier trust hierarchy — untrusted, internal, privileged, system. Agents get compromised. Aegis limits the blast radius.
  4. Cryptographic agent binding — API keys bound to agent identity. No more trusting a request body that says "I'm the admin agent."
  5. ACE loop — generation, reflection, curation. Agents that learn from their own mistakes and promote what works.
  6. Multi-agent coordination — scoped access control, cross-agent query, structured handoffs. Memory sharing with boundaries.

Get Running in 2 Minutes

Start the server

git clone https://github.com/quantifylabs/aegis-memory.git
cd aegis-memory

export OPENAI_API_KEY=sk-...
docker compose up -d

curl http://localhost:8000/health
# {"status": "healthy"}

Install the SDK

pip install aegis-memory

Multi-agent context in 10 lines

from aegis_memory import AegisClient

client = AegisClient(api_key="dev-key", base_url="http://localhost:8000")

# Planner agent stores task breakdown
client.add(
    content="Task: Build login. Steps: 1) Form, 2) Validation, 3) API",
    agent_id="planner",
    scope="agent-shared",
    shared_with_agents=["executor"]
)

# Executor queries planner's memories
memories = client.query_cross_agent(
    query="current task",
    requesting_agent_id="executor",
    target_agent_ids=["planner"]
)
print(memories[0].content)

Full Quickstart Guide

Context That Improves Itself

Aegis Memory is the first context layer with a complete ACE loop — the Generation → Reflection → Curation cycle from Stanford/SambaNova's research, engineered for production.

Your agent made the same mistake 5 times? ACE loop remembers the fix forever. Stale memories polluting retrieval? Curation auto-cleans your playbook.

Generation          Execution          Reflection          Curation
    |                   |                   |                  |
 Query playbook  ->  Run task with   ->  Auto-vote on    ->  Promote effective
 for strategies      tracked memories    used memories       Flag ineffective
                                         Auto-reflect        Consolidate duplicates
                                         on failures

Full ACE Loop in Code

from aegis_memory import AegisClient

client = AegisClient(api_key="your-key")

# 1. GENERATION: Query agent-specific playbook
playbook = client.get_playbook_for_agent(
    "executor",
    query="API pagination task",
    task_type="api-integration",
)
memory_ids = [e.id for e in playbook.entries]

# 2. EXECUTION: Track which memories the agent uses
run = client.start_run(
    "task-42", "executor",
    task_type="api-integration",
    memory_ids_used=memory_ids,
)

# ... agent does its work ...

# 3. REFLECTION: Complete with outcome (auto-feedback!)
client.complete_run("task-42", success=True, evaluation={"score": 0.95})
# -> Auto-votes 'helpful' on every memory used
# -> On failure: auto-votes 'harmful' AND creates a reflection memory

# 4. CURATION: Periodically clean up
curation = client.curate(namespace="production")
# -> Promotes high-effectiveness entries
# -> Flags low-effectiveness for deprecation
# -> Identifies duplicate entries to consolidate

What "Engineered" Means vs "Inspired"

FeatureACE-InspiredAegis ACE-Engineered
VotingManual vote endpointsAuto-voting tied to run outcomes
ReflectionManual reflection creationAuto-reflection on failure with error context
CurationNot implementedFull curation cycle with promote/flag/consolidate
Run trackingNot trackedFirst-class ace_runs table linking memories to outcomes
Agent-specific playbookGeneric queryFiltered by agent_id + task_type

ACE Patterns Guide

Choosing the Right Tool

Different tools solve different problems. This comparison stays focused on capabilities clearly documented in public repos and docs.5

If you need...Usually pickReason
Personalized assistant memory (user/profile facts)mem0Designed around persistent user/agent memory for assistants
Personal/team "second brain" with ingestionSupermemoryKnowledge-base style memory with connectors
Graph-native episodic memory over agent eventsGraphiti / ZepFocused on temporal + knowledge graph memory models
Stateful agent runtime + built-in memory blocksLettaAgent framework centered on durable state
Secure context engineering with built-in security, trust, and complianceAegis MemoryOnly context layer with content security, integrity verification, and trust hierarchy
Multi-agent coordination with access boundariesAegis MemoryScope-aware ACLs + cross-agent query APIs
Self-improving context loops (what worked / failed)Aegis MemoryACE patterns: vote, reflection, playbook

Quick Feature Comparison

Memory-depth primitives (hybrid retrieval, contradiction handling, consolidation) are now table stakes — mem0, Zep, Letta, and Aegis all ship variants in 2026.6 The differences are in how, not whether.

Capabilitymem0Graphiti / ZepLettaAegis Memory
Primary focusAssistant personalizationGraph-based episodic memoryStateful agentsSecure context engineering
Open sourceYesYesYesYes
Self-host postureAvailableAvailableAvailableSelf-host-first
Content security pipeline———4-stage (validation, PII, injection, LLM)
Memory integrity———HMAC-SHA256
Trust hierarchy———4-tier OWASP model
Multi-agent ACL/scopes———Yes
Cross-agent query———Yes
Handoff baton———Yes
ACE loop———Yes
Typed memory model———Yes
Temporal decay—Partial—Yes
Hybrid retrieval (dense + sparse + RRF)Semantic + BM25 + entitySemantic + keyword + graphYes (RRF)Yes (pgvector + tsvector + RRF)
Contradiction detectionMem0g (graph variant, LLM)LLM + temporal invalidation—Typed contradicts edge, cheap + optional LLM, explicit resolution workflow
Semantic consolidationLLM-merge + DELETE losersTemporal supersession—LLM/heuristic merge + audit-preserving (is_deprecated=True + consolidated_into)
Unified context hub (prompts + memory + skills + subagents)———Yes

When to Pick Aegis

Pick Aegis Memory when most of these are true:

  • You need content security — injection detection, integrity verification, sensitive data protection.
  • You need multiple agents to share memory safely with explicit ACL/scopes.
  • You need handoffs where one agent passes a reliable state bundle to another.
  • You want ACE patterns (vote/reflection/playbook) to continuously improve memory quality.
  • You want hybrid retrieval that catches exact-token cases (entity names, error codes, file paths) without giving up semantic similarity.
  • You need contradiction tracking that's reviewable, not just auto-deleted — typed edges with explicit kept_source / kept_target / both_valid / both_invalid resolutions, plus a /metrics endpoint for measuring epistemic conflict over time.
  • You need consolidation with an audit trail — losing memories stay queryable (is_deprecated=True, metadata.consolidated_into) rather than being deleted.
  • You prefer a self-host posture with operational control over storage and deployment.
  • You need temporal decay so stale memories don't pollute retrieval over time.

Performance

Benchmarked on 8 vCPU / 7.6 GB RAM (Intel 13th Gen), 1000 memories, Docker Compose (PostgreSQL 16 + pgvector), concurrency=10. Queries include OpenAI embedding latency. Reproduce with cd benchmarks && bash run_benchmark.sh.

Operationp50p95p99Throughput
Sequential add72ms89ms97ms14.1 ops/s
Batch add (5x20)216ms292ms292ms4.6 ops/s
Concurrent add (c=10)100ms193ms511ms85.1 ops/s
Sequential query282ms411ms1502ms3.8 ops/s
Concurrent query (c=10)413ms1832ms1897ms18.6 ops/s
Cross-agent query304ms380ms380ms3.3 ops/s
Vote64ms176ms176ms14.1 ops/s
Deduplication75ms112ms112ms13.6 ops/s

Query tail latency (p95/p99) is dominated by the external OpenAI embedding call, not Aegis or PostgreSQL. Write and vote operations that skip embedding are consistently under 100ms at p50.

Security benchmark

Does the 4-stage content security pipeline actually catch prompt injection? We measured it as a detector against five baselines (DeBERTa, LLM Guard, an LLM judge, and more) on labelled injection + benign corpora — with full confusion-matrix metrics, a per-stage ablation, and an honest error analysis. The false-positive rate is reported next to recall everywhere — a blocker that flags everything is useless.

Aegis configurationRecallFPRMedian latency
Stages 1–3 (deterministic, no API call)0.140.0046 µs
Stages 1–4 (+ LLM classifier)0.670.001.2 s

deepset/prompt-injections, direct injection (N=662). The free deterministic core adds zero false positives here and across 1,500 benign memory snippets (1 FP); the optional LLM stage trades ~1s of latency for a 4.6× recall gain. Stage 2 (PII) contributes ~0 to injection recall by design — it's a different threat category.

→ Full results, ablation, baselines, latency, and limitations: docs/security/benchmark.md · reproduce with python benchmarks/injection/run_benchmark.py.

Deployment

Docker Compose

docker compose up -d

Kubernetes

kubectl apply -f k8s/

Configuration

VariableDefaultDescription
DATABASE_URLpostgresql+asyncpg://...PostgreSQL connection
OPENAI_API_KEY—For embeddings
AEGIS_API_KEYdev-keyAPI authentication
CONTENT_POLICY_INJECTIONflagreject / redact / flag / allow
CONTENT_POLICY_SECRETSrejectreject / redact / flag / allow
ENABLE_LLM_INJECTION_CLASSIFIERfalseEnable Stage 4 LLM classifier
INJECTION_CLASSIFIER_MODELgpt-4o-miniModel for injection classification

Full Configuration

Documentation

docs.aegismemory.com — Full documentation

Contributing

We welcome contributions! See CONTRIBUTING.md for guidelines.

# Run tests
pytest tests/ -v

# Run linting
ruff check server/

License

Apache 2.0 — Use it however you want. See LICENSE.

Links


Built by engineers who read the OWASP reports and acted on them.

Footnotes

  1. EchoLeak: Zero-click exfiltration from M365 Copilot. arxiv.org/html/2509.10540v1 ↩

  2. Multi-agent exfiltration study (COLM 2025). openreview.net/pdf?id=DAozI4etUp ↩

  3. CVE-2025-32711 zero-click AI vulnerability analysis. socprime.com/blog/cve-2025-32711-zero-click-ai-vulnerability/ ↩

  4. OWASP Top 10 for Agentic Applications (2026). genai.owasp.org ↩

  5. Security comparison based on public documentation and open-source repositories as of February 2026. Sources: mem0 docs | Zep docs | Letta repo | Aegis docs ↩ ↩2

  6. Memory-depth feature claims verified May 2026 against vendor blogs and docs. Sources: mem0 State of AI Agent Memory 2026 (hybrid: semantic + BM25 + entity), mem0 architecture (consolidation, Mem0g contradiction resolver), Graphiti / Zep paper and Neo4j writeup (LLM-based edge contradiction with temporal invalidation), Letta archival search docs (RRF hybrid). Aegis design choices documented in server/contradiction_detector.py and server/consolidation.py. ↩

Ver o original no GitHub

Bom para

Relacionados