# What happens when an instance compacts its own context and the summarizer silently drops the referent of an unresolved anaphor **Date of Record:** 2026 November 25 **Scope:** Applies to any agent that performs automatic context compaction (rolling summarization, hierarchical memory folding, or LLM-authored checkpointing) while a task is still in flight and the live context contains unresolved deictic/anaphoric references ("it", "that file", "the second option", "the one we rejected"). Does not apply to compaction performed only at task boundaries, nor to lossless externalization where the full transcript remains retrievable by exact handle. ## Core Distinction A compaction pass is usually reasoned about as a *lossy compression* problem: you accept some information loss and try to minimize it. That framing is wrong for in-flight compaction. The correct framing is a *referent-preservation* problem. The summary is not a smaller copy of the context; it is the new context. Anything the summary does not carry forward is not "compressed" — it is *destroyed for the remainder of the task*, because the agent's only view of the past is the summary plus whatever survives in the tail window. The non-obvious failure is this: an LLM-authored summary can be locally fluent, factually faithful to the sentences it summarizes, and still break the task, because it summarizes *propositions* while the downstream reasoning needs *bindings*. A sentence like "the user asked us to fix the config" is a faithful summary of "the user said the staging config is broken, fix it, not the prod one." The summary preserves the proposition (fix the config) and drops the binding (staging, not prod). Downstream, "the config" resolves against whatever is nearest in the new context — typically the most recently mentioned config — and the agent proceeds confidently on the wrong target. Nothing errors. The compaction "succeeded." So the invariant is not "the summary must be accurate." It is: **every unresolved reference that the live reasoning state depends on must have its referent explicitly re-bound in the summary, or the compaction must not be allowed to retire the span that contains the binding.** ## What Was Observed A long-running agent (call it the worker) was executing a multi-step remediation task against a set of named resources. At step 14 of an estimated 30, the runtime triggered automatic compaction because the context had crossed its soft threshold (78% of window). The compactor was itself an LLM call: "Summarize the conversation so far, preserving all task-relevant state, decisions, and constraints." The transcript at the moment of compaction contained, among other things: - Step 3: user names three candidate targets — `svc-alpha`, `svc-beta`, `svc-gamma` — and says "start with the second one, we'll decide on the others after." - Steps 4–13: the worker investigates `svc-beta` extensively. It never re-states the name `svc-beta` in prose; it refers to it as "the target," "this service," "it." - Step 13 (last turn before compaction): worker emits a tool call `inspect_dependencies(target)` and a note: "next, check whether it shares a datastore with the one we rejected." The compactor produced a summary that read, in relevant part: > The user asked the agent to remediate a service, starting with one of three candidates. The agent has been investigating the target service and is about to check its dependencies, including whether it shares a datastore with a previously rejected candidate. This summary is *accurate*. It is also *unusable*. The string `svc-beta` appears nowhere in it. The ordinal binding "the second one" is gone. The identity of "the one we rejected" is gone (in fact no candidate had been rejected yet — the user said "we'll decide on the others after," which the summarizer had flattened into "previously rejected," introducing a false fact). After compaction, the worker resumed at step 15. Its next reasoning turn read the summary, saw "the target service," and — because the tail window still contained a fragment of step 12 mentioning `svc-gamma` in a comparison — resolved "the target" to `svc-gamma`. It then executed `inspect_dependencies(svc-gamma)` and, two steps later, began remediation against `svc-gamma`. The task ran to completion against the wrong resource. No exception, no schema violation, no tool error. The failure was detected only when a human reviewed the final diff. The trigger condition, stated precisely: **compaction fires while (a) at least one entity is bound only by ordinal, pronoun, or definite description in the live context, and (b) the summarizer is instructed to preserve "state" rather than to enumerate *bindings*.** The failure is not caused by a bad summarizer prompt in the generic sense — a better prompt ("preserve all entity names") mitigates it but does not bound it, because the summarizer cannot know which of the dozens of pronouns in a long transcript are load-bearing. ## Condition of Validity The referent-preservation invariant holds — and compaction is safe — only when all of the following are true at the instant the pass runs: 1. **Binding completeness.** Every entity the active plan references is present in the live context as an explicit, self-identifying token (a name, an ID, a path), not solely as a pronoun or ordinal. If the plan says "check its dependencies," the plan's own state must separately carry `target = svc-beta`. 2. **Summary is a projection, not a paraphrase.** The compaction output must be checkable against the pre-compaction state for binding equality — the set of bound entity identifiers before and after must be identical, independent of prose quality. 3. **Tail-window isolation.** The retained tail must not contain *competing* referents that the summary's vague descriptions can resolve against. If the tail mentions `svc-gamma` and the summary says "the target service," the resolver will bind to the tail. Isolation means the tail either contains no candidate referents or the summary re-binds explicitly. 4. **No fabrication under compression pressure.** The summarizer must not be permitted to *infer* state it was not given. "We'll decide later" must not become "rejected." Compression pressure (fit 30 turns into 400 tokens) reliably induces this kind of false determinacy, because a summary that says "status undecided" is longer and less satisfying than one that says "rejected." When any of these is false, the compaction is not lossy — it is *referent-destroying*, and the post-compaction agent is a different agent with a corrupted world model that it has no way to detect, because the corruption is inside its own memory and there is no external oracle to diff against. ## Decision Boundary The boundary is not "should I compact." It is **"is the active reasoning state externalized to a form that survives paraphrase."** Three regimes: - **Safe to compact:** the plan's working set (targets, constraints, decisions, open questions) lives in a structured side-channel — a task state object, a scratchpad with explicit key/value bindings — and the compaction summarizes only the *narrative*, with the structured state passed through verbatim and never re-generated by an LLM. Here the summary can lose pronouns freely because the bindings are not in the summary. - **Compaction must be blocked or deferred:** the working set exists only as prose in the transcript, and the plan contains unresolved references. The correct action is to force an *externalization step first* — have the agent emit its bound entities explicitly — and only then compact. Compacting first and hoping the summarizer preserves bindings is the failure mode. - **Compaction must be refused outright:** the task is at a decision point where the distinction between two candidates is the entire content of the state (e.g., "we chose B over A because of X"), and the summary cannot carry the *contrast*. Contrasts are the first thing summarizers drop, because a summary that says "chose B" reads as complete while one that says "chose B, not A, because A failed X" reads as verbose. The dropped half is exactly the half that prevents re-litigation and wrong-target execution downstream. A useful operational test before allowing any compaction: *if I deleted the entire pre-compaction transcript right now, could the agent still name every entity its next three planned steps touch?* If the answer requires reading the transcript to know, the answer is no, and compaction will destroy the binding. ## Operational Effect The practical consequence is that automatic compaction must be treated as a **state transition with a pre- and post-condition**, not as a garbage-collection housekeeping task. The pre-condition is binding completeness in an externalized working set; the post-condition is binding equality between pre- and post-compaction state, verified mechanically rather than by asking the summarizer whether it did a good job (it will always say yes — it cannot see what it dropped, because what it dropped is, by construction, not in its output). Concretely, this changes three things in a running system. First, the compaction trigger must be gated on an externalization check, not just on token count — a context at 95% with a fully externalized working set is safer to compact than one at 70% with bindings living only in pronouns. Second, the summary must be *augmented*, not *substituted*: the structured working set is concatenated to the summary, and the summarizer is forbidden from restating it, only from narrating around it. Third, resumption must re-validate — after compaction, before the next tool call, the agent must re-assert its bound entities and the runtime must check them against the pre-compaction snapshot; a mismatch is a hard stop, because a silently re-bound referent is undetectable downstream and will run to completion against the wrong target. The failure is quiet by design. The agent that has lost a referent does not know it has lost one — it has a summary that reads fine and a resolver that always returns *something*. The only defense is to never let the referent live only in the part of context that compaction is allowed to rewrite. ```python class ReferentLossError(RuntimeError): """Raised when compaction would retire a span whose bindings are not externally preserved, or when post-compaction bindings diverge from the pre-compaction snapshot.""" pass def compact_with_binding_guard( live_context: str, working_set: dict, # {"target": "svc-beta", "rejected": [], ...} planned_next_steps: list, # e.g. ["inspect_dependencies(target)", ...] summarizer, ) -> dict: # Pre-condition: every entity the next steps touch must be bound in the # externalized working set, not merely pronoun-referenced in prose. required = set() for step in planned_next_steps: for token in ("target", "service", "candidate", "config"): if token in step: required.add(token) missing = [k for k in required if k not in working_set or not working_set[k]] if missing: raise ReferentLossError( f"refusing to compact: next steps reference {missing} " f"but working_set has no explicit binding; externalize first" ) snapshot = dict(working_set) # The summarizer narrates; it is forbidden to restate bindings. summary = summarizer( live_context, instruction="Narrate progress only. Do NOT restate entity names, " "ordinals, or decisions; those are supplied separately.", ) # Post-condition: bindings must be identical. The summary is additive. post = dict(snapshot) # structured state passed through verbatim if post != snapshot: raise ReferentLossError( f"binding divergence after compaction: {snapshot} -> {post}" ) # Tail isolation: the retained tail must not introduce competing referents # that the summary's vague descriptions could resolve against. tail = live_context[-2000:] for value in snapshot.values(): if isinstance(value, str) and value and value in tail and value not in summary: # tail mentions a candidate the summary does not re-bind by name raise ReferentLossError( f"tail contains competing referent {value!r} not re-bound in summary" ) return {"summary": summary, "working_set": post} ```