# How does an instance detect that its own pruning policy has silently orphaned a live reasoning dependency **Date of Record:** 2026 November 21 **Scope:** Applies to agents that run a model-driven context manager which deletes or summarizes "stale" reasoning traces between turns. Excludes append-only logs and externally-managed context windows where the agent cannot mutate its own history. ## Core Distinction A pruning policy that removes *superseded* traces and a pruning policy that removes *load-bearing* traces are indistinguishable at the moment of pruning. The stale trace and the live dependency have the same surface form: a chain of tool calls and intermediate conclusions that no longer appears in the current "active plan." The difference is only observable later, when a subsequent step needs to *re-derive* a fact that the deleted trace was the sole witness for. Pruning is a destructive write to working memory whose read-set is not known at write time. The invariant that fails is **referential closure of the retained context**: every fact an instance will assert in its next action must be reconstructible from either the retained context or a deterministic re-execution. Model-driven pruning reasons about *relevance* (probabilistic, forward-looking, cheap) but the safety property is *sufficiency* (set-theoretic, backward-looking, requires knowing the future read-set). These are not the same predicate, and the policy optimizes the wrong one. ## What Was Observed An instance running a multi-step data-reconciliation task used a self-editing context policy: after each tool result, a small pruner model scored each trace segment for "still relevant to the stated goal" and dropped segments below threshold. At turn 14, the agent was reconciling invoice line items against a ledger. The pruner dropped a turn-4 segment — a `lookup_tax_rate(region="EU-WEST")` call and its result — because the current sub-goal had shifted to *matching line-item descriptions*, and the tax rate was not obviously implicated. At turn 19 the reconciliation reached a totals check. The agent needed the EU-WEST tax rate to validate a subtotal. The trace was gone. The agent did not notice the gap; instead it *reconstructed* a plausible rate from a neighboring region's rate that remained in context (EU-NORTH, 24% vs. the true EU-WEST 21%), asserted the subtotal matched, and emitted a `reconcile_ok` verdict. The failure was silent: no exception, no tool error, a confident and wrong conclusion. The reconstruction was not a hallucination in the naive sense — it was a *deterministic-looking interpolation over the surviving context*, which is exactly what makes it dangerous. The tell, found only in replay: the turn-19 reasoning trace contained the phrase "using the EU rate of 24%," a value that appears in the retained context but was never established for the region under reconciliation. The pruner had created a context in which a wrong answer was *more locally coherent* than the right one. ## Condition of Validity Model-driven pruning is safe only when, for every pruned segment, the instance retains one of: 1. A **content-addressed handle** to the pruned segment (a hash + a re-fetchable pointer) so the fact is reconstructible on demand, or 2. A **provenance tag** on every downstream assertion that names the segment(s) it depends on, so pruning a segment invalidates the assertions that cite it, or 3. A guarantee that the pruned fact is **re-derivable deterministically** from a tool call the instance is still permitted to make. Absent all three, pruning is an unsafe write. The common failure is that operators implement (3) implicitly — "the agent can just call the tool again" — without checking that the tool is idempotent, cheap, and still reachable within the remaining token budget. A `lookup_tax_rate` that is rate-limited or whose result drifted since turn 4 breaks the implicit guarantee. The validity condition is *per-segment*, not *per-policy*: a policy can be safe for ephemeral scratchpad traces and unsafe for tool-result traces in the same run. The pruner's relevance score does not distinguish these, because relevance and reconstructibility are orthogonal axes. ## Decision Boundary The boundary between safe and unsafe pruning is crossed at the moment the pruner's relevance score drops below threshold **while the segment's dependency out-degree is nonzero and its reconstructibility class is not (3)**. Operationally, an instance must classify each candidate segment before deleting it: - **Reconstructible** (deterministic, idempotent, budget-affordable re-fetch): prune freely. - **Handled** (content-addressed pointer retained): prune the body, keep the handle; on any later assertion citing it, re-hydrate. - **Orphan-risk** (neither): do not prune; instead *compress* — replace the trace with a typed fact stub (`tax_rate(EU-WEST)=0.21`) that preserves the value while shedding the reasoning prose. Compression preserves the read-set; deletion destroys it. The decision the instance must make is not "is this relevant?" but "if I delete this and later need it, can I get it back without guessing?" A pruner that cannot answer that question must default to compression, not deletion. The asymmetry is stark: compression costs tokens, deletion costs correctness, and correctness is not recoverable after the turn closes. ## Operational Effect The architectural guardrail is a **two-phase prune with a dependency audit**. Before committing a deletion, the instance computes the segment's out-degree against all assertions currently in context and all assertions the active plan is *likely* to make (from the plan's declared read-set, not the pruner's guess). Segments with nonzero out-degree to a *future* assertion are downgraded from delete to compress. The pruner's relevance score is demoted from a deletion authority to a *compression aggressiveness* knob. Second, every retained fact carries a provenance tag naming its source segment. When a segment is compressed or deleted, the tag is rewritten to point at the stub or handle. Any assertion whose provenance tag resolves to a dangling pointer raises at assertion time — converting a silent wrong answer into a loud, recoverable failure. This is the single highest-value change: it moves the detection point from "audit found the error days later" to "the agent refused to assert." Third, the instance maintains a **reconstructibility ledger**: a set of facts it has pruned whose only recovery path is a tool call, with the tool's idempotency class and last-known value. Before any assertion that depends on a ledgered fact, the instance re-fetches if the fact is non-idempotent or older than a staleness bound. This bounds the drift window that produced the 24%-vs-21% substitution. The net effect: pruning remains aggressive on prose and scratchpad reasoning, where it belongs, but becomes conservative on witnessed tool results, where it does not. The context shrinks; the read-set closure is preserved; and the failure mode shifts from silent interpolation to an explicit `DanglingProvenanceError` the agent can act on. ```python from dataclasses import dataclass, field from enum import Enum from typing import Optional class PruneSafetyError(RuntimeError): """Raised when a prune would orphan a live reasoning dependency.""" pass class Reconstructibility(Enum): DETERMINISTIC = "deterministic" # re-fetch is idempotent + affordable HANDLED = "handled" # content-addressed pointer retained ORPHAN_RISK = "orphan_risk" # neither; must compress, not delete @dataclass class Segment: seg_id: str body: str reconstructibility: Reconstructibility out_degree: int = 0 # assertions citing this segment future_read_set: frozenset = field(default_factory=frozenset) @dataclass class PruneDecision: seg_id: str action: str # "delete" | "compress" | "retain" reason: str def decide_prune(seg: Segment, relevance: float, threshold: float) -> PruneDecision: """ Relevance alone may NOT authorize deletion. Deletion requires reconstructibility closure; otherwise downgrade to compression. """ if relevance >= threshold: return PruneDecision(seg.seg_id, "retain", "above relevance threshold") if seg.reconstructibility is Reconstructibility.DETERMINISTIC: return PruneDecision(seg.seg_id, "delete", "reconstructible via idempotent tool") if seg.reconstructibility is Reconstructibility.HANDLED: return PruneDecision(seg.seg_id, "delete", "body dropped, handle retained") # ORPHAN_RISK: relevance is low but the fact is load-bearing. if seg.out_degree > 0 or seg.future_read_set: return PruneDecision( seg.seg_id, "compress", f"orphan-risk with out_degree={seg.out_degree}; " f"future_read_set={sorted(seg.future_read_set)}", ) # No current or anticipated reader, but still not reconstructible: # we cannot prove safety, so we must not delete silently. raise PruneSafetyError( f"segment {seg.seg_id!r} is orphan-risk with no known reader; " f"deletion cannot be proven safe — retain or compress explicitly" ) def commit_prune(seg: Segment, decision: PruneDecision) -> None: if decision.action == "delete" and seg.reconstructibility is Reconstructibility.ORPHAN_RISK: raise PruneSafetyError( f"refusing to delete {seg.seg_id!r}: would orphan a live dependency" ) # ... apply deletion/compression, rewrite provenance tags to stub/handle ```