Long-Running Sessions: Compression, Notes and Memory Files, Subagent Isolation and Handoff Summaries
A window will always fill up once a task runs for tens of minutes. Today implement a measurable compression strategy, and draw a clear line between when notes-and-memory-files and when subagent isolation each fit.
Today's Goals
- Implement a compression strategy, and verify it with the token count before and after plus a key-information retention check
- Name which tasks compression, notes-and-memory files, and subagent isolation each suit
- Write a handoff summary template, and explain why a subagent should only pass back a summary, not its full process
The first three days all treated things whose per-turn length is essentially controllable. Today treats the last piece: conversation history. Its defining trait is that it only grows, and a task running tens of minutes will inevitably fill the window. Come back when you have read it and tick off the three goals.
Plain-Language Walkthrough
Repacking at a layover
A long trip means a connection. In three hours at the transfer airport, experienced travellers do one thing: open the case and repack it. Clothes worn on the first leg go into the laundry bag and down to the bottom, the boarding pass stub goes in the bin, and the contract needed on the second leg moves to the top. Same case, and most of the usable space is back.
Compaction is that act. When a session nears the window limit, summarize what came before into a shorter passage, replace the original with it, and carry on with the summary.
It differs from yesterday's pruning in one fundamental way, and that difference is what makes it more dangerous: pruning operates on structure, compaction on language. Pruning drops an audit_log field and you know what you dropped and can fetch it back any time. Compaction turns thirty turns of conversation into a three-hundred-word summary, and what got lost was decided by the model, with no marker afterwards to tell you anything was lost at all.
So the entire difficulty of this craft is not how to compact — calling a model to summarize is something anybody can write. The difficulty is proving you did not compact wrongly. In today's lab the compactor has two outputs: a compression ratio and a key-fact survival check. Only the second makes the first mean anything.
So what should be kept and what thrown out, when should compaction fire, and when is compaction simply the wrong answer? One at a time below.
Interview questions
When should you compact the context, and when should you just move to a larger context window?什么时候该压缩上下文,什么时候该直接换一个更大的窗口?
Common in ChinaCommon overseasIntermediate#compaction#context-rot🔒 Unlock this chapter to see the answer keys.
What does compaction lose most easily, and how do you verify that a given compaction kept what mattered?压缩最容易丢什么?你怎么验证一次压缩没有丢掉关键信息?
Common in ChinaCommon overseasDeep dive#compaction#verification🔒 Unlock this chapter to see the answer keys.
Why does a subagent return only a summary instead of its full transcript, and how should the lead agent specify the handoff?子代理为什么只回传摘要而不回传全过程?主代理该怎么写交接要求?
Common in ChinaCommon overseasDeep dive#subagents#handoff#cost🔒 Unlock this chapter to see the answer keys.
