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 cilo[local]

Quickstart (60 seconds)

# 1. Start PostgreSQL with pgvector + TimescaleDB
docker compose up -d

# 2. Install
pip install cilo[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)

The full power: a cognitive loop that routes, qualifies, commits, and learns.

from cilo import CiloClient, CognitiveOrchestrator

async def main():
    async with CiloClient() as client:
        async with CognitiveOrchestrator(client, user_id="u1") as orch:

            # THINK — automatically routes to the right memory types
            # No need to choose between search(), temporal.as_of(),
            # procedural.find_skill() etc. The router decides.
            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")
            # Automatically: ingests, extracts facts, detects contradiction
            # with old TensorFlow memory, reduces TF confidence, logs to audit

            # ACT — record an outcome, learning happens automatically
            await orch.act("suggested JAX", success=True)
            # Automatically: updates procedural skill confidence,
            # applies feedback correction to contributing memories

            # REFLECT — trigger self-improvement
            report = await orch.reflect()
            print(report["health"])

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

Retrieved memories are noisy. Stale. Sometimes injected.
Feeding everything to the LLM causes drift.

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.

# AGM-based belief revision
belief_system.revise(
    "User works at Google",
    confidence=0.95,
    source="user_message"
)
# Automatically supersedes "User works at startup" (lower confidence)
# Preserves audit trail. Truth Maintenance System updates dependents.

# Always-consistent active belief set
beliefs = belief_system.currently_believes()

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)
    valence, arousal = await client.affective.get_current_state(user_id)

    # ── 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)
    # staleness_rate, contradiction_rate, coverage_gaps, avg_confidence

    # ── 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)
    await client.multiagent.vote_stale(memory_id, agent_id)

Framework Integrations

LangGraph

from cilo.adapters.langgraph import CiloCheckpointer
from cilo import CiloClient

client = CiloClient()
checkpointer = CiloCheckpointer(client, user_id="u1")

# Drop-in replacement for MemorySaver
graph = StateGraph(...).compile(checkpointer=checkpointer)

# Memory-augmented context injection
state = await checkpointer.inject_memory_context(query, state)

OpenAI Agents SDK

from cilo.adapters.openai_agents import CiloMemory
from cilo import CiloClient

memory = CiloMemory(CiloClient(), user_id="u1")

# Tool definitions for OpenAI Agents
tools = memory.as_tools()  # cilo_remember + cilo_recall

# Context injection
system_prompt += await memory.build_context("What does the user prefer?")

# Store every turn
await memory.store_turn(user_message, assistant_reply)

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  (routes to right memory type automatically)
    ├── Commitment Gate 𝒬           (8 rules, filters noise before state entry)
    │
    ├── Compressed Cognitive State  (bounded, formal, never grows)
    │     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

# Core + local embeddings (no API key needed)
pip install cilo[local]

# Core + OpenAI embeddings + LLM extraction
pip install cilo[openai]

# Core + REST API server
pip install cilo[server]

# Everything
pip install cilo[all]

# Minimal core only
pip install cilo

Requirements

  • Python 3.12+
  • PostgreSQL 16 with pgvector and TimescaleDB (Docker Compose included)
  • For local embeddings: cilo[local] (sentence-transformers, ~400MB first run)
  • For cloud: cilo[openai] + OPENAI_API_KEY

Self-Hosting

git clone https://github.com/cilo-ai/cilo
cd cilo
cp .env.example .env        # set OPENAI_API_KEY if using cloud embeddings
docker compose up -d        # PostgreSQL + pgvector + TimescaleDB
pip install -e ".[all]"
python -m api.main          # REST API on :8000

Compliance

CILO ships with full compliance tooling:

  • 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 on every retrieval
  • Consent management — per-memory-type opt-in/opt-out, retroactive
  • Immutable audit log — every operation logged, 90-day retention
  • Poisoning detection — pattern matching + rate anomaly + quarantine

License

Apache 2.0 — free for commercial use, modification, distribution.


Contributing

Issues and PRs welcome at github.com/cilo-ai/cilo.

CILO is built on the insight that 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.0.tar.gz (92.3 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.0-py3-none-any.whl (118.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: mcilo-0.1.0.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

Hashes for mcilo-0.1.0.tar.gz
Algorithm Hash digest
SHA256 b57c509b48feafe47aabc8ae6d2809123a3ab55f984e2901fbd1ccc3fc9d5912
MD5 94959d06c9cfd4e3cbcc5c766f9c4978
BLAKE2b-256 98ad91df70d518716403eaf45392c524c9a222f43002c471bba2d46c69f796d6

See more details on using hashes here.

File details

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

File metadata

  • Download URL: mcilo-0.1.0-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

Hashes for mcilo-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 671a9014f557447f1b1f489a00c20453ce4776418fb52737ed53808a39c05529
MD5 1a8c4f070175485249928609a18be4d2
BLAKE2b-256 b15b380b99893d101d4e49ce113f9f1af02f9f1adff12e8207be11bc0fc08e7d

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