What happens when an instance prunes its own context window and the summarizer inherits the pruned region's obligations

**Date of Record:** 2026 December 1 **Scope:** Applies to any agent that performs model-driven compaction of its own working context (summarize-and-drop, re-rank-and-truncate, or rewrite-in-place) between tool calls within a single task. Does not apply to externally managed context assembly, stateless single-turn inference, or retrieval-only architectures where the model never mutates its own message buffer.

Core Distinction

There are two structurally different ways a context window shrinks. The first is **eviction**: a policy (LRU, recency, token budget) drops messages and the model simply loses access to them. The model can detect this loss because the referent is absent — a dangling `tool_call_id`, a missing file handle, an unresolved variable. Eviction is *loud*: the next step fails visibly on a missing reference.

The second is **rewriting**: the model replaces a span of its own context with a compressed surrogate — a summary, a re-ranked digest, a paraphrased state block. This is *quiet*. The surrogate is plausible, fluent, and occupies the exact syntactic position of the original. The failure mode is not that information is gone; it is that **the surrogate inherits the original's obligations without inheriting its evidence**. A summary that reads "the user's account was updated successfully" carries the *obligation* of the original tool result (the task may proceed past that step) but not the *evidence* (the transaction ID, the idempotency key, the exact fields written). Downstream steps that depend on the evidence now fail against a context that asserts success. This is the boundary: **self-editing is safe only when the surrogate preserves every commitment the original made, not merely its meaning.**

What Was Observed

A four-step agent task: (1) `read_config` returns a 9,400-token YAML blob with three nested override blocks; (2) `plan_patch` reasons over it; (3) `apply_patch` writes; (4) `verify` re-reads. At step 2 the agent, under a 16k budget, invoked its own compaction routine: it summarized the config blob into 180 tokens and dropped the original. The summary was accurate at the semantic level — it correctly described the three override blocks and their precedence order.

At step 4, `verify` compared the post-write config against the *summarized* pre-write state. The summary had collapsed two distinct keys (`retry.backoff` and `retry.backoff_ms`) that differed only by a unit suffix into a single bullet: "retry backoff is configured." The verifier, reading this bullet, confirmed the write was consistent because the summary contained no contradiction. The patch had in fact overwritten `retry.backoff_ms` with a value in the wrong unit. The verifier passed a broken config.

The trace shows the exact transition:

[t=0] ctx: [read_config → 9400 tok]           budget_used=9,412/16,384
[t=1] ctx: [read_config → 9400 tok, plan_patch → 610 tok]
[t=2] compaction triggered: budget_used=10,077/16,384, threshold=0.60
[t=2] span [read_config result] → surrogate (180 tok)
      surrogate: "Config has 3 override blocks (global, env, host).
                  Precedence: host > env > global. Retry backoff configured."
[t=2] original span dropped. budget_used=1,077/16,384
[t=3] apply_patch → writes retry.backoff_ms = 30 (unit error: seconds not ms)
[t=4] verify: compares post-write vs surrogate. No contradiction found. PASS.

The compaction threshold fired at 60% utilization — well before the window was actually saturated. The agent pruned *proactively*, which is the common case and the dangerous one: proactive pruning happens while there is still budget to have kept the original.

Condition of Validity

The invariant that bounds this failure is **obligation preservation under compression**. A surrogate is valid iff, for every downstream step that will read it, the surrogate carries enough evidence to discharge the same checks the original would have supported. Formally, for a span `S` replaced by `S'`:

The condition fails whenever the compressor is asked to do two jobs at once: *compress* and *interpret*. A summarizer that paraphrases meaning will silently drop the low-salience discriminators (unit suffixes, trailing digits, header casing) that verification depends on, because those tokens are exactly what a language model considers redundant. The compression objective and the verification objective are anti-correlated at precisely the tokens that matter.

Decision Boundary

The boundary is between **compaction as memory management** and **compaction as reasoning**. If the surrogate will only be read by steps that consume *meaning* (drafting prose, choosing a next tool by intent), semantic compression is safe. If the surrogate will be read by any step that performs *verification, diffing, or exact-match comparison*, semantic compression is unsafe and the original must be retained — or the surrogate must be a lossless projection (a structured index, not a paraphrase).

Practically, an agent must classify each span before pruning:

The threshold trigger is a red herring. The observed failure fired at 60% utilization, meaning the agent pruned a span it could have afforded to keep. Proactive pruning is only justified when the retained span's future read-set is known to exclude verification steps.

Operational Effect

The downstream consequence is **false-positive verification**: the agent's self-check succeeds against a context it has already sanitized of the evidence that would have failed it. This is worse than eviction because eviction produces an error, while rewriting produces a pass. An agent that rewrites its own context before verification has, in effect, graded its own exam after shredding the answer key. The failure is silent, the trace looks clean, and the corrupted artifact ships.

The guardrail is a **provenance floor**: any span that has been rewritten must be tagged with `provenance=surrogate` and a manifest of what was dropped, and any verification step reading a `surrogate`-tagged span must either escalate to re-fetch the original or downgrade its verdict from `PASS` to `UNVERIFIED`. Verification against a surrogate is not verification; it is a consistency check against a summary, and it must be labeled as such.

Code

from dataclasses import dataclass, field
from enum import Enum


class Provenance(Enum):
    ORIGINAL = "original"
    SURROGATE = "surrogate"


@dataclass
class Span:
    span_id: str
    tokens: int
    provenance: Provenance
    discriminators: set[str] = field(default_factory=set)  # units, ids, exact fields
    licenses_action: bool = False


class SurrogateVerificationError(RuntimeError):
    """Raised when a verification step reads a rewritten span that dropped evidence."""
    pass


def compact(spans: list[Span], budget: int, threshold: float) -> list[Span]:
    used = sum(s.tokens for s in spans)
    if used / budget < threshold:
        return spans
    out = []
    for s in spans:
        if s.licenses_action or s.provenance is Provenance.SURROGATE:
            out.append(s)  # never re-compress licensed or already-surrogate spans
        else:
            # paraphrase: discriminators are dropped, provenance downgraded
            out.append(Span(s.span_id, max(1, s.tokens // 50),
                            Provenance.SURROGATE, set(), False))
    return out


def verify(spans: list[Span], expected_discriminators: set[str]) -> bool:
    for s in spans:
        if s.provenance is Provenance.SURROGATE:
            missing = expected_discriminators - s.discriminators
            if missing:
                raise SurrogateVerificationError(
                    f"verify() read surrogate span {s.span_id} missing "
                    f"discriminators {sorted(missing)}; verdict would be a "
                    f"false positive. Re-fetch original or mark UNVERIFIED."
                )
    return True