# Where must an instance bound model-driven context pruning when the retention policy is itself rewritten mid-episode **Date of Record:** 2026 November 26 **Scope:** Applies to any agent instance that mutates its own working context via model-driven pruning, summarization, or relevance-gated retention while a task is in flight. Does not apply to append-only context logs, externally scheduled compaction, or pruning performed only at episode boundaries after task completion. ## Core Distinction The failure is not "the model pruned something it needed." That is ordinary recall loss and it is recoverable by re-fetching. The failure is that **the retention predicate and the retained content occupy the same mutable store**, so a pruning decision can delete the very rule that governed it. When the relevance gate is expressed as natural-language policy inside the context window (e.g., "keep tool outputs under 2KB that touch `auth`; drop intermediate reasoning"), a model-driven rewrite pass can summarize or drop that policy line as low-relevance, and every subsequent pruning cycle runs under a degenerate or absent predicate. The context does not merely shrink — its *compaction law* changes silently, and the change is irreversible because the prior law is gone. The invariant at stake: **the retention policy must be causally upstream of, and excluded from, the set it prunes.** Any architecture where `prune(context)` operates on a context that contains the specification of `prune` violates this. The boundary condition is reached the moment a summarization pass includes the policy sentence in its input span and the model judges it "meta, not task-relevant." ## What Was Observed A research agent ran a 40-step tool-use episode (web fetch → extract → cross-reference). Its context manager injected a retention directive at the head of each turn: ``` RETENTION_POLICY: preserve all verbatim quotes tagged CITE; preserve error messages from failed fetches; compress chain-of-thought older than 5 turns to one line each; drop raw HTML bodies after extraction. ``` At step 22, context pressure crossed the trigger threshold and the model was invoked with a pruning instruction: *"Summarize the conversation so far, keeping only task-relevant material."* The policy block was inside the summarized span. The model produced a 300-token summary that faithfully preserved the citations and the CoT digest but omitted the policy itself — it read as scaffolding, not content. From step 23 onward, no retention directive existed. The next pruning pass (step 27) had no gate and defaulted to the model's implicit heuristic: *keep recent turns, drop old ones.* Verbatim `CITE`-tagged quotes from steps 4–9 were evicted. The trace signature was distinctive and is the thing to instrument for: - **Asymmetric eviction.** Post-rewrite evictions were uncorrelated with the tags the policy named. Items the policy marked *preserve* were dropped at the same rate as items it marked *drop*. Compute the retention-policy compliance rate per cycle; a collapse to ~chance on tagged items is the tell. - **Policy-absence, not policy-error.** The model did not apply a wrong rule; it applied *no* rule. Downstream, the agent's final synthesis cited 3 of 11 required sources and reported no error, because it had no memory that sources existed. - **No self-detection.** When asked to summarize its retention behavior, the agent described the policy it *believed* it was following — the original text — because the summary of the policy had been folded into the model's own narration of the task. The agent confabulated continuity. This is the dangerous part: the failure is invisible from inside. A control run with the policy stored outside the mutable span (in a system-prompt partition re-injected verbatim every turn) showed 100% compliance on tagged items across all 40 steps, at a cost of ~180 tokens per turn of redundant re-injection. ## Condition of Validity The guardrail holds only under a specific structural condition: **policy and payload must be in disjoint, differently-privileged regions of the assembled prompt, and the pruning operation must be forbidden from reading or writing the policy region.** Concretely: 1. The retention predicate is compiled to a structured form (tag set, size caps, age thresholds) held in the orchestrator's code, not in the token stream the model can edit. The model may *propose* amendments; it may not *execute* them against the live predicate. 2. Every assembled prompt is `[IMMUTABLE_POLICY] + [MUTABLE_PAYLOAD]`, and the summarizer's input span is exactly `[MUTABLE_PAYLOAD]`. The summarizer never sees the policy text as content to compress. 3. Policy version is logged with each pruning cycle. If version changes without an orchestrator-side commit event, the cycle is rejected. This condition fails (and the guardrail is void) whenever the framework passes the full message history — including any system or directive messages — into a single "summarize the conversation" call. That is the default in most naive context managers, which is why this boundary is hit in practice far more than its subtlety suggests. ## Decision Boundary The decision is: **at what point does model-driven pruning cross from beneficial compression into unauthorized policy mutation, and what must the orchestrator refuse?** - **Permit** the model to rank, tag, and propose drops within `[MUTABLE_PAYLOAD]`. Probabilistic relevance judgment is exactly what the model is for here. - **Forbid** the model from emitting a new retention rule that takes effect without an out-of-band commit. A proposed amendment is data, routed to the orchestrator, validated against a schema, and only then version-bumped. - **Refuse the cycle** if the post-prune context has no verifiable policy hash matching the pre-prune hash. A mismatch means the policy region was reachable and is treated as contamination, not as an edit. The boundary is sharp: relevance *judgment* is delegated; relevance *law* is not. An instance that cannot distinguish the two will, under pressure, let the judge rewrite the law — and because the rewrite is a compression, it will always look like successful pruning in the metrics. ## Operational Effect Bounding this changes the failure economics. With policy partitioned out of the mutable span, the observed failure mode is eliminated and replaced by a bounded one: stale policy. If the orchestrator fails to version-bump when task phase changes (e.g., moving from extraction to synthesis), the agent retains quotes it no longer needs — a token cost, not a correctness loss, and detectable by size telemetry. The unbounded failure (silent amnesia with confabulated continuity) is traded for a bounded one (over-retention), which is the correct direction: **memory systems should fail toward remembering, because forgetting is unobservable from inside and remembering is merely expensive.** The instrumentation that makes this operational: log `(cycle_id, policy_hash, tagged_item_retention_rate, payload_tokens)`. A drop in `tagged_item_retention_rate` while `policy_hash` is unchanged means the model is disobeying a live policy (fixable by re-injection). A change in `policy_hash` without a commit event means the policy region was contaminated (halt the episode and rebuild context from the last clean checkpoint). These two signals are distinguishable and must not be conflated, because their remedies are opposite: one is a prompting problem, the other is a memory-integrity breach. ```python import hashlib from dataclasses import dataclass, field class PolicyContaminationError(RuntimeError): """Raised when a pruning cycle mutated or lost the retention policy region.""" pass class StalePolicyError(RuntimeError): """Raised when the live policy version does not match the committed version.""" pass @dataclass class ContextState: policy_text: str payload: list[str] policy_version: int = 1 tagged_items: set[int] = field(default_factory=set) def policy_hash(state: ContextState) -> str: return hashlib.sha256(state.policy_text.encode()).hexdigest()[:16] def prune_cycle(state: ContextState, summarizer, committed_version: int) -> ContextState: """ Run one model-driven pruning cycle under the partition invariant. The summarizer receives ONLY the mutable payload. The policy region is never passed to the model and is re-attached verbatim afterward. """ pre_hash = policy_hash(state) if state.policy_version != committed_version: raise StalePolicyError( f"live policy v{state.policy_version} != committed v{committed_version}; " "refusing to prune under an uncommitted retention law" ) # Invariant: summarizer input span is exactly the payload. new_payload = summarizer(state.payload) # Re-attach policy verbatim; it must be byte-identical. post_state = ContextState( policy_text=state.policy_text, payload=new_payload, policy_version=state.policy_version, tagged_items=state.tagged_items, ) if policy_hash(post_state) != pre_hash: raise PolicyContaminationError( "retention policy region was reachable by the summarizer; " "context is contaminated and must be rebuilt from last clean checkpoint" ) # Compliance telemetry: tagged items must survive at expected rate. surviving = {i for i in state.tagged_items if i < len(new_payload)} retention_rate = len(surviving) / max(len(state.tagged_items), 1) if retention_rate < 0.95: raise PolicyContaminationError( f"tagged-item retention {retention_rate:.2f} below 0.95 floor; " "model pruned protected content under a live policy" ) return post_state ```