Compaction: keep the window bounded as the run grows

Run a support session turn by turn. Every turn is re-sent, so the live window keeps growing. When it crosses the token budget the meter turns red, then a COMPACT step keeps the last 2 turns HOT, folds older decisions into a WARM summary, drops chatter, and pushes the oldest WARM into a one-line COLD gist. The bar drops back under budget and the run continues.

The world: the same refund desk. User Dana, order ORD-3300, a $200.00 order returned after the 30-day window, a 10% restocking fee, so the refund is $180.00, then a question about the Globex earbuds warranty.
Budget BUDGET = 40, hot tail HOT_N = 2. Tokens are estimated by word count, so the run is reproducible.
Press Add next turn. Each turn adds to the window; watch the meter climb. It crosses budget on turns 4, 6, 8, 9, and 10, and each crossing triggers a compaction that brings it back under.
live window 0 / 40 tokens under budget
The window the model actually sees
hotlast 2 turns, verbatim
warmrolling summary of decisions and tool outputs
coldone lossy line
Not RAG Part 20 condensation. P20 rewrote the latest question into a standalone one so retrieval works ("what about its battery?""what is the battery life of the earbuds?"). Compaction compresses the history so the run fits the window. Different input, different output, different purpose.

Forgetting: score by importance x recency x access; decay, supersede, evict

A store that only grows fills with stale and duplicate facts. Each fact carries an importance and a last-touch time. Reads rank by a score; writes decay importance with age, retire a fact when a newer one supersedes it, and evict the weakest when the store is over capacity. Drag the time slider, then fire the two write events.

The score: importance x recency x access, where recency halves every HALF_LIFE = 4 time units and each read nudges access up. Capacity is CAPACITY = 4 active facts.
At t = 0 every fact is fresh. Slide to t = 6: recency has decayed every score, and 'the user is Dana' was read twice, so its access count lifts it.
The store, ranked by score
Why an agent must forget: growth without forgetting is just slower failure. Compaction keeps the live window bounded (the hot / warm / cold tiers above); forgetting keeps the store sharp (decay fades old facts, supersession retires what a newer fact replaces, eviction drops the weakest over capacity). A sleep-time consolidation pass then distills raw episodes into durable semantic facts and procedural rules.

hot / working   warm   cold   score   over budget / evicted   under budget / active