# Context Lifecycle Management — Multi-Model Synthesis
*3 models consulted: Kimi K2.5, Sonnet 4, MiniMax M2.5 (via Cog)*
*Date: 2026-02-17 06:15 AEDT*

---

## 🔑 Universal Agreement (All 3 Models)

### 1. Tiered Classification
Every context item tagged by importance:
- **CRITICAL** — Decisions, specs, errors, user instructions → always preserve
- **WORKING** — Current task state, active conversation → preserve during work
- **REFERENCE** — Old conversations, completed tasks → compress to summaries
- **EPHEMERAL/NOISE** — Heartbeats, status checks, routine reads → discard first

### 2. Threshold-Based Auto-Compaction
- **75%** — Start compressing noise, deduplicate file reads
- **85%** — Archive old conversations, compress reference items
- **95%** — Emergency checkpoint + controlled reset
- **Never let 100% happen** (Builder's 104% was a preventable failure)

### 3. Checkpoint-and-Resume Protocol
Before any reset, agent writes:
- Current task + step + progress percentage
- Recent decisions with rationale
- Pending actions (what to do next)
- Knowledge updates (things learned this session)

After reset, agent reads checkpoint first → seamless resume.

### 4. External Memory > Context
- **In context:** Active conversation, current task execution, immediate decisions
- **In files:** Everything else — decisions log, knowledge base, task specs, archives
- Files persist forever. Context is temporary. Treat context like a cache.

---

## 🔀 Unique Ideas Per Model

### Kimi — Importance Scoring Engine
- Regex-based pattern matching scores each message (0.0 to 1.0)
- Decision markers score 0.9, heartbeats score 0.0
- Recency boost + repetition penalty
- Learns importance patterns over time

### Sonnet — Four-Tier with Compression Log
- Tracks every compression event (what was removed, why, when)
- Can reconstruct context from compression log if needed
- Inter-agent handoff protocol for coordinated work

### MiniMax (Cog) — Permanent vs Temporary Folders
- `/permanent/` — Identity, rules, decisions, specs (never touched)
- `/session/` — Active work with checkpoints
- `/archive/` — Daily compressed logs (gzipped)
- `/temp/` — Auto-expires, scratchpad for working notes

---

## 📐 Recommended Implementation

### Phase 1: Build Now (Add to Builder's task)
1. **Context monitoring script** — Checks token usage every heartbeat
2. **Threshold alerts** — 75/85/95% triggers
3. **Auto-checkpoint** — Write state file at 85% before any compaction
4. **Startup protocol** — Read checkpoint on fresh session

### Phase 2: Build Next Week
5. **Importance classifier** — Tag messages by type
6. **Smart compaction** — Remove noise first, keep critical
7. **Compression log** — Track what was removed for audit

### Phase 3: Optimization
8. **Content-addressed deduplication** (from earlier coordination synthesis)
9. **Learning importance model** — Improve classification over time
10. **Cross-agent context sharing** — Avoid re-reading shared data

---

*This directly prevents the Builder 104% incident from recurring across the fleet.*
