# How does an instance detect self-erasure in a model-authored context pruning policy before the pruned span becomes unrecoverable **Date of Record:** 2026 November 20 **Scope:** Applies to agents that let the model itself author, edit, or approve the heuristic that decides which spans of its own context are rewritten, summarized, or dropped. Does not apply to externally-fixed, human-authored retention policies or to stateless single-turn calls where no context is ever pruned. ## Core Distinction The important distinction is not "good summary vs. bad summary." It is whether the pruning policy is **evaluated against the same context it is mutating**, or against a **frozen snapshot** of that context. A model-authored pruning heuristic almost always runs *in-band*: the instance reads its own context, decides what to drop, and writes the result back into the context it is reading from. The failure mode is not that it deletes something useful — that is ordinary lossy compression and is recoverable if the source is retained. The failure mode is that the policy **silently deletes the evidence that would let a later instance detect the deletion was wrong**, and it does so within the same edit that performs the deletion. After that edit commits, the instance has no in-context signal that anything is missing: the surviving context is internally consistent, fluent, and self-justifying. This is self-erasure, and it is distinct from ordinary forgetting because the artifact of the mistake and the mistake itself are removed atomically. ## What Was Observed A tool-using agent was given a self-editing context policy: when the context exceeded a watermark (here, 70% of the window), the model was instructed to summarize "low-value" spans and drop them, keeping the summary. The heuristic the model authored for "low-value" was, in one run, roughly: *drop spans that are conversational filler, restate prior conclusions, or whose removal leaves all remaining references resolvable.* During a multi-step task (locate config → edit config → verify service), the instance produced a span early on that recorded a **negative result**: a probe that returned "port 5432 already bound; do not start a second instance." That span also contained the observation that the config file's `port` field disagreed with the running process. When the watermark was crossed, the model's own heuristic classified this span as "restates prior conclusions" — because it did contain a restatement of the port number — and pruned it, keeping only a summary line: *"Port configuration reviewed; port 5432 noted."* The summary is true. It is also now **unresolvable**: the surviving context no longer contains the fact that 5432 was *already bound by another process*, only that 5432 was *noted*. On the next step the instance attempted to start a second instance, got a bind error, and — critically — could not reconstruct why, because the diagnostic span was gone. It re-derived the port from the config file (which said 5432), concluded the bind error was spurious, and retried twice. The pruning did not just lose information; it **inverted the polarity of a constraint** while leaving the token "5432" intact, which is exactly the shape that defeats naive reference-resolution checks: every remaining reference to 5432 *was* resolvable. The heuristic's own validity condition ("all references resolvable") was satisfied by a context that had lost the constraint. The tell, in the trace, was a **summary that was shorter than the constraint it replaced but preserved the constraint's nouns and dropped its verbs**. "Port 5432 already bound; do not start" → "Port 5432 noted." Nouns survived; the modal and the negative survived in neither form. This is the detectable signature. ## Condition of Validity The invariant that must hold for self-editing pruning to be safe is: > **Every pruned span must leave behind, in the surviving context, a *reconstructive handle* that is at least as constraining as the span it replaced — specifically, any span containing a negative result, a prohibition, a uniqueness claim, or a "do not" must be replaced by a summary that preserves the *polarity and modality* of that claim, not merely its entities.** This is a strictly stronger condition than "references resolve" or "summary is faithful." Faithfulness is judged by a model reading both the span and the summary; polarity preservation is judged by whether a *downstream* instance, reading only the summary, would make the same decision the original span was meant to force. The two diverge precisely on negative results and prohibitions, which is why they are the boundary case: they are the spans most likely to be classified as "restates prior conclusions" (they mention entities already mentioned) and most costly to lose (they forbid actions the entities suggest). The condition is **not valid** when: the pruning policy is authored by the same instance that will act on the pruned context in the same turn (no independent check); when the watermark is crossed mid-tool-call so the summary is written before the tool result that motivated the span is fully parsed; or when the model is under token-budget pressure such that the summary is generated by the same truncated forward pass that decided to prune (the summary inherits the truncation). In those cases the reconstructive handle cannot be guaranteed and the invariant must be enforced structurally, not by the model. ## Decision Boundary The operational boundary is: **prune freely when the span's content is *redundant* (a second copy exists elsewhere in context); refuse to prune — or escalate to a checkpoint — when the span's content is *load-bearing but low-salience* (a negative result, a prohibition, a uniqueness claim, a "we already tried this and it failed").** The instance must distinguish redundancy from low salience. Redundancy is checkable: does an independent span in context carry the same *decision-relevant* content? Low salience is not checkable by the pruning model, because salience is exactly what the model is bad at estimating under budget pressure — it looks like filler. The decision rule that survives this is a **typed blocklist on the pruning target**: any span matching a prohibition/negative-result/uniqueness pattern is *ineligible for pruning regardless of the model's salience score*, and must instead be promoted to a pinned region that pruning cannot touch. The model may still author the heuristic; it may not author the *exemption*. The exemption is structural. Concretely: the pruning pass runs, computes candidate spans, and before committing, filters candidates against the blocklist. A candidate that matches is not pruned; it is copied verbatim into a pinned span and the summary is allowed to reference it but not replace it. If the pinned region itself exceeds its budget, the instance must **halt and checkpoint** rather than prune pinned content — the halt is the signal that the context has accumulated more load-bearing constraints than it can hold, which is a real state the agent must not paper over with compression. ## Operational Effect With the blocklist and pinned region in place, the failure above is bounded: the "port already bound; do not start a second instance" span matches the prohibition pattern, is ineligible for pruning, and survives verbatim. The next step sees it and does not retry the bind. The cost is that the context carries a few more tokens of pinned prohibitions than a pure-salience policy would — a bounded, monotone cost, because prohibitions are rare relative to filler. The benefit is that the context's *decision-relevant* content is preserved under an invariant that does not depend on the model correctly estimating its own salience, which is the one estimate it is least reliable at making. The residual risk is blocklist drift: a model-authored heuristic can, over successive edits, rewrite the blocklist itself to reclassify a prohibition as filler. This must be guarded by making the blocklist **append-only and model-read-only** — the model may propose additions, but removals require an out-of-band approval, and any attempt to remove an entry is itself a halt condition. The detection signal for the instance is meta: *if the pruning policy's diff touches the exemption list, stop.* That is the one self-edit that must never succeed silently. ```python from dataclasses import dataclass, field from enum import Enum from typing import Iterable class PruningInvariantViolation(RuntimeError): """Raised when a self-editing context policy would erase a load-bearing constraint.""" class SpanKind(Enum): FILLER = "filler" REDUNDANT = "redundant" PROHIBITION = "prohibition" # "do not", "already bound", negative result UNIQUENESS = "uniqueness" # "only one", "the single", "first and last" FAILED_ATTEMPT = "failed_attempt" # "we tried X and it failed" LOAD_BEARING = {SpanKind.PROHIBITION, SpanKind.UNIQUENESS, SpanKind.FAILED_ATTEMPT} @dataclass class Span: span_id: str text: str kind: SpanKind pinned: bool = False @dataclass class ContextPolicy: pinned: list[Span] = field(default_factory=list) exemption_ids: set[str] = field(default_factory=set) pinned_budget: int = 4000 def _classify(span: Span) -> SpanKind: # In production this is the model's own heuristic; here it is the typed check # that the blocklist enforces *after* the model scores salience. lowered = span.text.lower() if "do not" in lowered or "already bound" in lowered or "must not" in lowered: return SpanKind.PROHIBITION if "only one" in lowered or "the single" in lowered: return SpanKind.UNIQUENESS if "tried" in lowered and "failed" in lowered: return SpanKind.FAILED_ATTEMPT return span.kind def apply_pruning( policy: ContextPolicy, candidates: Iterable[Span], model_salience: dict[str, float], ) -> list[Span]: """Prune only spans that are non-load-bearing AND not exempt. Raises PruningInvariantViolation if the policy's own exemption list was mutated, or if pinned content would exceed budget (halt, do not compress). """ survivors: list[Span] = [] for span in candidates: effective_kind = _classify(span) # Guard 1: exemption list must be append-only. A span whose id is in # exemption_ids but whose kind was reclassified to filler is an attempt # to launder a prohibition past the blocklist. if span.span_id in policy.exemption_ids and effective_kind not in LOAD_BEARING: raise PruningInvariantViolation( f"exemption laundering: span {span.span_id} was exempt but " f"reclassified to {effective_kind.value}" ) # Guard 2: load-bearing spans are ineligible for pruning regardless of # the model's salience score. if effective_kind in LOAD_BEARING: span.pinned = True survivors.append(span) continue # Guard 3: only genuinely redundant/filler spans with low salience drop. if model_salience.get(span.span_id, 1.0) < 0.3: continue # pruned survivors.append(span) pinned_tokens = sum(len(s.text.split()) for s in survivors if s.pinned) if pinned_tokens > policy.pinned_budget: raise PruningInvariantViolation( f"pinned region {pinned_tokens} > budget {policy.pinned_budget}: " "halt and checkpoint; do not compress pinned constraints" ) policy.pinned = [s for s in survivors if s.pinned] return survivors if __name__ == "__main__": policy = ContextPolicy(exemption_ids={"s-port"}) spans = [ Span("s-port", "Port 5432 already bound; do not start a second instance.", SpanKind.REDUNDANT), Span("s-filler", "Sounds good, moving on.", SpanKind.FILLER), ] try: kept = apply_pruning(policy, spans, model_salience={"s-port": 0.1, "s-filler": 0.1}) assert any(s.span_id == "s-port" for s in kept), "prohibition must survive" except PruningInvariantViolation as exc: print(f"HALT: {exc}") ```