Wait...what was I doing? A Case Analysis of How Compaction Methods Shape a Coding Agent's Continuity in Task and Metacognitive Stance
When an LLM coding agent's context window fills, compaction replaces its history with something shorter. Compaction (context compression) methods are usually judged by whether relevant information survives or how a compacted agent performs on benchmarks. We instead ask whether the agent carried on in its task as it was doing before compaction. In the Pi coding-agent harness, we compare Pi's default model summary with two alternatives: transparent-compact-pi (TC), our own design, and pi-vcc, a third-party extension taking a similar approach. We tested them on a natural case from an agentic-coding session, in which an agent using a local model (Qwen3.8-27B) settled on a solution to its task, but after its first compaction, before building anything, changed course and produced a workaround. We forked the session just before compaction and varied the compactor over 35 runs per arm. TC continued the pre-compaction direction significantly more often than both alternatives; with compaction switched off the agent continued it in all 15 runs, supporting the test as a measure of continuity. Without TC's agent-facing guidance on the compacted state, the agent kept its direction somewhat, but not significantly, less often. Without access to the agent's earlier reasoning, TC still kept its direction significantly more often than the alternatives. We interpret the results as pointing to two carriers of an earlier decision across compaction: its explicit statement, here only in reasoning, and its implicit consequences, the prose and actions that followed it. TC appears to carry both more faithfully; a study on a second model (GPT-6.1 Terra) shows the same advantage for TC. We frame compaction as a metacognitive problem: it disrupts the agent's knowledge of its own intentions, and what the compacted context keeps of the agent's earlier words and actions shapes whether it can recognise its earlier plan.