engram-causal
Causal reasoning layer for AI systems. Answers "why" instead of just "what".
Extract cause-effect relationships from your AI agent sessions, store them in a causal graph, and inject root causes into debugging workflows without burning tokens on re-investigation.
The Problem in 30 Seconds
Your AI agent debugs a payment failure (6+ files read, 5+ token-expensive turns). Next week: same failure, same re-investigation, same tokens wasted.
Why? Because memory systems don't store causality — they store facts.
Engram solves this:
# Structured event ingestion (zero LLM cost)
engram ingest ./logs/session.json
# Query: "Why did payment fail?"
engram why "payment_failed"
# Returns: "Token validation bug in auth_middleware.py:47 (conf: 0.94)"
# Tokens used: 0 (pure graph traversal)
Next time your agent sees that setup, it knows the root cause instantly.
Key Features
✅ Three-Track Extraction — Rules (free) → SHA256 cache (free) → Claude once, then cached (~$0.0003)
✅ Persistent Causal Graph — Store relationships, survive sessions
✅ Why-Query Engine — Backward DFS traversal for root causes (zero LLM)
✅ EU AI Act Ready — Full audit trail + confidence scores
✅ Structured Events — Parse OpenTelemetry, typed JSON logs with deterministic rules
✅ Low Cost — Most queries run on cached triples or graph math, not LLM
Install
pip install engram-causal
# Set your Anthropic API key (optional, only for free-text extraction)
export ANTHROPIC_API_KEY=sk-ant-...
Quick Start
Extract causal triples from text
engram extract "The database timed out because the connection pool was exhausted"
Output:
1 triple(s) extracted:
'connection pool exhausted' → 'database timed out' (conf=0.89, mechanism=external-event)
Ingest structured events (zero LLM)
engram ingest ./logs/events.json
Query root causes
engram why "database_timeout"
Start the API server
engram serve
# API: http://localhost:8000
# Graph viewer: http://localhost:8000/graph
Use Cases
- AI Agent Debugging — Capture why decisions failed, prevent repeated mistakes
- Explainable Systems — EU AI Act Article 13 compliance, auditable reasoning chains
- Root Cause Analysis — Trace failures back to origin across sessions
- Incident Response — Structured post-mortems with causal chains
What's Different
| Vector DB | Chat Memory | Engram | |
|---|---|---|---|
| Stores | Embeddings | Facts & history | Cause-effect chains |
| Query style | "Find similar" | "What happened?" | "Why did this happen?" |
| Explainability | ❌ Black box | ❌ Fact-based only | ✅ Causal + confidence |
| LLM cost | High (reprocess) | Medium (caching) | Ultra-low (graph math) |
Documentation
Full docs: https://engram.viberank.co.in
GitHub: https://github.com/karankartikeya/engram
Report issues: https://github.com/karankartikeya/engram/issues
License
MIT
Metadata
Release files for engram-causal 0.1.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| engram_causal-0.1.5.tar.gz | 82.6 kB | Without provenance | Details for engram_causal-0.1.5.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| engram_causal-0.1.5-py3-none-any.whl | Python 3 | none | any | Details for engram_causal-0.1.5-py3-none-any.whl |
Total release size: 160.3 kB
Release files / engram_causal-0.1.5.tar.gz
| Download URL | engram_causal-0.1.5.tar.gz |
|---|---|
| Size | 82.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
bfa2abd3096b0804738a5a81a14cb7e3d0c3572f670bebd0f7a205632eebc15e
|
|
BLAKE2b-256 checksum How to use checksums |
984be707d8f3e87460d8564b0a9223eca4fac703666f9210bc8e9828a7456d4a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Release files / engram_causal-0.1.5-py3-none-any.whl
| Download URL | engram_causal-0.1.5-py3-none-any.whl |
|---|---|
| Size | 77.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
14af20d57e7ced0ee066f89c0eebd94470ba157d4a289814dc4e47eef47a817e
|
|
BLAKE2b-256 checksum How to use checksums |
bd3fb74bc2f2874502b765b65ee705bb9dffb0210b5d072d5735f26dfd68556c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Security for engram-causal 0.1.5
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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.