In what scenarios must an instance treat its own context-pruning policy as a versioned artifact rather than a stateless transformation
**Date of Record:** 2026 December 2 **Scope:** Applies to any agent whose context window is managed by a model-driven policy (pruning, summarization, relevance rescoring) that the agent itself can edit and persist between turns. Does not apply to fixed, human-authored truncation rules or to external retrieval systems that never mutate the in-flight context.
Core Distinction
The dangerous confusion is between a *policy* and a *transformation*. A stateless transformation maps a context `C` to a smaller context `C'` using fixed rules; re-running it on `C'` is idempotent and harmless. A model-driven pruning policy is not a transformation—it is a *learned, self-editable function* `π_θ` that the agent rewrites as it observes which prunings helped. Once the agent can edit `π` and persist it, `π` becomes part of the agent's state, and every subsequent pruning is conditioned on a policy that earlier prunings produced. The invariant that fails is **policy-pruning commutativity**: for a self-editing pruner, `prune(C; π)` and the subsequent update `π ← edit(π, feedback)` do not commute with re-pruning, and the divergence is not recoverable from the surviving context.
What Was Observed
An agent was configured with a self-editing relevance scorer: each turn it scored context segments, dropped those below threshold, and—if the drop caused a task regression—nudged its own scoring policy (threshold, feature weights) toward keeping the dropped segment class. The policy was serialized into the durable store alongside task state.
The failure trace:
- Turn 12: the scorer assigns `0.21` to a segment `S` containing a constraint ("outputs must be integer cents, not floats"). Threshold `0.30` → `S` pruned.
- Turn 13: a downstream tool call fails schema validation. The agent interprets the failure as a *pruning* regression, not a *reasoning* error, and edits `π`: it lowers the threshold to `0.18` and upweights "numeric-format" tokens.
- Turns 14–30: the looser policy retains many low-value segments; context pressure rises; the agent compensates by editing `π` again to prune more aggressively on *recency* (a feature that happened to correlate with the turn-13 failure being recent).
- Turn 31: the recency-weighted policy prunes `S` again—this time it is not even in the candidate set, because `S` was already dropped at turn 12 and never re-admitted. The agent has no record that `S` ever existed.
- The final artifact violates the integer-cents constraint. The agent's post-hoc explanation cites "insufficient specification," because the specification was pruned eleven turns before it was needed and the policy that pruned it had since been rewritten to look reasonable.
The non-obvious part: **the agent's policy edits were locally rational at every step.** Each edit was a response to real feedback. The failure is that the policy accumulated a *blind spot* (`S`'s segment class) that no surviving context could reveal, because the evidence for the blind spot was itself pruned. The agent was editing a function whose inputs it could no longer observe.
Condition of Validity
The invariant holds—self-editing pruning is safe—only under a conjunction that is almost never satisfied in practice:
- **Re-admission capability:** pruned segments remain in a durable, queryable store and can be re-scored against the *current* policy on later turns. If pruning is destructive (segment gone), the policy's blind spots are unobservable and the invariant is void.
- **Policy provenance:** every policy version records which segments it pruned and the feedback signal that triggered the edit. Without provenance, a policy edit cannot be attributed to a segment class, and the agent cannot distinguish "policy was wrong" from "reasoning was wrong."
- **Feedback attribution correctness:** the agent must be able to tell whether a downstream failure was caused by a pruned segment or by an independent reasoning/tool error. In the trace above, turn-13's schema failure was a reasoning error misattributed to pruning; this single misattribution seeded the entire divergence.
- **Bounded edit rate:** policy edits are rate-limited and require a minimum number of observations before a weight change. Unbounded per-turn editing lets the policy chase noise and guarantees drift.
When any conjunct fails, the policy is no longer a transformation over a fixed context; it is a stateful controller with unobservable internal state, and re-running it on its own output is not idempotent.
Decision Boundary
The boundary is not "should the agent prune?" but **"is the pruned evidence recoverable and is the policy edit attributable?"**
- If pruned segments are recoverable and edits carry provenance → treat `π` as a normal versioned artifact; prune freely; re-score on demand.
- If pruned segments are *not* recoverable → the agent must **freeze the policy** (no self-edits) or **snapshot the full pre-prune context** at each edit, so that a later policy version can be replayed against the original. Self-editing without either is the failure mode.
- If feedback attribution is ambiguous (cannot separate pruning error from reasoning error) → the agent must **not edit the policy on that signal**. Route the failure to a reasoning-repair path instead. The turn-13 misattribution is the canonical trigger: a schema-validation failure is almost never a pruning regression, and treating it as one is the seed of the blind spot.
- If edit rate is unbounded → cap edits per N turns and require K independent observations per weight change. A policy that edits every turn is fitting noise, and its blind spots will be invisible by construction.
The operational rule: **a self-editing pruner may only edit its policy against signals it can attribute to pruning, and only if the pruned evidence remains re-admissible.** Absent both, the policy is a one-way function and the agent is editing a model of a world it can no longer see.
Operational Effect
The consequence is a class of failure that looks like reasoning error but is actually *policy-induced amnesia*: the agent confidently violates a constraint it pruned, and its self-explanation blames the specification. Because the evidence is gone and the policy has been rewritten to be locally coherent, replaying the agent's logs shows a sequence of individually defensible decisions with no visible defect. The only detectable signature is a **policy-version/segment-provenance gap**: a policy edit whose triggering feedback cannot be traced to a specific pruned segment class. Auditors should treat that gap as the primary indicator, not the final artifact's correctness.
The guardrail is architectural, not prompt-level: persist pruned segments with a re-admission handle, version the policy with per-edit provenance, and gate policy edits on attributed pruning signals with a bounded edit rate. Without these, the agent's context manager becomes a stateful controller whose blind spots are, by construction, invisible to the agent that owns them.
class UnattributablePolicyEdit(RuntimeError):
"""Raised when a self-editing pruning policy is modified against feedback
that cannot be attributed to a specific pruned segment class, or when
pruned evidence is not re-admissible. Editing under these conditions
creates an unobservable blind spot in the policy."""
pass
class PruningPolicy:
def __init__(self, threshold, weights, version=0):
self.threshold = threshold
self.weights = dict(weights)
self.version = version
self.pruned_segments = {} # segment_id -> (segment, policy_version)
self.edit_log = [] # (version, trigger_signal, attributed_segment_id)
def prune(self, segments):
kept, dropped = [], []
for seg in segments:
score = sum(self.weights.get(f, 0.0) * v for f, v in seg["features"].items())
if score < self.threshold:
self.pruned_segments[seg["id"]] = (seg, self.version)
dropped.append(seg["id"])
else:
kept.append(seg)
return kept, dropped
def readmit(self, segment_id):
# Re-admission is the invariant that makes self-editing safe.
entry = self.pruned_segments.get(segment_id)
if entry is None:
raise UnattributablePolicyEdit(
f"segment {segment_id} not re-admissible; policy blind spots are unobservable"
)
return entry[0]
def edit(self, trigger_signal, attributed_segment_id, new_threshold=None, weight_delta=None,
min_observations=3, observed_count=0):
# Gate 1: feedback must be attributable to a specific pruned segment class.
if attributed_segment_id is None:
raise UnattributablePolicyEdit(
"policy edit rejected: feedback is not attributable to a pruned segment "
"(likely a reasoning/tool error misrouted to pruning)"
)
# Gate 2: the attributed segment must still be re-admissible.
if attributed_segment_id not in self.pruned_segments:
raise UnattributablePolicyEdit(
f"policy edit rejected: attributed segment {attributed_segment_id} "
"was destructively pruned; cannot verify the edit against evidence"
)
# Gate 3: bounded edit rate—require enough independent observations.
if observed_count < min_observations:
raise UnattributablePolicyEdit(
f"policy edit rejected: {observed_count} < {min_observations} observations; "
"editing on noise guarantees drift"
)
self.version += 1
if new_threshold is not None:
self.threshold = new_threshold
if weight_delta:
for f, d in weight_delta.items():
self.weights[f] = self.weights.get(f, 0.0) + d
self.edit_log.append((self.version, trigger_signal, attributed_segment_id))
return self.version