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.2.tar.gz (16.0 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.2-py3-none-any.whl (16.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: causal_os-0.1.2.tar.gz
  • Upload date:
  • Size: 16.0 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.2.tar.gz
Algorithm Hash digest
SHA256 d4efe58875a2086c312980f5b45ddc18426e1158e0ea51d87cc2860597ef7be3
MD5 81b9bee4a74099d1fec3f3e4e80705bb
BLAKE2b-256 c1729f2b4f6c47947cf4f396389ff4a8b71c46c805fdd35d3094bafbf8bc30e4

See more details on using hashes here.

File details

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

File metadata

  • Download URL: causal_os-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 16.7 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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 39b07bf871367cc991d8858e37f168ce03c3ebb2e68e869fa1b889d71236a55b
MD5 4c6e32903f8e05b163a4c131c090a73b
BLAKE2b-256 050dca9a4228c379c56cb997f8fb0e34c908f21716c5656845ad5efce433a013

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