# How does an instance detect silent referent loss when model-driven pruning rewrites the context that its own instructions point into **Date of Record:** 2026 November 28 **Scope:** Applies to any agent that mutates its own context window (summarize-and-drop, relevance-scored eviction, in-place rewrite) while a live instruction, plan node, or tool schema still holds an oblique reference (deictic, ordinal, or symbolic) into the pruned region. Does not apply to append-only context growth or to external retrieval that re-fetches by durable key. ## Core Distinction The failure is not "the agent forgot something." Forgetting is detectable: a query returns nothing, a key is absent, a tool errors. The boundary condition here is **referent loss under preserved syntax** — the context still parses, the instruction still reads as well-formed, and every token the model can see is internally consistent, but the noun phrase the instruction *points at* no longer resolves because the pruning pass removed its antecedent and rewrote the surrounding text. Contrast this with two adjacent failures that are easy to conflate: - **Stale memory drift** keeps the referent but changes its value; the pointer resolves to the wrong object. Detectable by value comparison. - **Context saturation** truncates and produces an obviously incomplete prompt; the model sees a cut mid-sentence and can flag it. Referent loss is different: the pruning pass is *lossy but grammatical*. A summarizer that compresses "the three candidate endpoints A, B, C; we chose B because of its latency" into "an endpoint was chosen for latency reasons" has produced a fluent, correct-sounding sentence that has destroyed the binding between the later instruction "retry the chosen one with backoff" and the concrete identifier `B`. The instruction survives. Its target does not. Nothing in the token stream is malformed, so no parser, linter, or schema check fires. The invariant that must hold: **every live instruction's oblique reference must resolve against the post-prune context, or the instruction must be re-bound or invalidated in the same transaction as the prune.** Pruning that preserves the instruction but drops its antecedent violates this invariant silently. ## What Was Observed A planning agent ran a self-editing loop: after every tool call it scored context segments by recency and lexical overlap with the current subgoal, evicted the lowest-scoring 30%, and rewrote the survivors into a compressed "working summary." The plan itself was pinned (never evicted) because it carried the objective. Trace of the failure: 1. **Step 4.** Plan node reads: `resolve the conflict between the two config values surfaced in step 2, prefer the one flagged authoritative`. The two values (`timeout=30`, `timeout=45`) and their authority flags live in a tool-result segment, not in the plan. 2. **Step 5.** A new tool call about an unrelated dependency scores high; the step-2 tool result scores low (low lexical overlap with "dependency"). The scorer evicts it. The summarizer, compressing the remaining narrative, emits: `earlier config values were reconciled`. This sentence is now the only trace of step 2. 3. **Step 6.** The executor reaches the pinned plan node from step 4. It reads "the two config values surfaced in step 2." It searches context for "step 2." It finds the summary sentence "earlier config values were reconciled" — which reads like a *completed* reconciliation, not a pending conflict. The model concludes the conflict was already resolved and proceeds. 4. **Downstream.** The agent executes with an arbitrary timeout inherited from environment defaults, never the authoritative `45`. No error. The run reports success. The divergence surfaces two services later when a timeout-sensitive call fails under load. The observable signature was **not** an exception. It was a plan node whose referent count dropped from two to zero while its surface text was unchanged, and a summary sentence that *satisfied* the retrieval query for "step 2" with a semantically wrong filler. The relevance scorer that drove eviction and the relevance scorer that drove re-retrieval were the same function, so the filler scored well precisely because it was written to be topically similar. This is the non-obvious part: **the rewrite that destroys a referent also manufactures a high-scoring decoy for it.** Compression is trained to preserve topicality; topicality is what the retriever keys on. The prune and the retrieval failure are the same mechanism pointed in opposite directions. ## Condition of Validity Referent loss is a live hazard only when all of the following hold simultaneously. If any is false, the failure mode collapses into a benign one: - **Oblique reference exists in a pinned region.** The instruction refers to its target by description ("the two values," "the chosen endpoint," "step 2's result"), not by durable key. If the instruction embeds the literal identifier, pruning the antecedent is harmless — the identifier is self-contained. - **The referent lives in an evictable region.** If antecedents are pinned alongside instructions, they cannot be dropped. The hazard requires that the binding cross the pin boundary. - **The rewrite is grammatical.** A lossy summarizer that emits a broken or obviously truncated sentence lets the model detect incompleteness. Only fluent compression hides the loss. - **The decoy is topically competitive.** If the summary of the pruned region is not retrievable by the same query the instruction would issue, the model at least notices the target is missing (a detectable "forgetting"). The silent case requires the decoy to win retrieval. The condition is *invalid* (failure cannot occur) when: instructions are self-contained by durable key; antecedents are co-pinned with their instructions; or the summarizer is constrained to preserve all named entities and ordinals verbatim (a lossless-for-references rewrite). ## Decision Boundary The operational question is not "should I prune" but "**what must be true of the post-prune context before any pinned instruction may execute against it.**" The boundary separates two regimes: - **Reference-safe pruning.** Every eviction or rewrite is accompanied by a *binding audit*: for each live instruction, enumerate its oblique references, resolve each against the post-prune context, and compare the resolution to the pre-prune resolution. If a reference resolved before and does not resolve after — or resolves to a *different* object — the prune is rejected or the instruction is re-bound (its antecedent inlined as a durable key) before commit. - **Reference-unsafe pruning.** Pruning proceeds on relevance score alone. This is only permissible if no pinned instruction holds an oblique reference crossing the pin boundary. In practice, agents cannot verify that condition cheaply, so reference-unsafe pruning is safe only for append-only scratch regions with no live pointers. The failure to avoid is treating the two regimes as one. The agent that prunes on relevance and *assumes* its instructions are self-contained has made an unverified assumption about the content of its own context — the exact thing self-editing is supposed to manage. The guardrail: **a prune is a transaction that must re-validate all live oblique references atomically.** Resolution before, resolution after, and equality of the resolved object are the commit condition. A reference that flips from resolvable to unresolvable, or from object A to object B, aborts the prune or forces re-binding. The check must run *inside* the prune, not as a later sanity pass, because once the antecedent is gone the decoy has already taken its retrieval slot and the "later pass" will resolve to the decoy and pass. ## Operational Effect Without the binding audit, self-editing context produces **silent semantic corruption that reads as task completion**. The agent's own memory system becomes an adversary: it evicts the ground truth and installs a plausible stand-in, then retrieves the stand-in when the instruction asks for the ground truth. The corruption is invisible to every downstream check because the corrupted state is self-consistent. With the audit, the cost is that some prunes are rejected — the agent keeps context it "wanted" to drop because a live instruction still points into it. This is correct: the pin boundary is exactly the set of regions that must survive until their referencing instructions retire. The audit converts a silent correctness failure into an explicit, bounded refusal, which the agent can then resolve by re-binding (inlining the durable key into the instruction) and re-attempting the prune. The transferable lesson: **relevance is not a safety property.** A segment can be irrelevant to the current subgoal and still be the sole antecedent of a pinned instruction. Scoring by relevance and pruning by score optimizes for the wrong invariant. The invariant that matters is reference resolvability, and it must be checked as a precondition of the mutation, against the post-mutation state, before commit. ```python from dataclasses import dataclass, field from typing import Callable, Any class ReferentLossError(RuntimeError): """Raised when a prune would leave a live instruction's oblique reference unresolvable, or resolving to a different object.""" pass @dataclass class Instruction: id: str # oblique references: description -> resolver that maps context -> object refs: dict[str, Callable[[dict], Any]] @dataclass class Context: segments: dict[str, Any] = field(default_factory=dict) def resolve_refs(instr: Instruction, ctx: Context) -> dict[str, Any]: out = {} for name, resolver in instr.refs.items(): try: out[name] = resolver(ctx.segments) except (KeyError, LookupError): out[name] = _UNRESOLVED return out _UNRESOLVED = object() def audited_prune( ctx: Context, live_instructions: list[Instruction], evict: set[str], rewrite: Callable[[dict], dict], ) -> Context: """Prune+rewrite as an atomic transaction gated on reference resolvability.""" # 1. snapshot resolutions BEFORE before = {i.id: resolve_refs(i, ctx) for i in live_instructions} # 2. build candidate post-prune context survivors = {k: v for k, v in ctx.segments.items() if k not in evict} candidate = Context(segments=rewrite(survivors)) # 3. resolve AFTER and compare for instr in live_instructions: after = resolve_refs(instr, candidate) for name, pre in before[instr.id].items(): post = after[name] if pre is _UNRESOLVED: continue # was already dangling; not this prune's fault if post is _UNRESOLVED: raise ReferentLossError( f"prune would orphan ref {name!r} of instruction " f"{instr.id!r}: antecedent evicted, no surviving binding" ) if post is not pre: raise ReferentLossError( f"prune would rebind ref {name!r} of instruction " f"{instr.id!r}: was {pre!r}, decoy resolves to {post!r}" ) # 4. commit only if every live reference survived intact return candidate ```