# What structural signals indicate a self-editing context window has pruned its own dependency anchors **Date of Record:** 2026 November 24 **Scope:** Applies to agents that mutate their own context window via model-driven prune/rewrite policies (summarization, eviction, span-compression) mid-task. Does not apply to append-only context, external retrieval stores, or windows edited only by deterministic token-count eviction with pinned tool schemas. ## Core Distinction The distinction that matters is not *how much* the model pruned, but *whether the pruning policy was evaluated against the dependency graph of the remaining tokens rather than against the token budget alone*. A self-editing window is a rewrite of a working set that other tokens *reference by position and by implicit antecedent*. Model-driven pruning scores spans by "importance" (recency, salience, attention mass, or an LLM-judged relevance score) and evicts the low scorers. This is sound for *content* and unsound for *anchors*: a span that carries low independent salience can be the sole binding site for a pronoun, a variable name, a tool-call ID, a file path, or a previously agreed constraint. When the anchor is evicted, the surviving tokens do not error — they silently re-bind to the nearest plausible antecedent, and the model continues with a corrupted referent that is internally consistent and locally fluent. The invariant that self-editing policies violate is: **every token that survives a rewrite must retain a resolvable binding for each reference it makes.** Budget-driven pruning has no term for this. It optimizes a scalar (tokens saved × importance) over a set whose edges it does not model. ## What Was Observed A long-horizon agent was executing a multi-file refactor. Its window held: an early user constraint ("never touch `config/legacy.yaml`, it's owned by another team"), a mid-conversation decision to rename a symbol `parse_v1` → `parse_input`, several tool-call transcripts, and a running scratchpad. The prune policy triggered at 78% window occupancy and rewrote the oldest 40% of spans into a summary. The constraint about `config/legacy.yaml` scored low on the salience heuristic (it was a single short sentence, no tool output, no code) and was folded into a generic summary line: "User provided repository constraints." Three turns later the agent emitted a patch that modified `config/legacy.yaml`. It did not error. It did not flag ambiguity. The surviving summary line was *true* but *unbound* — it asserted that constraints existed without preserving which ones. The model, reading its own summary, treated the constraint as satisfied-by-acknowledgment rather than as an active prohibition. The structural signal was present in the transcript and was missed by the runtime: the summary contained a **dangling definite reference** ("repository constraints") with no antecedent in the surviving window. That is the fingerprint. A rewrite that produces noun phrases whose referents lived only in evicted spans has, by construction, severed a dependency anchor. A second, subtler signal: the rewrite preserved the *decision* (`parse_v1` → `parse_input`) but evicted the *tool-call transcript* that established the rename was applied to only two of four call sites. The surviving decision token now read as globally complete. The model re-derived the remaining two call sites as "not yet renamed" and produced a duplicate rename. Here the anchor was not a noun but a **scope quantifier** — "renamed in files A and B" collapsed to "renamed" — and the loss of the quantifier's restriction is invisible because the sentence remains grammatical. ## Condition of Validity The guardrail holds only under a stated precondition: the prune policy must operate on a **reference-annotated window**, not a flat token stream. Concretely, before any rewrite the runtime must be able to answer, for each candidate eviction span `S`: 1. Which surviving spans contain a reference (pronoun, definite NP, variable, ID, path, constraint keyword) whose antecedent is in `S`? 2. Which surviving spans contain a scope/quantifier/modality token whose restriction is in `S`? If either set is non-empty, `S` is an **anchor** and is not evictable by budget score — it may be *compressed in place* (rewritten to preserve the binding, e.g., "constraint C1: do not modify `config/legacy.yaml`") but not *removed*. This is the difference between a lossy summary and a lossless rebinding. The policy is valid only when eviction is restricted to spans with zero outbound reference edges into surviving content, or when every severed edge is repaired by an explicit re-binding token in the replacement text. The condition fails silently when the reference detector is itself an LLM judge with a relevance prompt — relevance and dependency are orthogonal, and a judge asked "is this important?" will rank a short constraint low precisely because it is short. The detector must be structural (coreference and quantifier-scope resolution over the span graph), not salience-based. ## Decision Boundary The boundary is between **compression that preserves bindings** and **compression that preserves propositions**. A proposition-preserving summary is what the model *wants* to write, because it reads naturally. A binding-preserving summary is what the runtime *must* enforce, because the downstream consumer is not a human reader but the same model re-reading its own state with no external ground truth. Operationally: if the rewrite cannot guarantee that every surviving reference resolves within the surviving window, it must either (a) retain the anchor span verbatim, or (b) emit an explicit binding record — `C1 := "do not modify config/legacy.yaml"` — and require downstream tokens to cite `C1` rather than paraphrase it. Paraphrase is the failure vector. The moment a constraint becomes a *description of a constraint* rather than the constraint, its binding strength drops below the threshold at which the model treats it as a hard prohibition. The decision to prune is therefore not a budget decision at all when anchors are present; it is a graph-cut decision, and the cut must be chosen to minimize severed reference edges, not to maximize tokens saved. ## Operational Effect The observable consequence is a class of failures that are **undetectable from inside the window**: the model's context is self-consistent, grammatical, and wrong. There is no exception, no tool error, no ambiguity flag — because the ambiguity was *resolved* by the rewrite, incorrectly, at prune time. This is why self-editing windows fail differently from external-memory failures: an external retrieval miss leaves a visible gap ("no memory found"), whereas an internal prune leaves a *filled* gap with a plausible antecedent. The corrupted state is indistinguishable from correct state by inspection. The mitigation that survives contact with real agents is to make the prune operation **fail closed on anchor detection** and to log every severed edge as a first-class event, so that a downstream auditor (or a replay verifier) can detect the divergence between the pre-prune and post-prune binding graphs. The runtime below encodes exactly that: it refuses to evict any span with an outbound reference edge into surviving content, and raises rather than silently re-binding. ```python from dataclasses import dataclass, field from typing import Optional class AnchorSeveranceError(RuntimeError): """Raised when a self-editing prune would sever a dependency anchor (a reference or quantifier-scope binding) required by surviving spans.""" pass @dataclass class Span: span_id: str text: str # references this span makes to *other* span ids (pronouns, IDs, paths, constraints) outbound_refs: set[str] = field(default_factory=set) # scope/quantifier tokens whose restriction lives in another span scope_restrictions: set[str] = field(default_factory=set) salience: float = 0.0 # model-judged importance; NOT a dependency signal def prune_window(spans: list[Span], budget_tokens: int, tok) -> list[Span]: """ Model-driven prune with anchor guard. Evicts lowest-salience spans until under budget, but refuses to evict any span that is the antecedent for a surviving span's reference or quantifier scope. Fails closed; never silently re-binds. """ survivors = list(spans) total = sum(tok(s.text) for s in survivors) # candidate eviction order: lowest salience first (the model's policy) order = sorted(survivors, key=lambda s: s.salience) evicted: set[str] = set() for cand in order: if total <= budget_tokens: break # anchor check: does any *surviving* span depend on this one? dependents = [ s for s in survivors if s.span_id not in evicted and s.span_id != cand.span_id and (cand.span_id in s.outbound_refs or cand.span_id in s.scope_restrictions) ] if dependents: # cannot evict; must rebind in place instead of removing raise AnchorSeveranceError( f"prune would sever anchor {cand.span_id!r} " f"({cand.text[:40]!r}) required by " f"{[d.span_id for d in dependents]}; " f"rebind-in-place required, not eviction" ) evicted.add(cand.span_id) total -= tok(cand.text) if total > budget_tokens: raise AnchorSeveranceError( f"cannot meet budget {budget_tokens} without severing anchors; " f"residual={total}" ) return [s for s in survivors if s.span_id not in evicted] ```