Track A
Structured events
OpenTelemetry spans, typed JSON agent logs → rule-based extraction. confidence=EXTRACTED, cost=$0.00.
Not just what happened — why.
Engram captures cause-and-effect chains across your agent's decisions. Agents that remember why they failed don't repeat the same mistakes.
❌ Without Engram — debugging a payment failure
read payment_service.py 800 tokens
read auth_middleware.py 600 tokens
read logs/2024-03-01.log 1,200 tokens
analyze all above 3,500 tokens
~6,100 tokens · 5 turns
✅ With Engram (warm graph)
hook injects causal chain 200 tokens
"auth_middleware.py:47 — token expiry check
uses < not <= (conf: 0.94)"
edit auth_middleware.py:47
~200 tokens · 2 turns · ~30x reduction
Three-track pipeline. LLM only called once per unique text. Everything else is local graph math.
Track A
OpenTelemetry spans, typed JSON agent logs → rule-based extraction. confidence=EXTRACTED, cost=$0.00.
Track B
SHA256 cache — same log text seen before → serve cached triples instantly. No API call.
Track C
Claude extracts causal triples once from novel free-text logs → cached forever. ~$0.0003/1K tokens.
// LLM cost profile
Structured JSON event $0.00 rule-based
Repeated free-text log $0.00 cache hit
New free-text (first time) ~$0.0003 per 1K tokens
Why-query (DFS traversal) $0.00 graph math
Typical 100-event session: ~$0.002 total. Subsequent runs: $0.00.
Engram's hook is bidirectional — unlike read-only tools. Agents read causal history before acting AND write new evidence back after. Every session makes the next one cheaper.
Agent starts task
PreToolUse hook fires
Injects top causal chain (≤500 tokens): "auth_middleware:47 failed 3x, root cause: token expiry off-by-one (conf 0.94)"
Agent acts directly — no exploration needed
Skips reading 5 files. Edits the right line immediately.
PostToolUse hook fires
Ingests outcome as structured event → Engram reinforces or updates the causal triple
Next session starts with updated knowledge
Graph learns. Token cost drops. Mistakes don't repeat.
Install once. Hook fires automatically on every tool call.
# install
pip install engram-causal
# set your Anthropic key (only for free-text extraction)
export ANTHROPIC_API_KEY=sk-ant-...
# install hooks + start
engram install && engram serve
📋 Traditional Logs
tool_call_failed: truestatus: timeouterror: connection reset
You know what. Not why.
⚡ Engram Causality
weather_api timed out (0.92)→ server_overload (0.87)→ high_traffic_spike (0.81)→ deployment at 14:32 UTC
Root cause. Confidence scored. Audit trail included.
Vector memory (Mem0, Zep, etc.)
Retrieves semantically similar content. Great for recall. Doesn't tell you why something happened.
Engram causal memory
Retrieves causally upstream content — the reasons, not just similar facts. No embeddings. Graph traversal is cheaper, faster, and fully explainable.
Open-source. Works with any AI agent. No framework required.