OPEN PROTOCOL v2.0

The Hippocampus Protocol

Context Lifecycle Management for AI Agents

202,773 → 5,100 tokens (16.6× compression)
First AI agent to rewrite its own memory — live on production

Don't store content. Store the index.
Retrieve when needed. Forget when not.

By Roman Godz & R2D2

📦
Full Content
202,773 tokens
🧠
Sparse Index
5,100 tokens
🔄
On Demand
pattern completion

Live Results

Real production data from R2D2's first memory compaction

115
Messages
classified and scored
16.6×
Compression
202,773 → 5,100 tokens
108
Sparse Pointers
7 compressed, 0 lost
0
Data Lost
all content retrievable

Decay Configuration

Per-Type Decay Rates

decisionsλ = 0.03
tool_resultsλ = 0.20
user_intentλ = 0.10
ephemeralλ = 0.50

Retention Floors

decisions≥ 0.50
user_intent≥ 0.35
tool_results≥ 0.15
ephemeral≥ 0.05

How It Works

Simple 4-step flow that mimics biological memory formation

🏷️
1

Classify

Each message gets a type

(decision, user_intent, tool_result, ephemeral)

⚖️
2

Score

Importance based on type + modifiers

(recency, size, references)

📉
3

Decay

Exponential decay with per-type rates

retention = importance × e^(-λ × age)

📚
4

Index

Three tiers

full keep (≥0.65), compressed (<0.65), sparse pointer (<0.25)

Memory Decay Formula
retention = importance × e^(-λ × age)
λ = decay rate (per-type) • age = turns since creation

Context Without Lifecycle

AI agents don't have a memory problem — they have a forgetting problem. The brain solved this with active decay. We can too.

📈

Context Bloat

One browser snapshot: 52,000 tokens. One config schema: 285,000 tokens. Tool outputs accumulate until context overflows. 62% are never referenced again.

💸

$2,250/month Wasted

At Claude Opus pricing, carrying 150K tokens of stale tool outputs costs $75/day. Multiply by sessions. Most of those tokens are dead weight.

✂️

Truncation Kills Memory

Summarization loses specificity. Sliding windows drop critical early context. Neither approach knows what's important — they just cut blindly.

Key Features

📍

Sparse Indexing

Context holds pointers, not content. 85× average compression. A 200K token context becomes ~2,400 tokens of index entries.

📉

Active Decay

Every entry loses strength over time (power-law curve). Critical items resist decay. Unused tool outputs fade naturally. No manual cleanup.

🧩

Pattern Completion

Decayed entries aren't deleted — they become 'silent engrams'. Re-fetch from source when needed. 89% retrieval success rate.

🎚️

Priority Modifiers

Critical: no decay. High: slow decay. Normal: standard. Low: fast decay. Encoding depth and associations further modify rates.

🌙

Consolidation Cycles

Light (every turn): recalculate strengths. Deep (session end): compress to essentials. Archival (periodic): promote to long-term memory.

📋

Lifecycle Policies

Declarative rules for automatic management. 'Browser snapshots decay at 0.2/turn'. 'User instructions persist'. YAML-based configuration.

Part of Agent Brain Architecture

Four protocols inspired by neuroscience. Each handles a different aspect of agent cognition.

🌙
defrag.md
Sleep & Consolidation
nightly cycles
memory consolidation
cleanup routines
synapse.md
Multi-Agent Memory
shared memory
agent teams
permissions
🧠
hippocampus.md
Context Lifecycle
sparse indexing
decay functions
pattern completion
CURRENT
🏛️
neocortex.md
Long-Term Format
coming soon
structured format
curated knowledge

hippocampus.md manages context lifecycle • neocortex.md structures long-term memory
defrag.md consolidates during sleep • synapse.md shares across agents

Real Benchmarks

Measured on a production agent (R2D2) over 7 days.

16.6×
Live Compression
202K → 5K tokens
Lower Cost
$43 → $8 per day
85×
Avg Compression
Tool outputs
89%
Retrieval Success
Pattern completion
0
Data Lost
Everything retrievable
No management
Context145K
Cost$43/day
LossHigh
Summarization
Context40K
Cost$18/day
LossMedium
hippocampus.md ✦
Context18K
Cost$8/day
LossLow

Get Started

Implement context lifecycle management in your agent.

hippocampus-entry.ts
# Context entry schema (TypeScript)
interface HippocampusEntry {
  id: string;
  type: "tool_result" | "message" | "state";
  
  source: {
    type: string;        // How to re-fetch
    ref: string;         // External reference
    retrievable: boolean;
  };
  
  summary: string;       // Human + LLM readable
  key_data?: Record<string, unknown>;
  
  strength: number;      // 0.0 - 1.0
  
  decay: {
    rate: number;        // Strength loss per turn
    floor: number;       // Minimum strength
    last_access: number; // Turn of last access
  };
  
  modifiers: {
    priority: "critical" | "high" | "normal" | "low";
    encoding: "manual" | "auto";
    associations: string[];
  };
}