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.1.tar.gz (14.8 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.1-py3-none-any.whl (15.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: causal_os-0.1.1.tar.gz
  • Upload date:
  • Size: 14.8 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.1.tar.gz
Algorithm Hash digest
SHA256 190beb4568fd87fdb034deb8fbd3ade6c2ddfca1d44888fcfce1f579203b0eab
MD5 6ebfcc59b71e92fa223b55d15d5021c6
BLAKE2b-256 aa579872e4834920432aa74e47960528e1f18d17ce1e0a6afcf5ec3caf738749

See more details on using hashes here.

File details

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

File metadata

  • Download URL: causal_os-0.1.1-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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 d4ed3267e42adfd3eb50361d5bc6d2cec042631fe9fc0dc160a9268b76e1b2f7
MD5 662a055426e19c11fdb55a3cd9d91a37
BLAKE2b-256 5443ba8fbf3af46c9f3ec1c8ef18ba03ad760d3e1ee093d47f05c7a177a2d3e6

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