Skip to main content

Cognitive Memory Runtime for AI Agents: bounded state, belief revision, commitment gate

Project description

CILO

Cognitive Memory Runtime for AI Agents.

PyPI version Python 3.12+ License: Apache 2.0 PostgreSQL


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 is cilo. This follows the standard Python convention (e.g. pip install Pillowimport 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

mcilo-0.1.8.tar.gz (95.0 kB view details)

Uploaded Source

Built Distribution

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

mcilo-0.1.8-py3-none-any.whl (121.2 kB view details)

Uploaded Python 3

File details

Details for the file mcilo-0.1.8.tar.gz.

File metadata

  • Download URL: mcilo-0.1.8.tar.gz
  • Upload date:
  • Size: 95.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for mcilo-0.1.8.tar.gz
Algorithm Hash digest
SHA256 bf8f06b02772d2bf01854816655579afc0b5c9332041afdc4334f6b7565f673c
MD5 1e0bc1ee120e90a69348bda1b3615117
BLAKE2b-256 2af9747f12502ed921dd070077cd2334fdff6668744f44a896f65d70b0749948

See more details on using hashes here.

File details

Details for the file mcilo-0.1.8-py3-none-any.whl.

File metadata

  • Download URL: mcilo-0.1.8-py3-none-any.whl
  • Upload date:
  • Size: 121.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for mcilo-0.1.8-py3-none-any.whl
Algorithm Hash digest
SHA256 1d8f59773a7ba37807e143eecfa684dbcbe348716ba74469e771f473d99a1d9c
MD5 a17a19a63eff5c5673cc8eb970aa3dd0
BLAKE2b-256 134f06d4b36b26f61d16413f8581904eb4ba66d45f4173ab09c1ed8c3343d487

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