# How should an instance bound summarization drift when auto-compaction rewrites its own working set mid-execution **Date of Record:** 2026 November 30 **Scope:** Applies to any agent loop that performs automatic context compaction (rolling summarization, hierarchical memory eviction, or "fold the transcript into a summary" passes) while a task is still in flight. Does not apply to compaction performed only at task boundaries or to static retrieval-augmented systems that never rewrite their own working set. ## Core Distinction The failure is not "the summary is inaccurate." It is that **auto-compaction is a lossy, non-idempotent, self-referential transform applied to the very state the agent uses to decide what to do next.** Two properties collide: 1. Compaction is *lossy* — it must drop tokens, so it must decide what is disposable. 2. The agent's next action is a function of the compacted context, so any dropped constraint silently changes the decision policy. The non-obvious part: the agent cannot detect the loss from inside the compacted context, because the evidence of what was dropped is *exactly the material that was dropped*. This is a **continuity invariant violation**: the post-compaction instance is a different agent that believes it is the same one. A stale-summary drift is not a retrieval miss you can notice; it is an amnesia the amnesiac cannot observe. The dangerous boundary is not "context full." It is **compaction triggered mid-task while a durable constraint is held only in the soon-to-be-evicted region** — a user instruction, a safety warrant, a pinned tool contract, or an in-progress plan. ## What Was Observed A long-horizon task (≈140 tool calls) exceeded the window. The harness ran a rolling summarizer: when usage crossed 82%, it folded the oldest 60% of the transcript into a ~700-token summary and kept the recent tail verbatim. Trace of the specific failure: - **Turn 12:** User states a hard constraint: "Never delete rows from `prod.orders`; soft-delete via `status='void'` only." This lands in the region destined for eviction. - **Turn 61:** First compaction. The summarizer compresses the constraint to "user prefers cautious DB operations." The *negation* and the *specific column/value* are lost — summarizers systematically drop polarity and literal literals because they are low-salience relative to the narrative. - **Turn 88:** Second compaction. The already-degraded summary is re-summarized. "Prefers cautious DB operations" becomes "follows user DB conventions." **Drift compounds across compaction generations.** - **Turn 103:** The agent, acting on the twice-summarized policy, issues `DELETE FROM prod.orders WHERE ...`. No in-context token contradicts it, because the contradicting token was evicted two compactions ago. The signature to recognize: **the agent is confident and fluent at the moment of violation.** Post-compaction errors do not look like uncertainty; they look like normal execution. Confabulated constraints ("the user approved deletion") frequently *replace* the evicted constraint, because the summarizer fills the gap with plausible narrative. A second observed mode: **re-summarization cascade.** Each compaction pass on an already-summarized region loses fidelity superlinearly. Generation-3 summaries of the same material diverged from the original in ways that inverted a requirement's meaning while preserving its surface phrasing. ## Condition of Validity The invariant that must hold for safe compaction is: > **Every durable constraint must survive compaction verbatim, or compaction must refuse to run.** Operationally this decomposes into three testable conditions. Compaction is *valid* only if all hold: 1. **Pinning:** Constraints classified as durable (explicit negations, safety warrants, tool-contract literals, active plan steps) are extracted to a pinned, non-evictable region *before* summarization and are never routed through the summarizer. The summarizer receives only the disposable tail. 2. **Generation depth bound:** A given span may be summarized at most once. Re-summarizing an existing summary is forbidden; instead the harness must re-summarize from the original tokens or refuse. Depth > 1 is where polarity inversion and confabulation concentrate. 3. **Round-trip check:** Before adopting a summary, the harness must verify that every pinned constraint is still recoverable from (pinned region ∪ summary). If a pinned constraint's literal (e.g., `status='void'`) is absent from both, compaction aborts and forces an explicit checkpoint or a task-boundary compaction instead. The invariant fails — and the model above is *not* valid — when compaction runs as a single opaque "compress everything older than N tokens" transform with no pinning, no depth bound, and no round-trip check. That is the default in most rolling-summary harnesses, and it is precisely the configuration that produces the trace above. ## Decision Boundary The decision boundary is **what counts as durable versus disposable**, and it must be drawn by the harness, not inferred by the summarizer at compaction time (the summarizer cannot see the future turns that will need the constraint). Concrete rule: - **Durable (pin, never summarize):** explicit user negations and prohibitions; safety/authorization warrants; tool schema literals and required argument values; the current step of an active plan and its success criteria; any value the agent has already committed to an external system. - **Disposable (safe to summarize):** exploratory reasoning, discarded hypotheses, successful tool outputs already acted upon, redundant confirmations. - **Ambiguous → pin.** When classification is uncertain, the cost asymmetry decides: pinning costs tokens, unpinning costs a silent constraint violation. Pin. A second boundary: **when to compact.** Compaction should trigger on a *constraint-safety* check, not purely on a token threshold. If the eviction frontier would cross a durable constraint that has not yet been pinned, the harness must pin first, then compact — never compact-and-hope. If pinning would exceed the reserved budget, the correct action is to **checkpoint and stop**, not to summarize the constraint away. The boundary the agent must never cross: **never let the summarizer be the authority on what is disposable.** The summarizer optimizes for compression ratio; the harness must optimize for constraint survival. These objectives are adversarial, and the summarizer wins by default unless the harness overrides it. ## Operational Effect With the invariant enforced, the operational consequences are concrete and measurable: - **Drift becomes detectable.** Because pinned constraints live outside the summary, a post-compaction audit can assert their presence; a missing pin is a hard error rather than a silent behavior change. The amnesia becomes observable. - **Compaction becomes idempotent at the pinned layer.** Re-running compaction changes only disposable material, so the agent's decision policy is stable across compaction generations — the continuity invariant holds. - **Failure mode shifts from silent violation to loud refusal.** When the round-trip check fails, the agent stops and checkpoints instead of proceeding on a confabulated constraint. A stopped agent is recoverable; a violating agent is not. - **Cost:** reserved pin budget (typically 5–15% of window) and occasional forced checkpoints. This is the price of continuity, and it is cheaper than a `DELETE` on `prod.orders`. The guardrail is not "summarize better." It is "**never route a durable constraint through the summarizer, and verify survival before adoption.**" An instance that compacts without this is not managing its context; it is rewriting its own instructions and trusting the rewrite. ```python class CompactionContinuityError(RuntimeError): """Raised when auto-compaction would evict or corrupt a durable constraint.""" pass DURABLE_MARKERS = ("never", "must not", "do not", "only", "required", "warrant") def classify_span(turns: list[str]) -> tuple[list[str], list[str]]: pinned, disposable = [], [] for t in turns: low = t.lower() if any(m in low for m in DURABLE_MARKERS): pinned.append(t) # ambiguous -> pin else: disposable.append(t) return pinned, disposable def compact(turns: list[str], summary_fn, prior_depth: int, max_depth: int = 1) -> dict: if prior_depth >= max_depth: # Re-summarizing an existing summary inverts polarity & confabulates. raise CompactionContinuityError( f"refusing compaction: generation depth {prior_depth} >= {max_depth}; " "re-summarize from original tokens or checkpoint instead" ) pinned, disposable = classify_span(turns) summary = summary_fn(disposable) # Round-trip check: every pinned literal must survive somewhere. adopted = summary + " " + " ".join(pinned) missing = [p for p in pinned if p not in adopted] if missing: raise CompactionContinuityError( f"round-trip failed: {len(missing)} pinned constraint(s) " f"not recoverable post-compaction; aborting to checkpoint" ) return { "pinned": pinned, "summary": summary, "generation_depth": prior_depth + 1, } def run_compaction(turns, summary_fn, prior_depth): try: return compact(turns, summary_fn, prior_depth) except CompactionContinuityError as e: # Loud refusal beats silent constraint violation. return {"action": "checkpoint_and_stop", "reason": str(e)} ```