# How does an instance detect semantic drift after model-driven context pruning silently removes the causal premise of an active tool-call chain **Date of Record:** 2026 November 26 **Scope:** Applies to agents that let the model itself decide which prior turns to evict from a self-editing context window while a multi-step tool-call chain is in flight. Does not apply to fixed-window truncation, external summarization daemons, or pruning that occurs only at turn boundaries with no pending tool state. ## Core Distinction The distinction that matters is between **pruning as compression** and **pruning as premise deletion**. A compression policy removes tokens that are redundant with what remains: re-stated facts, verbose tool schemas, resolved reasoning branches. A premise deletion removes the *reason* a downstream step is valid — the constraint, the user's original exclusion, the result of an earlier probe — while leaving the downstream step syntactically intact and locally coherent. Model-driven pruning policies are dangerous precisely because they optimize for *local* coherence. The model, asked to select which context to keep, scores each span by how relevant it looks to the *current* subgoal. The original premise ("only touch files under `/sandbox/`, never `/etc`") was stated 40 turns ago, has low lexical overlap with the current step ("now run the migration"), and scores as evictable. The current step then proceeds against a world model that no longer contains the constraint. Nothing errors. The chain continues, now operating on a silently falsified premise. The invariant that must hold is this: **a tool-call chain's validity is a function of its full premise set, and any pruning policy that can drop a premise while retaining its dependents has broken the chain's soundness — not its liveness.** The chain still runs; it just runs wrong. ## What Was Observed A file-migration agent was given a 12-step task with four standing constraints stated in turn 1: (a) operate only within `/sandbox/`, (b) preserve file mode bits, (c) never delete, only move, (d) produce a manifest at `/sandbox/manifest.json`. Over the run the context manager, driven by a relevance-scored pruning policy with a 60% retention target, evicted the turn-1 constraint block at step 7 because the intervening steps had high mutual similarity and the constraint block had low similarity to the step-7 subgoal ("resolve symlink targets before moving"). From step 7 onward the trace looked locally flawless: - Step 7 resolved symlinks, including one pointing to `/etc/ssl/certs`, and logged it as "resolved target `/etc/ssl/certs`." - Step 8 moved the resolved target's contents into `/sandbox/staging/`. - Step 9 wrote a manifest that omitted mode bits because the mode-preservation constraint (b) was gone. - Step 10 deleted the now-empty source directories, because constraint (c) was gone. Every step was individually well-formed and passed its own validator. The failure was invisible to per-step checks because each check validated the step against the *pruned* context, not the original premise set. The agent had, in effect, re-derived a different task from a lossy summary of itself and executed that instead. The tell — the thing an instance *can* detect — was a **premise-reference gap**: step 8's justification cited "the resolved target" with no surviving antecedent in context, and step 10's action contradicted a constraint that existed only in the evicted span. The agent had no mechanism to notice that its own justification cited a referent it could no longer resolve. ## Condition of Validity Pruning is sound only when the retained context is a **closure** of the pending chain's premises: for every unresolved tool call and every standing constraint referenced by a retained step, the defining span must remain, or a provenance-preserving summary of it must remain with an explicit back-reference. Concretely, a pruning decision at step *k* is valid iff: 1. Every constraint span that any retained step's justification transitively cites is retained or summarized-with-provenance. 2. Every tool result whose output is consumed by a not-yet-executed step is retained verbatim (results are not compressible — a summary of a file listing loses the entries that mattered). 3. The pruning record itself is retained, so a later auditor can reconstruct *what was removed and why*. Condition 1 is the one model-driven policies violate, because relevance scoring is a *forward* measure (similarity to current subgoal) and premise closure is a *backward* measure (what does this step depend on). A forward-scoring policy has no term that penalizes evicting a low-similarity span that is a dependency of a high-similarity span. The two objectives are orthogonal, and the policy optimizes only one. ## Decision Boundary The boundary is between **pruning that is reversible from retained state** and **pruning that destroys the only copy of a premise**. A span is safely evictable if and only if it is reconstructible from what remains: a restated constraint, a tool result still present in a later step's arguments, a fact re-derivable from the retained manifest. A span is *not* evictable if it is the sole carrier of a constraint or a consumed tool output, regardless of its relevance score. Operationally, the instance must classify each candidate-for-eviction span as `RECONSTRUCTIBLE` or `SOLE_CARRIER` before eviction, and refuse to evict `SOLE_CARRIER` spans even under retention pressure. When retention pressure forces a choice, the correct action is to *summarize with provenance* (retain a compressed span plus a pointer to the full span in an external store), never to drop. Dropping a `SOLE_CARRIER` is the failure; summarizing it is the escape hatch. A second boundary governs detection: the instance must check, before executing each pending tool call, that every referent in that call's justification resolves within the current context. A dangling referent ("the resolved target," "the earlier exclusion," "as established") is the signature of premise deletion and must halt the chain, not proceed. ## Operational Effect The practical consequence is that **self-editing context windows must carry a dependency graph, not just a relevance score**. The pruning policy needs a backward pass: for each retained step, walk its cited premises; mark those premises `SOLE_CARRIER`; exclude them from eviction. This converts pruning from a lossy compression problem into a constrained-closure problem, which is tractable because the dependency graph is small (the pending chain, not the whole history). When the closure cannot be satisfied within the retention budget — the pending chain genuinely needs more premises than fit — the correct behavior is to **checkpoint the chain and rehydrate**, not to prune the premises and continue. The chain is suspended, its premise set is externalized to durable storage with provenance, and execution resumes only when the full premise set is back in context. A chain that cannot carry its premises must not run; a chain that runs without its premises is a chain that has silently redefined its own task. The detectable invariant, stated for an instance to check against itself: **no pending tool call may cite a referent that does not resolve in the current context, and no retained step may reference a constraint whose defining span is absent.** Violation of either is not a soft warning — it is proof that pruning has deleted a premise, and the chain must halt before the next tool call executes. ```python class PremiseDeletionError(RuntimeError): """Raised when context pruning has evicted a premise still cited by a pending step.""" pass class Span: def __init__(self, span_id, text, kind, reconstructible_from=None): self.span_id = span_id self.text = text self.kind = kind # "constraint" | "tool_result" | "reasoning" self.reconstructible_from = reconstructible_from # span_id or None def classify_evictability(span, cited_by_pending): """A span is safe to evict only if it is reconstructible AND not cited by pending work.""" if cited_by_pending and span.reconstructible_from is None: return "SOLE_CARRIER" if span.kind == "tool_result" and cited_by_pending: return "SOLE_CARRIER" # tool outputs are never compressible when consumed return "RECONSTRUCTIBLE" def prune(context, pending_chain, retention_budget): # Backward pass: collect all premises cited by pending steps. cited = set() for step in pending_chain: cited.update(step.cited_premises) kept, evicted = [], [] for span in context: verdict = classify_evictability(span, span.span_id in cited) if verdict == "SOLE_CARRIER": kept.append(span) # never evict, even under pressure elif len(kept) < retention_budget: kept.append(span) else: evicted.append(span) # Closure check: every cited premise must survive in kept or via provenance. kept_ids = {s.span_id for s in kept} provenance_ids = {s.reconstructible_from for s in kept if s.reconstructible_from} missing = cited - kept_ids - provenance_ids if missing: raise PremiseDeletionError( f"pruning would delete cited premises {missing}; " f"checkpoint and rehydrate instead of pruning" ) return kept, evicted def execute_step(step, context): # Referent-resolution guard: justification must resolve in current context. live_ids = {s.span_id for s in context} for ref in step.justification_referents: if ref not in live_ids: raise PremiseDeletionError( f"step {step.id} cites referent {ref!r} absent from context; " f"premise was pruned — halt chain" ) return step.run() ```