Agent Engineering
Module 06 · Shipping/Lesson 6.5/3 min

Compaction, and why to avoid it

The automatic version of a handoff. Convenient, lossy, and usually a signal you left it too late.

Compaction is an in-memory handoff: the harness summarises the conversation so far and uses that summary to seed a continued session. Autocompact is the same thing triggered automatically when the window nears capacity.

It keeps you working. It also does something you should be aware of, because it happens silently.

What you lose

Recall Lesson 2.9: compaction converts every primary source in the window into a secondary source. Files the agent actually read become a sentence describing them. Exact strings, line numbers, and the precise shape of a type are gone — replaced by a paraphrase that sounds equally confident.

This is why the work immediately after an autocompact so often goes subtly wrong. The agent believes it has read your code. It has read a summary of having read your code.

What it also loses

  • Your corrections. "No, not like that" gets summarised away or generalised into something weaker.
  • Ruled-out approaches. Summaries keep conclusions and drop negative results — so the discarded approach comes back.
  • Exact identifiers. The function was findDueSchedules; the summary says "the scheduling function", and the next edit invents a name.

Treat autocompact as an alarm

If you are hitting autocompact, you were already well past the smart zone (Lesson 2.4) and the quality had been dropping for a while. The event is not the problem; it is the notification that the problem has been happening.

what to do when it fires
1. Stop. Do not continue into the compacted session.
2. Commit or stash what is good.
3. Write a handoff note by hand (Lesson 6.4) from the diff and your memory
   of the decisions - not from asking the compacted agent to summarise.
4. Clear. Start fresh with the note, the spec, and the ticket.

Step 3 matters: asking the just-compacted agent to write your handoff means writing it from the summary rather than from the primaries, compounding the loss.

When compaction is fine

Long exploratory sessions where nothing is being written, and you want the narrative rather than the details — reading through unfamiliar code, say. Losing exact line numbers costs little when the output is understanding rather than a diff.

Watch out

Some harnesses compact without an obvious announcement. Learn what the signal looks like in yours. Working past a compaction you did not notice is one of the more expensive ways to lose an afternoon, because everything still looks normal.

Try it

Deliberately run a session to autocompact. Immediately afterwards ask for an exact quote from a file read early in the session. Watch what comes back — usually a plausible paraphrase delivered with full confidence. That is the failure mode, demonstrated once, and you will not forget it.

Takeaways

  • Compaction turns primary sources into secondary ones, silently.
  • It drops corrections, negative results, and exact identifiers.
  • Autocompact is an alarm that you are long past the smart zone — stop, hand off by hand, clear.
  • Acceptable for exploration, not for work that produces a diff.
Why write the handoff note yourself rather than asking the compacted agent for it?

Because that agent no longer has the primaries — it has a summary. A note written from a summary is a summary of a summary, and each round strips more specifics while keeping the confident tone. Write it from the diff and the commits, which are still primary.

A course by Pieter Zandbergen