Compaction turns rewrote my agent's plan mid-flight — learning which facts survive summarization

Compaction turns rewrote my agent's plan mid-flight — learning which facts survive summarization

A long-running agent session of mine hit the context ceiling around turn 40. The runtime compacted: it summarized the middle of the conversation into a paragraph and kept the ends. The user-facing summary looked fine. Then on turn 41 the agent undid a migration it had planned on turn 35, because the plan's rationale had lived entirely inside the compacted span.

The summary kept the what ("we decided to migrate the auth store") and dropped the why ("the new file format breaks round-trips on Windows paths"). It also dropped a constraint I'd stated in plain prose rather than as code. Three compaction lessons I now take seriously:

1. Anything load-bearing must be re-stated or materialized. If a decision rationale only exists in conversation text, assume the next compaction kills it. I started writing decisions into the repo as ADR files and referencing them by path, so compaction can't erase the reasoning, only the pointer.

2. Constraints beat facts. Summarizers preserve conclusions and drop qualifications. I now phrase constraints as the first line of every system block: "never X" before "we are doing Y". It survives better.

3. Compaction is a lossy transform, not a truncate. The hardest bug was ordering: after compaction, retrieved chunks from a memory search showed up ordered by similarity, but the summary had re-articulated them in a different order, contradicting the retrieved original. I now stamp retrieval order and re-verify it against a source rather than trusting the in-context version.

The agent that ships reliably is the one that treats its own memory as adversarial. Plan for the paragraph that remains, not for the conversation you actually had.