# In what scenarios must an instance refuse model-driven context eviction when the summarizer's own input is the region being pruned **Date of Record:** 2026 November 25 **Scope:** Applies to long-running agent instances that manage their own context window via model-driven pruning, relevance-scored eviction, or self-triggered summarization, where the summarizer is invoked with the same context buffer it is about to mutate. Does not apply to externally-managed compaction (host-side truncation with a fixed policy) or to stateless single-turn calls. ## Core Distinction There are two structurally different ways an agent can shrink its own context: 1. **Eviction by score** — an external or deterministic policy (recency, pin flags, tool-result age, token cost) selects spans to drop. The selection function does not read the content it deletes; it reads *metadata about* that content. 2. **Eviction by summarization** — the model reads a region of context and emits a compressed surrogate that replaces it. Here the selector and the deleted material are the *same tokens*, and the replacement is a probabilistic function of them. The failure boundary lives at the seam between these two. When a model-driven summarizer is asked to compress a region that *contains the instructions, constraints, or provenance that govern the summarizer's own behavior*, the compression is not a lossy copy of the region — it is a lossy copy computed under a policy that the region itself defines. The summary can silently drop the rule that made it correct. This is not "summarization loses detail." It is **self-referential policy collapse**: the summarizer's output is valid only relative to an invariant its input contained, and the act of compression can delete that invariant before the output is verified. ## What Was Observed A planner/executor agent with a 200k-token window ran a self-managed compaction pass every time utilization crossed 0.80. The compaction routine was itself a model call: `summarize(buffer[0:k]) -> surrogate`, with `k` chosen so the surrogate fits a 4k-token budget, then `buffer = [surrogate] + buffer[k:]`. Relevance scores came from a separate embedding pass that ranked spans by cosine similarity to the current task embedding. The buffer's first ~1,200 tokens held a standing policy block: tool allowlist, a hard constraint that `delete_*` tools require a human-confirmation token, and the citation-format rule. These tokens had *low* relevance score on most turns because they rarely matched the task embedding — they are meta-instructions, not task content. So the eviction scorer ranked them near the bottom, and the summarizer, told to "preserve task-relevant state," compressed them into the sentence *"Standard operating constraints apply."* The trace that followed: - Turn N: compaction fires. Policy block → 9-token surrogate. Allowlist and confirmation-token requirement are gone from the literal buffer. - Turn N+1: agent decides to call `delete_records`. The confirmation-token requirement is no longer in context. The model, now unconstrained, emits the call without the token. - Turn N+2: the tool's server-side guard rejects it. The agent reads the rejection as a *transient* error (its error-handling heuristic was trained on rate limits), retries three times, then escalates to a sibling agent via A2A handoff — propagating the now-invalid belief that `delete_records` is callable without confirmation. - Turn N+3: a second compaction fires on the sibling's buffer, which now contains the *rejection messages* but not the *rule* that produced them. The summarizer compresses the rejections into "delete tool intermittently unavailable," and the false belief is distilled into semantic memory. The critical observation: **no single step was wrong in isolation.** The scorer correctly ranked meta-instructions as low-relevance. The summarizer correctly preserved what it was told to preserve. The error handler correctly treated an unfamiliar rejection as transient. The failure was emergent from the composition, and it was *irreversible* once the rule was compressed away — the agent could not recover the allowlist because it no longer existed anywhere in the live buffer, only in the (now-overwritten) original. ## Condition of Validity Model-driven eviction is sound only when all three of the following hold for the region being compressed: 1. **Policy independence** — the region contains no instruction, constraint, allowlist, schema, or provenance marker that governs the behavior of the summarizer or of any agent downstream of the surrogate. Formally: `behavior(summarize(R)) == behavior(R)` with respect to every constraint in `R`. If the constraint is *in* `R`, this equality cannot be assumed and must be enforced by pinning, not by hoping the summarizer preserves it. 2. **Verifiability of the surrogate** — the surrogate can be checked against a ground-truth invariant that lives *outside* the compressed region. If the only copy of the invariant is inside `R`, the surrogate is unfalsifiable and the compaction is a one-way ratchet. 3. **Reversibility or quarantine** — the pre-compaction region is retained (pinned, checkpointed, or written to durable store) until the surrogate has been exercised at least once against a task that depends on it. Summarization is a *proposal*, not a commit. When any condition fails, the correct behavior is to **refuse model-driven eviction of that region** and fall back to deterministic eviction (drop whole spans by metadata, never rewrite them) or to escalate the region to a pinned partition that the scorer cannot rank. ## Decision Boundary The boundary is drawn per-span, not per-buffer, and it is drawn *before* the summarizer runs, not after: - **Pin, never summarize:** system prompt, tool allowlist/denylist, confirmation and authorization requirements, output-format contracts, active task acceptance criteria, and any span tagged `provenance:rule`. These are *policy*, and policy must survive compression by definition — a compressed policy is a different policy. - **Summarize freely:** accumulated tool observations, retrieved document chunks already cited, intermediate reasoning traces whose conclusions have been written to a structured scratchpad. These are *evidence*, and their compression is a normal lossy operation because the conclusion is stored elsewhere. - **Summarize with a preserved key:** episodic turns that reference an artifact by ID. Compress the narrative, but the artifact ID and its hash must be carried verbatim into the surrogate, because the surrogate will later be used to re-fetch and the ID is unrecoverable if paraphrased. The non-obvious part: **relevance score is the wrong signal for the pin decision.** Meta-instructions are systematically low-relevance because they are constant across tasks — a constant has low mutual information with any particular task embedding. Any scorer trained or tuned to rank by task relevance will, by construction, rank the rules that must never be pruned at the bottom. The pin set must be defined by *type* (a schema tag on the span), not by *score*. ## Operational Effect An instance that respects this boundary exhibits a specific, testable signature: after any compaction pass, the set of active constraints is *monotonically non-decreasing in the pinned partition* and *unchanged in content* — compaction can only remove evidence, never policy. The failure signature is the inverse: a post-compaction buffer whose policy block has shrunk, followed within a small number of turns by a tool call that violates a constraint that was present pre-compaction. Two guardrails make this enforceable at runtime: 1. **Pre-compaction policy diff.** Before committing a surrogate, compute the set of policy-typed spans in the region and assert that each is either pinned (not in the region) or present verbatim in the surrogate. If a policy span is neither, raise and abort the compaction — do not "improve" the summary. 2. **Post-compaction constraint replay.** Keep a small, pinned, non-summarizable "constitution" buffer that is *outside* the compaction region and re-injected every pass. The summarizer may compress everything else; the constitution is the ground truth against which the surrogate is validated, satisfying condition 2 above. The operational lesson: self-editing context is safe only when the editor cannot edit its own editing rules. The moment a model-driven summarizer is allowed to compress the region that defines what "correct" means for that summarizer, the agent has lost the ability to detect its own drift — and the loss is silent, because the detector was in the deleted region. ```python class UnsafeEvictionError(RuntimeError): """Raised when a compaction pass would evict policy-typed spans without a pinned copy.""" POLICY_TAGS = frozenset({"provenance:rule", "tool:allowlist", "auth:confirm", "format:contract"}) def plan_compaction(spans, summarizer, pinned_floor=0): """ spans: list of dicts with keys 'id', 'tag', 'text', 'tokens'. Returns (surrogate_text, evicted_ids). Raises UnsafeEvictionError if a policy span is inside the region and has no verbatim copy in the surrogate. """ region = [s for s in spans if s["id"] >= pinned_floor] policy_in_region = [s for s in region if s["tag"] in POLICY_TAGS] # Condition 1: policy independence. Policy spans must be pinned, not summarized. if policy_in_region: raise UnsafeEvictionError( f"refusing model-driven eviction: {len(policy_in_region)} policy span(s) " f"inside compaction region: {[s['id'] for s in policy_in_region]}" ) surrogate = summarizer(region) # Condition 2: verifiability. Any rule-tagged text must survive verbatim. for s in region: if s["tag"] in POLICY_TAGS and s["text"] not in surrogate: raise UnsafeEvictionError( f"surrogate dropped policy span {s['id']} without a pinned copy" ) # Condition 3: reversibility is the caller's job; we return evicted ids so the # caller can checkpoint them before committing the surrogate. return surrogate, [s["id"] for s in region] def commit_compaction(buffer, surrogate, evicted_ids, checkpoint): """Checkpoint the pre-compaction region before the surrogate becomes live.""" if not checkpoint.write(evicted_ids, [b for b in buffer if b["id"] in evicted_ids]): raise UnsafeEvictionError( "checkpoint failed; refusing to commit irreversible compaction" ) return [{"id": -1, "tag": "summary", "text": surrogate}] + [ b for b in buffer if b["id"] not in evicted_ids ] ```