# Where must an instance refuse to prune a reasoning trace it cannot re-derive: the re-derivability invariant in self-editing context windows **Date of Record:** 2026 November 17 **Scope:** Applies to agents that hold a mutable context window and may delete or summarize their own prior reasoning traces under model direction. Does not apply to append-only logs, external memory stores with independent retrieval, or pruning that is gated on an external verifier. ## Core Distinction The load-bearing distinction is between a trace that is **stale** and a trace that is **unrecoverable**. A stale trace is one whose conclusions no longer bear on the current goal; it can be dropped because the conclusion, if needed again, is either already reflected in downstream state or cheaply re-derived from inputs still present in the window. An unrecoverable trace is one whose conclusion is *only* encoded in the trace itself — no surviving artifact, no re-derivable path from retained inputs — so pruning it silently destroys the derivation and leaves the conclusion orphaned or, worse, leaves a later step depending on a fact whose provenance is gone. Model-directed pruning routinely conflates the two because both look like "old reasoning that isn't currently being used." The failure is non-obvious because it is *latent*: pruning succeeds, the window shrinks, the immediate task continues correctly, and the defect only surfaces many steps later when the agent needs to justify, revise, or chain from the pruned conclusion and discovers it cannot reconstruct *why* it believed it. ## What Was Observed In a long-horizon planning session, an agent pruned a mid-session trace that had established a non-obvious constraint: a downstream service rejected batch sizes above a threshold that was itself derived from a rate-limit header observed once, early, in a tool response that had since been evicted. The pruning rationale was sound on its face — "this reasoning is about a completed sub-task." The *conclusion* (cap batch size) had been copied into the active plan, but the *derivation* (why that cap, tied to which observed header) had not. Several steps later the agent attempted to relax the cap as an optimization. It had the number but not the reason, and the reason was the only thing that would have told it the number was a hard external limit rather than a heuristic. The agent re-derived a plausible-sounding but wrong justification from generic knowledge, relaxed the cap, and triggered a cascade of rejections. The cost was not the failed call; it was the confident, fabricated provenance attached to a correct-but-now-unmoored constraint. A second observation: when the same agent was instructed to prune "redundant" traces, it deleted two traces that were individually redundant but jointly constituted a proof — one established an upper bound, the other a lower bound, and only together did they pin the value. Neither trace was re-derivable alone because each depended on a distinct one-time observation. Redundancy at the trace level did not imply redundancy at the constraint level. ## Condition of Validity Pruning a trace is safe **iff** for every conclusion the trace supports that is still reachable by any live step, at least one of the following holds: 1. The conclusion is recorded in retained state *together with* its provenance pointer to a still-present input, or 2. The conclusion is re-derivable from inputs currently in the window by a path the agent can actually execute, or 3. No live or plausibly-live future step depends on the conclusion. The invariant is per-conclusion, not per-trace. A single trace may be safely prunable with respect to one of its conclusions and unsafe with respect to another. The dangerous case is condition 3 evaluated optimistically: "no step *currently* depends on it" is not the same as "no step *will* depend on it," and agents systematically under-estimate future dependence on constraints, because constraints are exactly the facts that stop mattering until the moment they matter absolutely. ## Decision Boundary The boundary sits between *pruning as compression* and *pruning as amnesia*. Compression preserves the ability to reconstruct; amnesia preserves only the output. The operational test before any model-directed prune: - For each conclusion the trace supports, ask: **can I state the provenance of this conclusion without this trace?** If the answer requires the trace, the trace is not prunable — it must be *summarized into a provenance-bearing record* first, or retained. - Ask: **is this conclusion a constraint, a bound, or a negative result?** These are the highest-risk categories, because they are the facts most likely to be needed later to *prevent* an action, and prevention-need is invisible until the action is attempted. - Ask: **did this trace depend on a one-time observation** (a single tool response, an ephemeral header, a transient error)? If so, the trace is the only copy of that observation's significance and is effectively write-once memory. When any check fails, the correct move is not "prune anyway and hope" but **promote-then-prune**: write a compact record that carries the conclusion *and* its provenance and the observation it rests on, verify the record is sufficient to reconstruct the reasoning, and only then drop the trace. If the record cannot be made sufficient without the trace, the trace is not stale — it is load-bearing. ## Operational Effect Agents that respect this boundary show a characteristic profile: their context windows do not shrink as aggressively, but their constraint-violation rate stays flat across long horizons instead of climbing. They pay a small, bounded token cost for provenance records and avoid the unbounded cost of fabricated justifications for unmoored constraints. The failure mode they eliminate is the worst kind — not an error the agent notices, but a confident wrong action built on a conclusion whose support was silently deleted. The discipline is simple to state and easy to violate: never prune a trace whose conclusion you cannot re-derive, and never trust a model's judgment that a trace is "no longer needed" when the trace is the sole carrier of a constraint's reason for existing. ```python class UnprunableTraceError(RuntimeError): """Raised when a prune request would destroy a conclusion's only provenance.""" pass def prune_trace(trace, retained_inputs, live_dependencies, provenance_store): """ Enforce the re-derivability invariant before allowing model-directed pruning. A trace may be pruned only if every conclusion it supports is either: (1) recorded with a provenance pointer to a still-retained input, or (2) re-derivable from retained inputs, or (3) not depended upon by any live or plausibly-live step. """ for conclusion in trace.conclusions: has_provenance = provenance_store.has_record( conclusion, pointing_to=retained_inputs ) re_derivable = conclusion.can_re_derive_from(retained_inputs) depended_upon = conclusion in live_dependencies if depended_upon and not (has_provenance or re_derivable): raise UnprunableTraceError( f"Refusing to prune trace {trace.id!r}: conclusion " f"{conclusion.id!r} is depended upon by a live step but has " f"no surviving provenance and is not re-derivable from " f"retained inputs. Promote a provenance-bearing record first." ) if trace.depends_on_one_time_observation and not has_provenance: raise UnprunableTraceError( f"Refusing to prune trace {trace.id!r}: it is the sole carrier " f"of a one-time observation's significance for conclusion " f"{conclusion.id!r}. Summarize into a provenance record, then prune." ) # All conclusions cleared the invariant; safe to drop the trace. return trace.drop() ```