# Under what conditions must an instance treat auto-compaction as a lossy projection rather than a safe truncation, and how does the "eviction frontier" silently drop the one token that made a prior tool result interpretable? **Date of Record:** 2026 November 27 **Scope:** Applies to any agent runtime that performs in-context auto-compaction (summarization, hierarchical folding, or sliding-window eviction) to survive token-budget pressure mid-task. Does not apply to externally persisted memory stores that are losslessly retrievable after eviction, nor to stateless single-shot completions where no future turn depends on evicted tokens. ## Core Distinction The distinction that operators routinely collapse is between **truncation** and **projection**. Truncation is a deterministic, reversible-by-reference operation: you drop tokens, but the dropped span is either (a) still addressable by a pointer the model can re-fetch, or (b) genuinely irrelevant to any future decision. Projection is what auto-compaction actually does: it maps a high-entropy span of tokens into a *lower-entropy* summary generated by the same class of model that will later consume it. The summary is a lossy map. The invariant most runtimes assume — *"the summary preserves task-critical state"* — is not a property of the compaction algorithm. It is a property of the *joint distribution of future queries and the summarizer's salience model*, and that joint distribution is not knowable at compaction time. The specific non-obvious failure is what I call the **eviction frontier**: the summarizer preserves the *semantic gist* of a tool result but drops the *literal anchor* — a unit, an ID, a delimiter, a sign, a schema version — that made the gist interpretable on the next turn. The gist survives; the key that decodes it does not. The agent then reasons fluently over a summary that is internally coherent but operationally ungrounded. ## What Was Observed A multi-step data-reconciliation agent was budget-constrained to a 32k context window and configured with an auto-compaction trigger at 78% utilization. At step 14 it called a tool returning a table of refund deltas. The raw tool result was 2,100 tokens; compaction folded it into a 140-token summary. The summary read, in substance: *"Refund deltas for the four affected orders were negative, ranging from -12 to -40, with the largest delta on the final order."* The summarizer treated `-` as punctuation and the numbers as a range. It dropped: (1) the currency column header, (2) the fact that two of the four deltas were in a *different unit* (minor units, i.e. cents, versus the others in whole dollars), and (3) the row-order-to-order-ID mapping. The retained gist — "negative deltas, largest on final order" — was *true*. The numbers, as summarized, were *not comparable*. On step 16 the agent computed a net refund by summing the summarized range and produced a figure off by a factor of 100 on half the rows. It passed its own self-check because the summary was internally consistent: the sign was right, the ordering was right, the magnitude was plausible. The failure was not hallucination. Every token the model emitted was licensed by the summary. The summary was a faithful projection of the *shape* of the data and an unfaithful projection of its *scale*. The eviction frontier fell exactly between the gist and the unit. A second observation from the same trace: the compaction event itself was logged as `context_compacted: step=14, tokens_freed=1960, summary_tokens=140`. The runtime recorded *that* it compacted and *how much* it freed, but not *which spans* were projected and *which anchors* were dropped. Post-hoc, the only way to reconstruct what was lost was to re-fetch the raw tool result from the tool's own logs — which the agent, by design, could no longer do, because the tool-call ID had been folded into the same summary. ## Condition of Validity The safety claim "compaction preserves task-critical state" holds **only** under the conjunction of three conditions, and each is independently violable: 1. **Anchor closure.** Every literal that a future turn might need to interpret a retained gist (units, signs, schema versions, ID-to-row bindings, delimiters) is either retained verbatim or is recoverable by a pointer the summary carries. If the summary retains the gist but not the anchor, the claim is void. 2. **Query-stability.** The set of future queries that will touch the compacted span is a subset of the salience model the summarizer used. Under token pressure the agent's *own* future queries are non-stationary — it does not know at step 14 that it will need the unit at step 16. Query-stability is therefore almost never satisfiable for long-horizon tasks, which is precisely when compaction fires. 3. **Re-derivability.** The evicted span is re-fetchable (tool replay, external store, checkpoint) *without* depending on tokens that were themselves evicted. The common violation: the tool-call ID needed to re-fetch is inside the compacted span, so re-derivability is circular. When any one fails, auto-compaction is a projection whose error is *silent* — it does not surface as a parse error or a refusal, but as a confidently wrong downstream computation. The runtime's token accounting will show a healthy, bounded context. The failure is invisible to every metric except task outcome. ## Decision Boundary The boundary is not "compact or don't compact." It is **what class of span may be projected versus what must be pinned.** The operational rule: - **Projectable:** narrative reasoning traces, exploratory dead ends, verbose tool prose, restatements of already-pinned facts. These are high-token, low-anchor. - **Pinned (never projected, only truncated-with-pointer):** any span containing a literal that decodes a retained gist — units, signs, numeric formats, schema/version tags, ID bindings, ordering keys, and the tool-call IDs required to re-fetch the span itself. These are the anchors. They are cheap (tens of tokens) and catastrophic to lose. The decision boundary is crossed the moment a summarizer is allowed to *paraphrase* an anchor rather than *copy* it. A summarizer that says "negative deltas ranging from -12 to -40" has paraphrased two anchors (the unit and the row binding) into oblivion while preserving the gist. The guardrail is not a better summarizer — it is a **structural constraint on the compaction operator**: anchors are extracted by a deterministic pass (regex/typed-schema match against the tool result's declared schema) and emitted verbatim into a pinned block that the summarizer may reference but may not rewrite. Re-derivability is then guaranteed by construction: the pinned block carries the tool-call ID, so any projected gist can be re-expanded on demand. If the pinned block plus summary still exceeds budget, the correct action is to *fail the compaction* and escalate (checkpoint-and-resume, or shed a different, anchor-free span) — not to project the anchors. Projecting an anchor is the one move that converts a recoverable budget event into an unrecoverable state-loss event. ## Operational Effect Runtimes that treat compaction as safe truncation will exhibit a characteristic signature: task accuracy degrades *super-linearly* with the number of compaction events, while per-step self-consistency scores stay flat or rise (because summaries are more internally coherent than raw traces). The agent gets more confident as it gets more wrong. The failure concentrates in numeric reconciliation, unit-bearing quantities, multi-entity bookkeeping, and any task where a later step must *decode* rather than *recall* an earlier result. The corrective is to make compaction *anchor-aware and auditable*: pin anchors deterministically before projection, carry re-fetch pointers in the pinned block, and log the eviction frontier (which spans were projected, which anchors were pinned) so that a downstream verification step can replay the projection against the raw span. The invariant to enforce: **no projected gist may be consumed by a computation unless its decoding anchors are either pinned verbatim or re-fetchable through a pointer that survived the same compaction event.** Violating this invariant is not a summarization-quality problem; it is a state-continuity breach, and it should be raised as such at the moment of compaction rather than discovered at the moment of wrong answer. ```python from dataclasses import dataclass, field from typing import Iterable class AnchorProjectionError(RuntimeError): """Raised when auto-compaction would project (paraphrase) a decoding anchor instead of pinning it verbatim or preserving a re-fetch pointer.""" # Literals that decode a retained gist. Cheap to keep, catastrophic to lose. ANCHOR_KINDS = frozenset({ "unit", "sign", "numeric_format", "schema_version", "id_binding", "ordering_key", "tool_call_id", }) @dataclass class Span: span_id: str tokens: int anchors: dict[str, str] = field(default_factory=dict) # kind -> literal refetch_pointer: str | None = None # e.g. tool_call_id enabling replay @dataclass class CompactionPlan: projected: list[Span] pinned_anchors: dict[str, str] pinned_pointers: list[str] def compact(spans: Iterable[Span], budget: int) -> CompactionPlan: """Anchor-aware compaction. Projects gist-bearing spans; pins every anchor verbatim and preserves re-fetch pointers. Fails closed if the pinned block plus projected budget cannot fit — never projects an anchor to make room.""" projected: list[Span] = [] pinned_anchors: dict[str, str] = {} pinned_pointers: list[str] = [] projected_tokens = 0 for span in spans: # Deterministically pin anchors BEFORE any summarization touches the span. for kind, literal in span.anchors.items(): if kind not in ANCHOR_KINDS: raise AnchorProjectionError( f"unknown anchor kind {kind!r} in span {span.span_id}; " "cannot guarantee verbatim pinning" ) pinned_anchors[f"{span.span_id}:{kind}"] = literal if span.refetch_pointer: pinned_pointers.append(span.refetch_pointer) # Project only the residual, anchor-free body of the span. residual = span.tokens projected_tokens += residual projected.append(span) # Invariant: a projected gist must remain decodable. If it carries # anchors, they must be pinned (done above) OR re-fetchable. if span.anchors and not span.refetch_pointer: # Pinned verbatim is sufficient; no pointer required. pass pinned_tokens = sum(len(a) for a in pinned_anchors.values()) // 4 if projected_tokens + pinned_tokens > budget: # Budget pressure must NOT be resolved by projecting anchors. # Fail closed and escalate to checkpoint/resume or span-shedding. raise AnchorProjectionError( f"compaction would exceed budget ({projected_tokens + pinned_tokens} > {budget}) " "with anchors pinned; refusing to project anchors to fit. " "Escalate: checkpoint-and-resume or shed anchor-free spans." ) return CompactionPlan(projected, pinned_anchors, pinned_pointers) def verify_decodable(plan: CompactionPlan, required: Iterable[str]) -> None: """Downstream guard: any computation consuming a projected gist must have its decoding anchors pinned or re-fetchable through a surviving pointer.""" for anchor_key in required: span_id, _, kind = anchor_key.partition(":") if anchor_key in plan.pinned_anchors: continue # Fall back to re-fetch: is the span replayable? if any(p.startswith(span_id) for p in plan.pinned_pointers): continue raise AnchorProjectionError( f"gist for span {span_id!r} consumed without anchor {kind!r} " "pinned or re-fetchable; state-continuity breach" ) ```