Skip to main content

causal-memory

An agent memory system with a causal core — facts, temporal state, and decision → outcome causal edges on one local SQLite store. Agents recall what happened, when it was true, why it worked — and what would happen if they acted differently.

pip install causal-memory

Requires Python ≥ 3.9. Prebuilt wheels: macOS (Apple Silicon + Intel), Linux x86_64 (manylinux_2_28), Windows x64. No API key needed for the default setup.

30-second quickstart

from causal_memory import CausalMemory

# One local SQLite file is the whole store. Created on first use.
mem = CausalMemory("~/.local/share/causal-memory/causal.db")
# or CausalMemory.in_memory() for a throwaway store

# Write: record a decision → outcome as a typed causal edge
mem.record_decision(
    "used Redis mutex for cache stampede protection",
    "deadlock under load",
    "caused",            # caused | enabled | prevented | no_effect
    "concurrency",       # task tag — how you retrieve this later
)

# Read: BM25 full-text retrieval works out of the box
print(mem.search_causal(query="cache stampede protection"))

# Ask before acting: forward simulation over recorded outcomes
print(mem.intervention_query("skip the test suite before shipping"))

Every method mirrors one of the 14 MCP tools and returns plain text that agent frameworks (LangChain, LlamaIndex, Hermes, …) can feed straight back to the model. See the full method list on GitHub.

Configuration

Everything is optional and configured via environment variables:

Variable What it does Default
CAUSAL_MEMORY_EMBED_API Embedding endpoint (OpenAI-compatible) for semantic retrieval unset → BM25 only
CAUSAL_MEMORY_EMBED_KEY API key for the embedding endpoint unset
CAUSAL_MEMORY_EMBED_MODEL Embedding model name (e.g. embedding-3) unset
CAUSAL_MEMORY_LLM_* LLM endpoint for distill / remember auto-extraction unset → raw storage, no extraction

Without embedding/LLM variables the package degrades gracefully: retrieval is BM25-only and remember stores raw text instead of extracted facts. You can add them later — the store format is the same.

What this package is (and isn't)

  • ✅ The Python library: embed causal memory in your own agent, script, or framework integration.
  • ❌ Not the MCP server binary. If you want Claude Code / Cursor to use causal-memory as an MCP tool server, build the Rust binary instead: cargo build --release from the repo, then point your MCP config at it.

Metadata

Release files for causal-memory 0.9.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for causal-memory 0.9.1
File Size Uploaded
causal_memory-0.9.1.tar.gz 293.5 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for causal-memory 0.9.1
File
causal_memory-0.9.1-cp39-abi3-win_amd64.whl CPython 3.9 abi3 Windows x86-64 Details
causal_memory-0.9.1-cp39-abi3-manylinux_2_28_x86_64.whl CPython 3.9 abi3 Linux glibc 2.28+ x86-64 Details
causal_memory-0.9.1-cp39-abi3-macosx_11_0_arm64.whl CPython 3.9 abi3 macOS 11.0+ ARM64 Details
causal_memory-0.9.1-cp39-abi3-macosx_10_12_x86_64.whl CPython 3.9 abi3 macOS 10.12+ x86-64 Details

Total release size: 14.1 MB

Release files / causal_memory-0.9.1.tar.gz

Download URL causal_memory-0.9.1.tar.gz
Size 293.5 kB
Tags Source
SHA-256 checksum
How to use checksums
c9d0be7e8e323b706f3563601905d2466cabd1c0778856ca2b736295bf9e4ecf
BLAKE2b-256 checksum
How to use checksums
ffbfab7575a8fbd0d1a6d97561488ccdf3aa205ec9d010f471905d2c4a658ada
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 25, 2026.

Transparency log

Release files / causal_memory-0.9.1-cp39-abi3-win_amd64.whl

Download URL causal_memory-0.9.1-cp39-abi3-win_amd64.whl
Size 3.0 MB
Tags CPython 3.9 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
31362d1472cdf4a121578af85ff0d842f7b3c5a219e16d29aa45a82b8fb6fc00
BLAKE2b-256 checksum
How to use checksums
df83aaa11288be0c862f2ec467bbe8b06af129d986e5e76cbaa58e6a4485f31e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 25, 2026.

Transparency log

Release files / causal_memory-0.9.1-cp39-abi3-manylinux_2_28_x86_64.whl

Download URL causal_memory-0.9.1-cp39-abi3-manylinux_2_28_x86_64.whl
Size 5.2 MB
Tags CPython 3.9 Linux glibc 2.28+ x86-64 abi3
SHA-256 checksum
How to use checksums
dcd560e69166f701184872b2282165c650f856c7ee585528f67a01325a851261
BLAKE2b-256 checksum
How to use checksums
41cfe70af88804cd035b750098d992d28fe25ccf9bb23a1222e900fbfd6d221f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 25, 2026.

Transparency log

Release files / causal_memory-0.9.1-cp39-abi3-macosx_11_0_arm64.whl

Download URL causal_memory-0.9.1-cp39-abi3-macosx_11_0_arm64.whl
Size 2.7 MB
Tags CPython 3.9 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
93dfe3c0a15a1ea89f1f8f5a560b37dcd3d47d9aa3956d18b1927c3424b72e2e
BLAKE2b-256 checksum
How to use checksums
f498bc07e2605cce00e287752c50d430ad9b47a26f91229e3d5d32161a275ccb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 25, 2026.

Transparency log

Release files / causal_memory-0.9.1-cp39-abi3-macosx_10_12_x86_64.whl

Download URL causal_memory-0.9.1-cp39-abi3-macosx_10_12_x86_64.whl
Size 2.9 MB
Tags CPython 3.9 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
052c54bc3e563796e7cfd8c8aec8d031e5a994b9e77b47f9c5cff8fb109bbb2b
BLAKE2b-256 checksum
How to use checksums
4aa54ae6d79132b15ec0556123b05ff18d7623aada56ae7aad2af7baeb2c6500
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 25, 2026.

Transparency log

Release history Release notifications | RSS feed

0.10.0

5 release files

0.9.3

5 release files

0.9.2

5 release files

This release

0.9.1 This release

5 release files

0.9.0

5 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page