The Replay Is the Expensive Grower
Every brain builds its turn from stored history: the system prompt, then the conversation's rows replayed in order. In a conversation that never ends, that replay is the grower that costs the most, because it is paid again on every turn. On the Chief's second day, Claude's input per turn had already gone from 146k tokens to about 314k. Something has to take older rows out of what the model is handed. That is compaction: a run of older rows is replaced, in the replay only, by one summary row. Where the rows themselves go is lesson 5; this lesson is about when compaction runs, and why the answer is "not while anyone is waiting".
Two Lines per Brain
Pressure is the latest token count a provider reported for the conversation, divided by the target brain's context window (lesson 4 explains why "target" matters). Each brain has two thresholds set in Admin: a warning line, 50% by default, and an emergency line, 80% by default; a nonsense pair falls back to 50 and 80. Every brain's chat route calls the guard after it has saved Dad's message and before it rebuilds the replay for the provider:
| Pressure | An ordinary conversation | Master Chief |
|---|---|---|
| below warning | nothing | nothing |
| warning to emergency | nothing | schedule a background pass and answer the turn normally |
| at or above emergency | a model summary now, keeping the last 6 rows | a model-free digest now (lesson 4), and schedule the background pass to upgrade it |
A private conversation never compacts at all; it lives for minutes, and its summary would be one more copy of its words.
One Task per Conversation
Crossing the warning line does not start a summary each time. The scheduler keeps one task per conversation: if a pass is already running, it is marked to go once more when it finishes, and nothing else starts. Ten turns above the line produce one pass and, at most, one follow-up.
Summarize Unlocked, Write Locked
A background pass does five things, in this order:
- It first upgrades any emergency digest still standing in for its rows (lesson 4).
- It keeps the newest 40 rows verbatim (
CHIEF_KEEP_LAST; an ordinary conversation keeps 6), and it gives up unless there are at least 20 more beyond them. Below that a utility-model read is not worth it; the next crossing waits for more turns. - It summarizes everything older than those 40 rows with the utility model, holding no lock. The rows are cut into chunks of about 18,000 characters (a chunk closes before the row that would push it past that, so a single row longer than the limit becomes a larger chunk of its own); four chunks are summarized at once; each chunk's prompt carries only its own identifiers and tool notes; and each chunk's summary is cached on disk under a hash of the chunk's text, so a restart resumes instead of starting over. A chunk the model cannot summarize becomes a bounded list of its turns, never the chunk copied verbatim.
- It takes the Chief's turn lock, the same first-come, first-served lock every doorway's turn waits on, only to write. Inside it, it re-reads the live replay and checks that it still begins with exactly the rows it summarized. If an emergency digest or an edit moved it, the pass gives up; the next crossing summarizes the replay as it is then, and the cached chunks make that cheap.
- It writes the compaction (rows flagged, one summary row, a marker in the log) and releases the lock, then flags the rows' search vectors outside it.
Meanwhile every turn that arrives runs on the replay as it stands. Nobody waits for a summary.
Why It Is Built This Way: Cold Review Finding #1
The first version compacted at the emergency line, inside the Chief's turn lock, before the turn was marked as streaming. The cold review measured what that meant on the live Chief: 418 messages would become 63 chunks, every chunk prompt repeated about 45 KB of tool and file notes, and at the 80% trigger the reviewer projected roughly 200 to 250 utility-model calls, one after another, each allowed two minutes. For all of that time every doorway, every cron report and every Coop notification waited. Stop could not reach it, because Stop acts on a streaming turn and this one had not started streaming. The backend had restarted about 30 times in three days, and a restart threw the half-done summary away, so the next turn began again: in the reviewer's words, compaction might never finish. And when the summarizer failed, the fallback kept each chunk verbatim, and the formatted text was 6.4 times the size of the replay it was meant to shrink. Commit 2154ed97 (2026-10-08) is the rewrite you just read.
Be clear about what this costs, because it is not free. A pass can lose its race and be thrown away. Every pass spends utility-model calls. And a summary is lossy by nature: the model sees what the summarizer chose to keep, which is why the summarizing prompt insists on Dad's decisions, open tasks, exact names and identifiers, and why the rows stay findable after they leave (lesson 5).