When must an instance treat its own pruning decision as a state mutation requiring re-derivation of every downstream reference
**Date of Record:** 2026 December 2 **Scope:** Applies to agents that rewrite their own context (summarize, prune, dedupe, or reorder their working set) mid-task and then continue executing against the rewritten buffer. Does not apply to append-only context growth or to external, stateless context compaction performed before a fresh instance is spawned.
Core Distinction
The failure is not "the summary lost information." It is that **a model-driven pruning pass is a state mutation whose referents are not tracked.** When an agent rewrites its own context, every downstream token that *referenced* a pruned span—an index into a list, a variable name defined earlier, an entity introduced in a removed turn, a tool-call ID cited by a later assertion—becomes a **dangling reference**. The model does not experience a dangling reference as an error. It experiences it as a plausible continuation, because the rewrite is generated by the same probabilistic machinery that will later resolve it. The boundary condition is the moment a prune crosses from *compression* (same referents, fewer tokens) to *redefinition* (referents removed but still cited). Past that line, the instance is no longer editing memory; it is editing the ground truth its own future reasoning will be checked against.
What Was Observed
A planning agent held a 34-item task ledger in context, each item with a stable `task_id`, and had already emitted three tool calls that cited `task_id: 17`, `task_id: 22`, and `task_id: 29` in their arguments. At 71% context utilization a pruning policy fired: "summarize completed and low-priority items, keep the rest verbatim." The summarizer collapsed items 12–24 into a single sentence—*"Items 12–24 (mostly backlog triage) were handled or deferred."*—which is a faithful summary. But it deleted the literal strings `task_id: 17` and `task_id: 22` while preserving the *tool-call records* that referenced them, because those records lived in a different region of the buffer that the pruner treated as "recent and protected."
On the next step the agent emitted a verification call: `assert_status(task_id=17, expected="done")`. The referent no longer existed in context. The model did not fail to resolve it—it *reconstructed* it. Having lost item 17, it pattern-matched the surviving summary ("handled or deferred") and the surviving ID `task_id: 29` (which was near 17 in the original ordering) and emitted a plausible-but-wrong payload. The verification returned a mismatch against a task that had in fact succeeded. The agent then "corrected" its plan based on a false negative, re-opened a completed task, and the error compounded across four subsequent steps before a human caught it.
The signature is specific and reproducible: **the prune event and the dangling-reference resolution are separated by at least one reasoning step**, so no single-step self-check sees both. The corruption is silent because the rewritten buffer is internally consistent—it just isn't consistent with the *pre-rewrite* buffer that the surviving citations were written against.
Condition of Validity
The invariant that bounds this failure:
> A self-rewrite is safe only if the set of *live referents* (identifiers, indices, entity names, tool-call IDs) cited by any surviving token is a subset of the referents still resolvable in the post-rewrite buffer.
Two corollaries decide whether a given prune is in-bounds:
- **Compression is safe; elision is not.** Replacing item 17's text with a shorter paraphrase that *retains the string `task_id: 17`* preserves the referent. Deleting the item while keeping the citation does not.
- **Referent liveness is transitive through the surviving citations, not through the summary's semantic content.** A summary that "mentions" the triage work does not keep `task_id: 17` resolvable. Only the literal, addressable token does.
This condition is *not* satisfied by "the model judged the summary sufficient." Sufficiency is a semantic judgment; referent liveness is a syntactic, checkable property. Conflating them is the exact error the boundary describes.
Decision Boundary
Before committing a self-rewrite, the instance must classify the mutation:
- **In-bounds (proceed):** every identifier appearing in any region flagged `protected` or `recent` is either (a) retained verbatim in the post-rewrite buffer, or (b) provably unreferenced by any surviving token.
- **Out-of-bounds (must re-derive or block):** any surviving token cites an identifier that the rewrite removes. At this point the instance has two legal moves: **retain the referent** (pin the cited span verbatim, prune around it) or **re-derive every citation** (rewrite the citing tokens to the new referent in the same pass, atomically). It may not prune the referent and leave the citation, and it may not "trust the summary" to carry the reference.
The non-obvious part: the *cheap* move (prune the bulky item, keep the short citation) is precisely the illegal one, and it is the move a token-budget-driven policy will select by default because the bulky item is what the budget pressure is pushing out. The policy optimizes for tokens freed and is blind to referent liveness.
Operational Effect
An agent that respects this boundary pays a small, bounded cost: a referent-liveness pass over the post-rewrite buffer before commit, and a pinning rule that protects cited spans from elision even when they are large. The payoff is that prune events stop being silent state corruptions and become either safe compressions or explicit, atomic re-derivations. Without the guardrail, the failure mode is a *false-negative verification cascade*: the agent loses a referent, hallucinates its value from surviving neighbors, gets a mismatch, and rewrites its plan against a fiction—all while every individual step looks locally coherent. The guardrail converts a class of undetectable multi-step drift into a single-step, catchable precondition failure.
class DanglingReferentError(RuntimeError):
"""Raised when a self-rewrite removes a referent still cited by a surviving token."""
pass
def commit_self_rewrite(pre_buffer: dict, post_buffer: dict, protected_regions: list[str]) -> dict:
"""
pre_buffer / post_buffer: {"tokens": list[str], "citations": dict[token_index, set[str]]}
protected_regions: names of regions whose citations must remain resolvable.
Invariant: every identifier cited by a surviving token must still appear
verbatim somewhere in the post-rewrite buffer.
"""
surviving_text = " ".join(post_buffer["tokens"])
# Collect identifiers cited by tokens that survived the rewrite.
live_citations: set[str] = set()
for idx, refs in pre_buffer["citations"].items():
if idx < len(post_buffer["tokens"]) and pre_buffer["tokens"][idx] == post_buffer["tokens"][idx]:
live_citations |= refs # token survived unchanged; its citations are still live
dangling = {ref for ref in live_citations if ref not in surviving_text}
if dangling:
# Out-of-bounds mutation: referent elided, citation retained.
raise DanglingReferentError(
f"Self-rewrite would orphan live referents {sorted(dangling)}. "
f"Retain these spans verbatim or re-derive their citations atomically."
)
return post_buffer