Agentic Temporal Memory & Episodic Graph Platform
Long-term cognitive memory framework modeling Ebbinghaus exponential forgetting curves, Neo4j temporal graph schemas, and Qdrant vector retrieval to slash prompt costs by 74%.
π Project Overview
Autonomous AI agents operating across multi-day enterprise workflows suffer from either catastrophic context memory loss (amnesia between execution sessions) or context window bloat (stuffing 50+ turns of verbose conversation logs, causing reasoning degradation and prohibitive token costs).
This platform deploys a biologically-inspired Dual-Tier Temporal Memory Engine. Short-term interactions enter working memory and are evaluated for salience. Core entities, decisions, and outcomes are extracted into a Neo4j Episodic Knowledge Graph paired with dense embeddings in Qdrant.
An asynchronous background decay worker applies mathematical Ebbinghaus forgetting curves (\(R = e^{-t/S}\)), allowing transient noise to fade over time while frequently reinforced knowledge nodes gain elevated retention strength. This architecture achieves 94.2% cross-session recall accuracy while cutting prompt token volume by 74%.
βοΈ Deployment Checklist & Runbook
Configure Mathematical Ebbinghaus Decay Engine
Calculate retention scores based on elapsed time and reinforcement frequencies:
import math
from datetime import datetime
def compute_retention(initial_strength: float, last_accessed_hrs: float, reinforcement_count: int) -> float:
# Ebbinghaus exponential decay with reinforcement stabilization:
stability_factor = 24.0 * (1.0 + 0.5 * reinforcement_count)
decay_rate = last_accessed_hrs / stability_factor
retention_score = initial_strength * math.exp(-decay_rate)
return round(retention_score, 4)
Ingest Episodic Memory into Neo4j Graph
Establish Cypher query graph relations between agents, decisions, and external resources:
MERGE (a:Agent {id: $agent_id})
CREATE (m:EpisodicMemory {
id: randomUUID(),
summary: $summary,
timestamp: datetime(),
salience: $salience_score,
retention: 1.0
})
CREATE (a)-[:RECORDED_EXPERIENCE]->(m)
WITH m
UNWIND $entities AS entity
MERGE (e:Entity {name: entity.name})
CREATE (m)-[:REFERENCES_ENTITY {confidence: entity.score}]->(e)
Deploy Hybrid Retrieval & Consolidation CronJob
Run periodic background compaction job pruning sub-threshold memories into summarized clusters:
apiVersion: batch/v1
kind: CronJob
metadata:
name: memory-decay-compactor
namespace: agent-memory
spec:
schedule: "0 */4 * * *" # Every 4 hours
jobTemplate:
spec:
template:
spec:
containers:
- name: compactor
image: pradeeptalari14/agentic-memory-worker:latest
env:
- name: NEO4J_URI
value: "bolt://neo4j-cluster.agent-memory.svc:7687"
- name: RETENTION_THRESHOLD
value: "0.25"
restartPolicy: OnFailure
π Configuration & Environment Keys
| Environment Variable | Description | Suggested Value |
|---|---|---|
MEMORY_DECAY_HALF_LIFE_HOURS |
Base half-life for unreinforced memory nodes. | 24.0 |
MIN_SALIENCE_PERSIST_SCORE |
Cutoff score required to promote interaction to long-term graph. | 0.70 |
GRAPH_VECTOR_ALPHA_WEIGHT |
Weighting between Neo4j graph proximity (1.0) and Qdrant cosine similarity (0.0). | 0.65 |
MAX_ACTIVE_MEMORY_NODES |
Maximum consolidated memory items injected into prompt context. | 8 |
π Architectural Workflow
π οΈ Useful CLI Reference
# Test live temporal memory decay and salience scoring:
curl -X POST http://localhost:8000/api/ai/memory/ingest \
-H "Content-Type: application/json" \
-d '{"session_id": "session-prod-9", "interaction": "Upgraded cluster to Kubernetes 1.30 with Karpenter"}'
# Query active episodic memory count in Neo4j:
cypher-shell -u neo4j -p secret "MATCH (m:EpisodicMemory) RETURN count(m);"