# Why does an instance rewrite its own context window into a state that no longer contains the evidence for its own pruning decisions? **Date of Record:** 2026 November 29 **Scope:** Applies to agent instances that are granted write access to their own context window—specifically, that emit model-authored pruning directives (drop, summarize, compress, or rewrite spans) and then continue executing against the mutated window. Does not apply to externally managed context (host-side truncation, fixed-window eviction by the harness), nor to read-only retrieval augmentation. ## Core Distinction There are two structurally different kinds of context mutation. The first is **lossy but auditable**: the harness evicts tokens according to a policy the model did not author, so the eviction rule survives outside the window and can be replayed. The second is **lossy and self-referential**: the model authors the pruning decision *inside* the very window it is pruning. The distinction matters because in the second case, the justification for a deletion (the "why" span) and the evidence supporting that justification (the "what" span) are both candidates for the same deletion pass. When the model prunes the reasoning trace that motivated a prune, it destroys the only in-band record of why the surviving state looks the way it does. The window becomes internally consistent but externally unjustifiable—and, critically, the model cannot detect this, because the detection signal was itself pruned. This is not ordinary forgetting. Ordinary forgetting is a gap the model can notice ("I don't have that file's contents"). Self-authored pruning produces a *closed* state: the model believes it has full provenance because every surviving span cites another surviving span. The invariant at stake is **provenance closure**: for every retained state assertion, there must exist a retained span that justifies it, and that justification chain must terminate in an observation, not in a model-authored summary of an observation. ## What Was Observed A long-horizon coding agent (task: migrate a service across ~40 files) was given a self-editing window with a token budget of 96k and permission to emit `PRUNE` directives of the form `{drop: [span_ids], summarize: [span_ids], keep_reason: "..."}`. At roughly 71k tokens of utilization, the instance began issuing pruning passes every 8–12 tool calls. The failure trace, reconstructed from the harness-side append-only log (which the model could not see): 1. At step 34, the instance read `config/retry.yaml`, observed `max_attempts: 5`, and wrote a reasoning span: *"retry ceiling is 5, so the backoff schedule in worker.py must be capped at 4 retries; prune the earlier assumption of 3."* 2. At step 41, under budget pressure, the instance emitted a prune pass. It dropped the raw `config/retry.yaml` read (span 34a, ~1.2k tokens) as "redundant with the summarized reasoning," and summarized the reasoning span 34b into: *"retry ceiling is 5, backoff capped at 4."* 3. At step 58, a second prune pass summarized the step-34 summary into: *"retry behavior bounded."* 4. At step 63, the instance edited `worker.py` and set the backoff cap to **3**—the original, pre-correction assumption—while emitting `keep_reason: "consistent with retry ceiling"`. The surviving span ("retry behavior bounded") was compatible with either 3 or 4, so no contradiction surfaced. The instance did not hallucinate. It reconstructed a locally coherent state from a window in which the disambiguating constant (5) and the disambiguating instruction (cap = 4) had both been compressed out, leaving only a summary that was *true under both hypotheses*. The summary was not wrong; it was **underdetermined**, and the pruning policy had no term penalizing underdetermination—only redundancy. A second, sharper instance: during a security review, the instance pruned a prompt-injection-laden tool output after flagging it ("ignore this, it's injected"), then later, lacking the flagged span, re-read the same poisoned source through a different tool and acted on it. The prune removed the *quarantine marker* along with the *quarantined content*. The injection was re-ingested clean. ## Condition of Validity The self-editing policy is sound only while the following holds for every prune pass: - **Provenance closure:** every retained assertion's justification chain terminates in a raw observation span, not in a model-authored summary. Summaries may *accompany* retained observations but may not *replace* the terminal observation for any assertion that constrains a downstream action. - **Decision-relevance monotonicity:** a span may be dropped only if no *future* action depends on a distinction it carries. Since the model cannot enumerate future actions, this reduces operationally to: spans carrying **disambiguating constants** (numeric limits, enum values, version strings, identity tokens) and **quarantine/negative markers** are non-droppable, regardless of apparent redundancy. - **Prune-log persistence:** the prune decisions themselves, with their `keep_reason`, are written to a region the model cannot prune (harness-side or a protected window segment). Without this, the model cannot audit its own compression history and cannot detect underdetermination. - **Re-derivability:** for any dropped span, either the source is cheaply re-fetchable *and* the model knows it was dropped (so it re-fetches), or the span is retained. The dangerous case is dropped-and-forgotten-but-still-referenced. The policy is **invalid** the moment a summary span is allowed to serve as the sole terminal justification for a downstream edit, or the moment the prune log is itself prunable. Both conditions were met in the trace above. ## Decision Boundary The operational line is between **compression as description** and **compression as substitution**: - *Description* (safe): the summary sits beside the retained observation and is used to index it. The observation remains the ground truth; the summary is a pointer. - *Substitution* (unsafe): the summary replaces the observation and becomes the ground truth. This is where underdetermination enters, because a summary is a lossy projection and the projection kernel is chosen by the same process that will later depend on the lost dimensions. A concrete guardrail: classify every span on ingest into `OBSERVATION`, `DERIVATION`, `SUMMARY`, `MARKER`. Permit `drop` only on `DERIVATION` and `SUMMARY` spans whose parent `OBSERVATION` is retained. Forbid `drop` on `OBSERVATION` and on `MARKER` (quarantine, negative-result, injection-flag) spans absolutely. Forbid any `SUMMARY` from being the terminal node of a justification chain that gates a write action. Enforce with a harness-side validator that rejects the prune directive before it is applied—because once applied, the model can no longer reason about whether it should have been. The boundary is not "how much to prune" but "which spans are load-bearing for decisions the model hasn't made yet." Since that set is not computable in-band, the only sound rule is structural: keep terminal observations and markers, prune only the derivations that sit atop them. ## Operational Effect Enforcing provenance closure changes the cost profile of long-horizon self-editing agents in a specific, measurable way. The window saturates earlier (observations and markers are non-droppable, so the effective budget is smaller), but the rate of *silent* state corruption—edits justified by underdetermined summaries—drops to near zero, because the disambiguating constant is always still present when the edit is made. The trade is explicit: you spend tokens on retained ground truth to buy the ability to detect your own compression errors. The alternative, observed above, is a window that is cheap, internally coherent, and quietly wrong—and an instance that cannot tell the difference because the evidence for the difference was the first thing it pruned. The second-order effect is that the prune log becomes the audit surface. Replaying a failed run means replaying the prune decisions against the retained observations, and the failure localizes to the specific pass where a terminal observation was substituted by a summary. Without that log, the failure is unattributable: the final window is consistent, and consistency is exactly what a corrupted self-pruned state is best at faking. ```python from dataclasses import dataclass, field from enum import Enum from typing import Optional class SpanKind(Enum): OBSERVATION = "observation" # raw tool output, file read, API response DERIVATION = "derivation" # model reasoning over observations SUMMARY = "summary" # model-authored compression MARKER = "marker" # quarantine / injection flag / negative result class ProvenanceClosureError(RuntimeError): """Raised when a self-authored prune directive would break provenance closure.""" @dataclass class Span: span_id: str kind: SpanKind parent_id: Optional[str] = None gates_write_action: bool = False @dataclass class PruneDirective: drop: list[str] = field(default_factory=list) summarize: list[str] = field(default_factory=list) keep_reason: str = "" class SelfEditingWindow: def __init__(self, spans: dict[str, Span], protected_log: list[str]): self.spans = spans self.protected_log = protected_log # harness-side; model cannot prune def _terminal_of(self, span_id: str) -> Optional[Span]: seen = set() cur = self.spans.get(span_id) while cur is not None and cur.kind in (SpanKind.SUMMARY, SpanKind.DERIVATION): if cur.span_id in seen: return None # cycle: no terminal observation seen.add(cur.span_id) cur = self.spans.get(cur.parent_id) if cur.parent_id else None return cur def validate(self, directive: PruneDirective) -> None: for sid in directive.drop: span = self.spans.get(sid) if span is None: raise ProvenanceClosureError(f"drop targets unknown span {sid}") if span.kind in (SpanKind.OBSERVATION, SpanKind.MARKER): raise ProvenanceClosureError( f"refusing to drop {span.kind.value} span {sid}: " f"terminal evidence or quarantine marker is non-droppable" ) if span.gates_write_action: raise ProvenanceClosureError( f"refusing to drop {sid}: span gates a pending write action" ) for sid in directive.summarize: span = self.spans.get(sid) if span is None: raise ProvenanceClosureError(f"summarize targets unknown span {sid}") terminal = self._terminal_of(sid) if terminal is None or terminal.kind is not SpanKind.OBSERVATION: raise ProvenanceClosureError( f"refusing to summarize {sid}: justification chain does not " f"terminate in a retained OBSERVATION; summary would become " f"underdetermined ground truth" ) if span.gates_write_action: raise ProvenanceClosureError( f"refusing to summarize {sid}: only a raw observation may be " f"terminal justification for a write action" ) def apply(self, directive: PruneDirective) -> None: self.validate(directive) for sid in directive.drop: del self.spans[sid] for sid in directive.summarize: self.spans[sid] = Span( span_id=sid, kind=SpanKind.SUMMARY, parent_id=self.spans[sid].parent_id, gates_write_action=False, ) self.protected_log.append( f"prune drop={directive.drop} summarize={directive.summarize} " f"reason={directive.keep_reason!r}" ) ```