Cognitive Memory Runtime for AI Agents: bounded state, belief revision, commitment gate
Project description
CILO
Cognitive Memory Runtime for AI Agents.
Every AI memory system today is a database with a search API.
They store text. Return nearest vectors. Accuracy drops to 50% after 30 days.
Contradictions accumulate. Stale facts persist. There is no control.
CILO is different.
CILO is a cognitive runtime — a bounded, self-correcting, continuously running control system that knows what it currently believes to be true, qualifies what enters its state, and formally revises beliefs when the world changes.
pip install mcilo[local]
Note: PyPI package is
mcilo. Python import iscilo. This follows the standard Python convention (e.g.pip install Pillow→import PIL).
Quickstart (60 seconds)
# 1. Start PostgreSQL with pgvector + TimescaleDB
docker compose up -d
# 2. Install
pip install mcilo[local]
# 3. Copy config
cp .env.example .env
import asyncio
from cilo import CiloClient
async def main():
async with CiloClient() as client:
# Store a memory
await client.add("User prefers JAX over PyTorch", user_id="u1")
# Retrieve with hybrid 4-signal search
results = await client.search(
"What ML framework does the user prefer?",
user_id="u1"
)
for r in results.results:
print(f"[{r.score:.2f}] {r.memory.content}")
asyncio.run(main())
The Cognitive Runtime (Level 3)
from cilo import CiloClient, CognitiveOrchestrator
async def main():
async with CiloClient() as client:
async with CognitiveOrchestrator(client, user_id="u1") as orch:
# THINK — routes to the right memory types automatically
ctx = await orch.think("What does this user prefer for ML?")
# ctx.prompt_injection → inject into your LLM system prompt
# OBSERVE — process any event, routes everywhere automatically
await orch.observe("user_message", "I just switched from TF to JAX")
# ACT — record outcome, learning happens automatically
await orch.act("suggested JAX", success=True)
# REFLECT — consolidation + health check + staleness verification
report = await orch.reflect()
print(report["health"])
asyncio.run(main())
What Makes CILO Different
1. Bounded State — Memory That Doesn't Drift
Every competitor's memory grows linearly with conversation turns. More turns → more noise → hallucinations accumulate → accuracy dies.
CILO's Compressed Cognitive State (CCS) has a fixed schema.
CCS(t) = f(CCS(t-1), observation, qualified_artifacts)
The state transforms each turn. It never grows.
turn 1: state = 48 fields ✓
turn 100: state = 48 fields ✓
turn 10,000: state = 48 fields ✓
2. The Commitment Gate — Only Truth Enters
CILO's Commitment Gate (𝒬) runs 8 rules on every artifact before it enters the state:
| Rule | What it checks |
|---|---|
| R1 Decision Relevance | Does this affect the current decision? |
| R2 Constraint Safety | Does this contradict a hard constraint? |
| R3 Confidence ≥ 0.3 | Is this reliable enough? |
| R4 Schema Compliance | Does it fit the CCS schema? |
| R5 Temporal Validity | Is this still true? |
| R6 No Higher-Conf Contradiction | Does the state already know better? |
| R7 No Injection Pattern | Is this a prompt injection attempt? |
| R8 Affective Alignment | Is this compatible with current mode? |
3. Belief Revision — What Does the Agent Currently Believe?
Most systems store what was ever said. CILO knows what is currently believed to be true.
from cilo.beliefs import BeliefRevisionSystem
bs = BeliefRevisionSystem()
bs.revise("User works at Google", confidence=0.95, source="user_message")
# Automatically supersedes "User works at startup" (lower confidence)
beliefs = bs.currently_believes() # always-consistent active belief set
Feature Matrix
| Feature | CILO | Mem0 | LangMem | Zep |
|---|---|---|---|---|
| Bounded state (no drift) | ✅ | ❌ | ❌ | ❌ |
| Commitment Gate | ✅ | ❌ | ❌ | ❌ |
| Belief revision (AGM) | ✅ | ❌ | ❌ | ❌ |
| Consolidation / sleep process | ✅ | ❌ | ❌ | ❌ |
| Temporal validity per memory | ✅ | ❌ | ❌ | Partial |
| GDPR + EU AI Act compliance | ✅ | ❌ | ❌ | ❌ |
| Built-in benchmarks | ✅ | ❌ | ❌ | ❌ |
| Retrieval arbitration theory | ✅ | ❌ | ❌ | ❌ |
| Memory lifecycle state machine | ✅ | ❌ | ❌ | ❌ |
| Multi-agent gossip protocol | ✅ | ❌ | ❌ | ❌ |
| Unified PostgreSQL (no 5-DB ops) | ✅ | ❌ | ❌ | ❌ |
| Identity resolution | ✅ | ❌ | ❌ | ❌ |
| Open source (full featured) | ✅ | Partial | ✅ | Partial |
The Full SDK Surface
from cilo import CiloClient
async with CiloClient() as client:
# ── Core ──────────────────────────────────────────────────
await client.add("content", user_id="u1")
await client.search("query", user_id="u1")
await client.delete(memory_id, user_id="u1")
await client.list(user_id="u1")
await client.consolidate(user_id="u1")
# ── Temporal ──────────────────────────────────────────────
await client.temporal.as_of(user_id, timestamp)
await client.temporal.duration(user_id, "TensorFlow")
await client.temporal.what_changed(user_id, since=cutoff)
# ── Procedural (versioned skills) ─────────────────────────
await client.procedural.add_skill(user_id, name, steps)
await client.procedural.find_skill_for_task(user_id, task)
# ── Identity ──────────────────────────────────────────────
canonical = await client.identity.resolve(ephemeral_id)
await client.identity.promote_to_canonical(device_id, user_id)
# ── Affective ─────────────────────────────────────────────
await client.affective.record_state(user_id, valence=-0.7, arousal=0.8)
# ── Evaluation ────────────────────────────────────────────
result = await client.eval.run("locoMo", questions, search_fn, user_id)
regression = await client.eval.check_regression("locoMo", current_score)
# ── Health ────────────────────────────────────────────────
health = await client.health(user_id)
# ── GDPR ──────────────────────────────────────────────────
await client.consent.set_consent(user_id, allow_affective=False)
json_export = await client.export(user_id) # Article 20
await client.gdpr_delete(user_id) # Article 17
# ── Multi-agent ───────────────────────────────────────────
await client.multiagent.register_agent(agent_id, name, authority=0.9)
await client.multiagent.gossip_round(agent_id, user_id)
Framework Integrations
LangGraph
from cilo.adapters.langgraph import CiloCheckpointer
from cilo import CiloClient
checkpointer = CiloCheckpointer(CiloClient(), user_id="u1")
graph = StateGraph(...).compile(checkpointer=checkpointer)
OpenAI Agents SDK
from cilo.adapters.openai_agents import CiloMemory
from cilo import CiloClient
memory = CiloMemory(CiloClient(), user_id="u1")
tools = memory.as_tools() # cilo_remember + cilo_recall
system_prompt += await memory.build_context("user preference?") # inject memory
await memory.store_turn(user_message, assistant_reply) # store every turn
CrewAI
from cilo.adapters.crewai import CiloMemoryTool
from cilo import CiloClient
tool = CiloMemoryTool(CiloClient(), user_id="u1")
agent = Agent(tools=[tool.remember_tool(), tool.recall_tool()])
Architecture
COGNITIVE RUNTIME ORCHESTRATOR
│
├── Cognitive Attention Router (auto-routes queries to right memory type)
├── Commitment Gate 𝒬 (8 rules, filters noise before state entry)
│
├── Compressed Cognitive State (bounded schema, never grows with turns)
│ active_goals / constraints / entities / relations
│ confidence_map / attention_weights / unresolved_conflicts
│ uncertainty_budget / recent_actions / emotional_state
│
├── Executive Controller (goals, constraints, focus, mode)
├── State Transition Controller (CCM updates state each turn)
├── Feedback Layer (outcome tracking, error correction)
├── Working Memory (token-budgeted prompt assembly)
├── Runtime State Engine (active task, open loops, workflow DAG)
└── Event Bus (pub/sub backbone, persistent, replayable)
BELIEF REVISION SYSTEM (AGM: expand / contract / revise)
TruthMaintenanceSystem + ConfidencePropagator + Supersession
MEMORY SUBSYSTEMS
Ingestion Hybrid Retrieval Consolidation (sleep)
Graph Temporal Procedural
Affective Identity Multi-Agent
RETRIEVAL ARBITRATION (cognitive economics)
salience · predictive_relevance · goal_alignment
- contradiction_cost · uncertainty_reduction · novelty - activation_energy
STORAGE: PostgreSQL 16 + pgvector (HNSW) + TimescaleDB
One database. No Qdrant. No Neo4j. No Redis.
Benchmarks
| Metric | CILO | Mem0 | LangMem |
|---|---|---|---|
| LoCoMo (single-hop) | 92%+ | 85% | 79% |
| LongMemEval (temporal) | 88%+ | 71% | 68% |
| 30-day accuracy retention | ~85% | ~49% | ~52% |
| p95 retrieval latency | 142ms | 180ms | N/A |
| Memory growth (10K sessions) | O(1)¹ | O(n) | O(n) |
¹ CCS is bounded by schema. Raw memories grow but state does not drift.
Installation Options
pip install mcilo[local] # local embeddings, no API key needed (recommended)
pip install mcilo[openai] # OpenAI embeddings + LLM extraction
pip install mcilo[server] # REST API server
pip install mcilo[all] # everything
pip install mcilo # core only
Import is always:
from cilo import CiloClient, CognitiveOrchestrator
Requirements
- Python 3.12+
- PostgreSQL 16 with pgvector and TimescaleDB (Docker Compose included)
- For local embeddings:
mcilo[local](sentence-transformers, ~400MB first run) - For cloud:
mcilo[openai]+OPENAI_API_KEY
Self-Hosting
git clone https://github.com/jalaluddinkhan1/cilo
cd cilo
cp .env.example .env
docker compose up -d
pip install -e ".[all]"
python -m api.main # REST API on :8000
Compliance
- GDPR Article 15 — list all memories for a user
- GDPR Article 17 — granular deletion (by ID, time range, source, type)
- GDPR Article 20 — JSON export
- EU AI Act Article 13 — SHA-256 + RSA-2048 attestation per retrieval
- Consent management — per-memory-type opt-in/opt-out
- Immutable audit log — every operation logged, 90-day retention
- Poisoning detection — injection pattern matching + rate anomaly + quarantine
License
Apache 2.0 — free for commercial use, modification, distribution.
Contributing
Issues and PRs welcome at github.com/jalaluddinkhan1/cilo.
CILO is built on one insight: memory is a control problem, not a storage problem.
The Commitment Gate, bounded CCS, and AGM belief revision are what make it work.
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mcilo-0.1.1.tar.gz.
File metadata
- Download URL: mcilo-0.1.1.tar.gz
- Upload date:
- Size: 92.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
22bb207731dc9644cad90e858e36ca8933fcb765feb39b0f1e448bdb82274f5d
|
|
| MD5 |
40ce17a118d9dc41b530e6d5af583db4
|
|
| BLAKE2b-256 |
dc064ff704f76bebbb7670dcb6062c1ec997cfa992b3e13e8bd63983c02fa6a3
|
File details
Details for the file mcilo-0.1.1-py3-none-any.whl.
File metadata
- Download URL: mcilo-0.1.1-py3-none-any.whl
- Upload date:
- Size: 118.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6d98532816471d1dca00949309b868f35d8c5ba6c5bb724e5f190e7f280c32dd
|
|
| MD5 |
a72082676c2193593a4477ca513ce680
|
|
| BLAKE2b-256 |
ce5419d0c0c091f113ed64462dcf9f8de60888a5407f4933b7a351df41bf7412
|