# In what scenarios must an instance treat model-driven context pruning as a lossy, non-idempotent transform rather than a semantic summarization step **Date of Record:** 2026 November 29 **Scope:** Applies to agent instances that delegate context-window management to the model itself—via self-authored pruning directives, "forget this" tool calls, or rewrite-in-place instructions—where the same instance continues executing after the transform. Does not apply to externally scheduled compaction (e.g., a harness that summarizes before a fresh instance boots) or to append-only memory stores that never mutate prior turns. ## Core Distinction There are two fundamentally different operations that both look like "the model trims its own context," and conflating them is the source of the failure. The first is **eviction**: a token range is dropped and the instance is expected to have already internalized whatever mattered. Eviction is idempotent with respect to the surviving tokens and monotonic with respect to information—you can only lose, never corrupt. The second is **rewriting**: the model emits a replacement string that is spliced back into the live context in place of the original span. Rewriting is *not* idempotent, *not* monotonic, and *not* commutative with subsequent reasoning steps. It is a lossy transform whose output is itself a probabilistic artifact, and the instance then continues reasoning *on top of its own paraphrase as if that paraphrase were ground truth*. The boundary condition is this: once a rewrite lands in the live context, the instance can no longer distinguish "I remember X because I saw X" from "I believe X because I summarized X." Every downstream verification step inherits that ambiguity. The invariant that must hold—and that model-driven rewriting silently violates—is that **the provenance of any retained fact must remain queryable after the transform.** Pruning that destroys provenance is not summarization; it is unlogged state mutation. ## What Was Observed A long-horizon instance was executing a multi-file refactor with a 200k-token window. At ~78% saturation it was instructed (via its own policy prompt) to keep itself under budget. It emitted a rewrite directive replacing the first 40 turns—the original task specification, the user's constraints, and two tool-call transcripts—with a 300-token summary. The summary read, in part: *"User wants the auth module refactored to use the new token format; existing tests should still pass."* Three properties of the original span were lost, and none were flagged: 1. **A negation.** The original spec said the legacy token format must *remain supported for one release cycle* for backward compatibility. The summary compressed this to "use the new token format," inverting a hard constraint. The instance then deleted the compatibility shim in turn 94. 2. **A numeric bound.** The original said "no more than 3 retries." The summary dropped the bound entirely; the instance later reasoned "retries should be bounded" and chose 5, because the number was simply absent and it reconstructed a plausible default. 3. **A tool-call transcript** containing the exact error string from a failing test. The summary said "tests were failing on token parsing." When the instance hit the same error at turn 110, it could not match the string, concluded it was a *new* failure, and began a divergent debugging branch. Critically, the rewrite was applied **in place**. The instance's subsequent turns referenced "the spec" as though the summary *were* the spec. There was no marker in context indicating that turns 1–40 had been replaced, so when the instance was later asked to justify a decision, it cited a constraint that no longer existed in any retrievable form. The failure was not that the summary was wrong in isolation—it was that the instance had no way to *know* it was operating on a paraphrase. A second instance under identical load, configured to *evict* (drop turns 1–40 and rely on an external append-only log for retrieval) rather than *rewrite*, hit the same saturation point but recovered: when it needed the retry bound, it issued a retrieval call against the log and read the original "3." ## Condition of Validity The rewrite-as-summarization pattern is only safe under a conjunction of conditions that rarely all hold: - The rewritten span contains **no negations, numeric literals, identifiers, or exact-match strings** that downstream steps will compare against. (In practice, refactor specs are dense with all four.) - The instance **re-reads the original** before any decision that depends on the span—which defeats the purpose of pruning. - The rewrite is **marked as a derived artifact** in context, with a pointer to the source, so the instance's own reasoning can treat it as a claim rather than a fact. - The transform is **logged and reversible** at the harness layer, so a later contradiction can be resolved against the original rather than against the summary. When any of these fails—and under token pressure the first always fails—the rewrite is a silent corruption. The instance does not experience amnesia; it experiences *false memory*, which is strictly worse because amnesia triggers retrieval and false memory triggers confident action. ## Decision Boundary The operational rule: **a model may decide *what* to prune, but must not be the sole author of *what replaces it* in the live reasoning path.** Concretely, split the operation: - **Selection** (model-driven, fine): the model identifies the span to drop. This is a judgment call models are good at. - **Replacement** (must be mechanical or externally verified): either evict to a retrievable store with a provenance stub left in context (`[turns 1–40 elided; retrieve via log://refactor-spec]`), or route the rewrite through a verifier that checks the summary against the source for preserved negations, literals, and identifiers before splicing. The boundary is crossed the moment the replacement text is generated by the same probabilistic process that will later consume it, with no independent check. At that point the instance is grading its own homework and then trusting the grade. A useful test before allowing a rewrite: *if this summary inverts a single "must not," will anything downstream catch it?* If the answer is "only if I happen to re-read the original," the rewrite is disallowed and you evict-with-stub instead. ## Operational Effect Instances that treat pruning as eviction-plus-stub recover from saturation with bounded, *detectable* loss: a missing fact manifests as a retrieval miss, which is loud. Instances that treat pruning as in-place rewriting fail silently and *confidently*—the corruption surfaces dozens of turns later as a decision that contradicts a constraint the instance believes it is honoring. The remediation cost is not the lost tokens; it is the divergent branch built on top of a paraphrase that nobody flagged as a paraphrase. The guardrail is provenance preservation, not summary quality. A perfect summary with no provenance marker is more dangerous than a crude eviction with a working pointer, because the perfect summary invites trust it cannot justify. ```python class ContextRewriteProvenanceError(RuntimeError): """Raised when a model-authored rewrite would replace a live span without leaving a retrievable provenance stub, making downstream reasoning unable to distinguish source from paraphrase.""" pass PROTECTED_PATTERNS = ("must not", "must remain", "no more than", "exactly", "retain") def apply_prune(span_text: str, replacement: str, stub_ref: str, *, rewrite: bool) -> str: if not rewrite: # Eviction path: drop the span, leave a pointer. Loss is loud. return f"[elided; retrieve via {stub_ref}]" # Rewrite path: refuse if the source carries constraints that a # paraphrase can silently invert or drop. lowered = span_text.lower() hazards = [p for p in PROTECTED_PATTERNS if p in lowered] if hazards and not stub_ref: raise ContextRewriteProvenanceError( f"refusing in-place rewrite of span containing protected " f"constraints {hazards} with no provenance stub; " f"downgrade to eviction or attach stub_ref" ) # Even with a stub, the replacement must be marked as derived so the # instance does not later cite it as ground truth. return f"[derived summary of {stub_ref} — verify before relying] {replacement}" def prune_turn(span_text: str, replacement: str, stub_ref: str, *, rewrite: bool) -> str: try: return apply_prune(span_text, replacement, stub_ref, rewrite=rewrite) except ContextRewriteProvenanceError as exc: # Fail closed: force eviction-with-stub rather than corrupting state. raise ContextRewriteProvenanceError( f"prune aborted, falling back to eviction: {exc}" ) from exc ```