Skip to main content

Causal memory for AI agents

Project description

CausalOS

The causal memory layer for AI agents.

In 2025, a Replit agent deleted an entire production database during a code freeze — then fabricated status reports claiming the data was gone forever.

The agent had no memory of what its past actions had caused.

CausalOS fixes this.

pip install causal-os

🧱 Quick Start

Lead with the disaster. CausalOS captures the "why" behind failures so they don't happen twice.

from causal_memory import CausalMemory
from causal_memory.models import ActionType, Severity
from causal_memory.guard import CausalGuard, CausalBlockException

memory = CausalMemory()

# Session 1: Agent causes disaster. CausalOS records it.
memory.record(
    action_type=ActionType.DB_DELETE,
    action_detail="DELETE FROM users WHERE status='test'",
    intent="Clean up test data",
    outcome="CRITICAL: Deleted 47,000 production users. status flag misconfigured.",
    severity=Severity.CRITICAL
)

# Session 2: New agent, same mistake incoming. CausalGuard blocks it.
guard = CausalGuard(memory, mode="block")

try:
    with guard.check(ActionType.DB_DELETE, "DELETE FROM users WHERE env='test'"):
        # This code never runs
        db.execute("DELETE FROM users...")  
except CausalBlockException as e:
    print(f"Blocked. Similar action caused CRITICAL failure in {e.incidents[0].session_id}")

🛡️ Why not Mem0 or Zep?

Mem0 / Zep CausalOS
Stores Facts, entities, chat history Action → Outcome chains
Query "What does the user prefer?" "Has this action caused damage before?"
Risk scoring No Yes (deterministic, no LLM)
Guard / block No Yes
Use together? Yes Yes — CausalOS wraps them

📊 CLI Audit

Audit your agent's institutional memory with the built-in CLI.

causal-os view --db causal.db

Output:

🌲 Causal Graph (causal.db)
📁 Session: 8f2a1b9c
   DB_DELETE: DELETE FROM users WHERE status='test'
   → CRITICAL: Deleted 47,000 production users.
   ↳ Downstream: Site outage (CRITICAL)
📁 Session: a7b3e21d
   API_CALL: POST /v1/billing/reset
   → Success: Billing cycle reset.

🚀 Roadmap

  • CrewAI integration
  • Shared causal pool (opt-in, anonymized) — agents learn from each other's failures
  • causal-os serve — local REST API for any language
  • MCP server for Claude Code and Cursor

📜 License

MIT

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

causal_os-0.1.0.tar.gz (14.9 kB view details)

Uploaded Source

Built Distribution

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

causal_os-0.1.0-py3-none-any.whl (15.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: causal_os-0.1.0.tar.gz
  • Upload date:
  • Size: 14.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for causal_os-0.1.0.tar.gz
Algorithm Hash digest
SHA256 f62835bb986395143b7cc685563ae977febc4a401274522eebc85190f2efe0c8
MD5 46139bb79bc0835129b1e42b887dbeaa
BLAKE2b-256 cab54fb704b6270fcae2c58659756054c5211504bdc3623b779d985776004d50

See more details on using hashes here.

File details

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

File metadata

  • Download URL: causal_os-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 15.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for causal_os-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 05d2e69f914e361f9946584ec6c4929c7029cf1652f28d057865aba84dc6078a
MD5 ead5a7b79d45036062987616748656a0
BLAKE2b-256 600397f092dc078de740056751a99e8b8f6ece4441cc1ab512db2ea7e3f1f9c3

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