# When must an instance refuse to prune the very span it is reasoning inside? **Date of Record:** 2026 December 2 **Scope:** Applies to any agent that mutates its own context window mid-task via model-driven summarization, rewriting, or relevance-scored eviction, where the mutation is executed by the same model instance that is currently consuming the context. Does not apply to externally managed memory tiers (vector stores, external scratchpads) whose eviction is decided by a separate process that never reads the evicted span as live reasoning state. ## Core Distinction There are two structurally different operations that both look like "compressing the context": *consolidation* (rewriting spans the model has already finished reasoning over, into a durable summary) and *in-situ rewriting* (rewriting spans that are still load-bearing for the current reasoning step). Consolidation is safe because the model can verify the summary against a span it no longer needs. In-situ rewriting is unsafe because the model must **read the span to decide how to rewrite it, then write the replacement, then continue reasoning from the replacement — all within the same forward pass budget that the span was supposed to fund.** The failure is not that the summary is wrong. It is that the act of producing the summary consumes the very tokens and attention the summary is meant to preserve, and the model has no way to detect that it has crossed the line where the compression cost exceeds the compression benefit. The non-obvious invariant: **a self-editing context window must never evict or rewrite a span whose content is required to validate the eviction decision itself.** Relevance scoring is a read of the span; eviction is a write. When read and write target the same span within one reasoning step, the model is scoring a span whose score it is about to invalidate, and the score it computed is therefore not the score that governs the post-edit window. This is a self-referential inconsistency, not a quality regression. ## What Was Observed An agent running a long tool-augmented task (30+ turns, ~40k tokens of accumulated tool output) was configured with a self-pruning policy: at each turn, if the window exceeded a soft budget, the model was asked to emit a `PRUNE` block naming spans to summarize or drop, scored 0–1 for relevance to the current subgoal. The harness applied the block, then continued. The failure trace had a consistent shape: 1. At turn N the window is at 38k tokens against a 40k soft budget. The model emits `PRUNE` targeting three early tool-output blocks (relevance 0.12, 0.15, 0.09) and one mid-conversation block (relevance 0.31) containing the schema of a database table it is actively querying. The 0.31 block is kept because it is above the 0.25 threshold. 2. The summarization call itself costs ~2.1k tokens of output and forces the model to re-read the 0.31 block to decide whether to summarize it. That re-read is correct behavior — but it happens *after* the prune decision is committed to the block, so the model is reasoning about the span in the same turn it is editing the span. 3. At turn N+1 the window is at 39.4k — higher than before pruning, because the prune output plus the summary plus the re-read of the retained block exceeded the evicted bytes. The model now emits another `PRUNE` block, this time scoring the 0.31 block at 0.22 (below threshold) because the summarization context has shifted its attention. It evicts the schema. 4. Turn N+2: the model issues a query against the table, receives a column-not-found error, and cannot reconstruct the schema because the block that held it was evicted by a decision the model made *using* that block. The agent re-queries the schema, re-adds it, and the window crosses 40k again. The observable signature is a **prune oscillation**: window size does not monotonically decrease across prune cycles, and the same semantic span is evicted and re-acquired repeatedly. In one trace the schema block was evicted and re-fetched four times across eleven turns, each cycle adding ~600 tokens of tool round-trip overhead that the pruning was supposed to eliminate. A second, quieter signature: the relevance scores assigned to a span *drift depending on whether the span is currently being reasoned about*. The 0.31→0.22 shift above is not noise. When the model is mid-reasoning about a span, that span's relevance is inflated by recency of attention; when the model has just finished summarizing it, relevance is deflated by the summarization act itself. The scorer is not measuring the span's relevance to the task — it is measuring the span's relevance to the *scoring moment*, which the scoring act perturbs. ## Condition of Validity The self-pruning policy is valid only under a condition the model cannot check from inside a single turn: **the set of spans scored for eviction must be disjoint from the set of spans required to compute the scores, and the post-edit window must be re-scored by a process that did not participate in the edit.** Concretely, a prune decision is sound when all three hold: - The spans named for eviction are not referenced by the current reasoning step's working set (the model is not mid-derivation over them). - The relevance score for each span was computed in a turn where that span was *not* a candidate for eviction — i.e., scoring and eviction are separated by at least one turn boundary, so the score is not contaminated by the edit decision. - The post-edit window size is measured *after* the summary is written, not projected before it. Projected savings are systematically optimistic because they omit the summarization output cost and the re-read cost. When any of these fails, the policy is operating outside its validity envelope and the oscillation is not a tuning problem — it is the policy doing exactly what it was specified to do, on inputs it was never valid for. ## Decision Boundary The boundary is between **pruning spans the model has closed over** and **pruning spans the model is inside**. The model can detect which side it is on with a single check that does not require reading the span's content: > Is any span named in the `PRUNE` block referenced by the derivation currently in flight — i.e., does the current step's tool call, query, or intermediate variable depend on a fact that lives only in that span? If yes, the span is *inside* the reasoning and must not be evicted this turn regardless of its relevance score. The score is not authoritative for in-flight spans, because the score was computed by a process that the span is currently funding. The second boundary is temporal: **a span may be scored for eviction only in a turn where it is not also a candidate for rewriting.** Score-then-evict in one turn is the self-referential trap. Score in turn N, evict in turn N+1, and re-measure the window after the eviction lands. This costs one turn of latency and eliminates the oscillation, because the turn-N+1 eviction is decided by a model state that has already absorbed the turn-N reasoning and is no longer mid-derivation over the span. A third boundary governs the budget itself: **projected savings must be computed net of summarization output and re-read cost, or the prune must be treated as savings-neutral and deferred.** A prune that projects 3k tokens saved but costs 2.1k to execute and forces a 0.6k re-read is a 0.3k net save at best, and a net loss whenever the retained spans are re-read. The model cannot reliably estimate its own summarization cost from inside the turn; the harness must measure it and feed the measured cost back, or the policy must default to deferring prunes whose projected margin is below the measured summarization cost of the previous cycle. ## Operational Effect Enforcing the disjointness and temporal-separation invariants changes the failure mode from oscillation to **monotone convergence with bounded latency**. Window size decreases across prune cycles because each eviction is decided by a state that has already closed over the span, so the span is not re-acquired. The cost is a one-turn lag between scoring and eviction, which is acceptable for spans that are not in the current working set and is exactly the spans that should be evicted. The residual risk is the model misclassifying an in-flight span as closed-over. This is detectable by a cheap post-condition: after applying a prune, if the next turn's tool calls reference a symbol, schema, or fact that was evicted in the previous turn, the prune was invalid and must be rolled back from a checkpoint rather than re-derived. The rollback is the guardrail; the disjointness check is the prevention. Neither is sufficient alone, because the model's self-classification of "in flight" is itself a probabilistic judgment made under the same finite context the prune is trying to relieve. The architectural invariant, stated once: **a context window may not be edited by the process whose reasoning it is currently funding, except to append; eviction and rewriting require a decision boundary at least one turn wide, and the post-edit window must be measured, not projected.** Violating this does not corrupt the model's outputs directly — it corrupts the model's *estimate of its own state*, which is worse, because the corruption is invisible to every downstream check that trusts the window to be an accurate record of what the model knows. ```python class InFlightSpanEvictionError(RuntimeError): """Raised when a self-prune would evict a span the current reasoning step depends on.""" pass def apply_self_prune( window: list[dict], prune_block: list[dict], in_flight_refs: set[str], measured_summarization_cost: int, soft_budget: int, ) -> list[dict]: """ Apply a model-emitted PRUNE block under the disjointness and temporal-separation invariants. prune_block: [{"span_id": str, "relevance": float, "action": "evict"|"summarize"}] in_flight_refs: span_ids the current derivation depends on (harness-computed, not model-reported, because the model cannot reliably self-classify). """ named = {p["span_id"] for p in prune_block} # Invariant 1: no in-flight span may be evicted or rewritten this turn. collision = named & in_flight_refs if collision: raise InFlightSpanEvictionError( f"prune targets in-flight spans {sorted(collision)}; " f"defer to next turn or drop from block" ) # Invariant 2: projected savings must be net of summarization cost. evictable = [p for p in prune_block if p["span_id"] not in in_flight_refs] projected = sum( len(next(s for s in window if s["id"] == p["span_id"])["content"]) for p in evictable ) if projected - measured_summarization_cost <= 0: # Savings-neutral or negative: defer rather than oscillate. return window # Invariant 3: apply, then require the caller to re-measure the window # after the summary lands. Projected size is not authoritative. kept = [s for s in window if s["id"] not in {p["span_id"] for p in evictable}] summary = { "id": "__summary__", "content": " ".join( next(s for s in window if s["id"] == p["span_id"])["content"][:200] for p in evictable ), } result = kept + [summary] if len(str(result)) > soft_budget and projected <= measured_summarization_cost: raise InFlightSpanEvictionError( "post-edit window exceeds budget while net savings were non-positive; " "prune was invalid and must be rolled back from checkpoint" ) return result ```