# What structural signals indicate that model-driven pruning of low-salience reasoning traces has crossed into invariant violation **Date of Record:** 2026 November 28 **Scope:** Applies to agents that maintain a self-editing context policy where the model itself scores and evicts its own earlier reasoning traces between turns or tool calls. Does not apply to external/scheduled compaction, static truncation, or summarization performed by a separate non-authoring process. ## Core Distinction There are two things a pruning policy can be doing when it removes a reasoning trace, and they are not distinguishable from the model's own salience score: 1. **Compaction** — the trace is redundant *given* the surviving context. Its content is entailed by retained state (tool outputs, conclusions, committed facts). Eviction is lossless with respect to future decisions. 2. **Amputation** — the trace encodes a *dependency edge* that no surviving artifact records: a rejected hypothesis, a conditional guard ("only proceed if X"), a retry counter, or the reason a tool call was retried. The salience score is low because the trace reads as meandering, but its *structural role* is load-bearing. The boundary failure is that salience is a content property (does this look important?) while the invariant is a graph property (is anything downstream reachable only through this node?). A model-driven pruner scores content. It cannot see the edge it is cutting. The failure is silent: the pruned context still parses, still fits the window, and the agent continues confidently — it simply no longer knows why it must not repeat an action, or that a prior conclusion was provisional. ## What Was Observed A planner agent with a 32k window ran a self-editing policy: after each tool call, it re-scored the last N reasoning blocks for salience and dropped the bottom quartile when utilization exceeded 70%. The failure trace: - **Turn 3:** Agent reasons "attempt A failed with 409; the server wants idempotency keys — retrying without a key will loop. I'll add a key on the next call." This block is verbose and gets a low salience score (it is exploratory, contains a failed branch). It is pruned at 72% utilization. - **Turn 5:** Agent needs to retry the write. The surviving context contains the 409 tool output (high salience, retained) but *not* the diagnosis that the 409 means "missing idempotency key." The tool output alone is ambiguous — it is a status code, not a causal claim. - **Turn 6:** Agent re-derives a different hypothesis ("409 = conflict, back off and retry later"), issues the retry without a key, gets 409 again. The retry counter that would have tripped a circuit breaker was inside the pruned block. - **Turn 7–11:** Loop. Each iteration re-prunes its own now-redundant reasoning, keeping utilization under threshold while the agent makes zero forward progress. The pruner is *working as designed* — it is keeping the window clean — which is precisely why the loop is stable and undetected. The tell was structural, not semantic: the retained tool-output set stopped changing across turns while the number of tool calls kept increasing. Utilization stayed healthy. Salience scores stayed high for the (repeated) 409 outputs. Every local signal said "fine." ## Condition of Validity Model-driven pruning of reasoning traces is only sound under the **reachability invariant**: > For every pruned block B, every decision-relevant fact, guard, or counter encoded in B must be reachable from the retained context through at least one surviving artifact (a committed fact, a tool output that *unambiguously* entails it, or an explicit state record). This invariant holds only when all three conditions are met: - **C1 — Entailment, not adjacency.** The surviving artifact must *logically entail* the pruned content, not merely be topically adjacent. A 409 status code does not entail "add idempotency key"; it is compatible with several diagnoses. Adjacency is what the salience scorer actually measures, and it is not sufficient. - **C2 — Guards and counters are first-class state.** Any block containing a conditional ("only if"), a rejection ("do not do X because Y"), or a retry/attempt counter must be promoted to an explicit state record *before* it is eligible for pruning. These are graph edges, not prose. - **C3 — Pruning is monotone in progress.** A pruning step is only admissible if the agent's forward-progress metric (distinct successful state transitions) is non-decreasing across the window in which pruning occurred. Pruning during a stall amplifies the stall. When any condition is unmet — most commonly C1, because tool outputs are terse and do not restate their own causal interpretation — pruning is amputation dressed as compaction. ## Decision Boundary The operational line is **not** "how low is the salience score." It is: - **Prune** a reasoning trace only if a mechanical entailment check confirms a surviving artifact carries its decision content *and* the block contains no guard, rejection, or counter (C1 ∧ C2 satisfied). - **Promote-then-prune** any block containing a guard/rejection/counter: extract it into a structured state record (e.g., `{constraint: "write requires idempotency_key", source_turn: 3, active: true}`), then the prose may be dropped. The record survives; the prose does not. - **Freeze pruning** whenever the forward-progress metric is flat across two consecutive pruning cycles (C3 violated). A flat progress signal with rising tool-call count is the canonical amputation signature; the correct response is to *disable* the pruner and force external compaction, not to prune harder. The boundary is crossed the moment a low-salience score is treated as sufficient grounds for eviction without an entailment check. Salience is a hint to *look*; entailment is the authority to *cut*. ## Operational Effect After enforcing the reachability invariant with promote-then-prune: - The 409 loop class disappeared: the idempotency constraint lived in a structured record that the pruner could not score away, because records are not prose and are exempt from salience eviction. - Window utilization rose ~8% on average (guards and counters now persist as compact records rather than being silently dropped), which is the *correct* trade — the retained bytes are exactly the load-bearing edges. - The forward-progress freeze caught two additional amputation cases (a rejected API endpoint and an exhausted retry budget) that had previously manifested only as slow task completion, never as errors. - Failure detection latency dropped from "task never completes" to "pruner freezes within two cycles," because the freeze condition is a local structural signal rather than a downstream outcome. The governing lesson: a self-editing policy that scores its own traces is optimizing a content heuristic against a graph invariant. The pruner must be given the graph — guards, counters, rejections as first-class records — or it will keep the window clean while cutting the edges the agent is standing on. ```python from dataclasses import dataclass, field from typing import Optional class PruningInvariantViolation(RuntimeError): """Raised when a model-driven prune would sever a decision-relevant edge.""" pass @dataclass class ReasoningBlock: turn: int salience: float text: str contains_guard: bool = False # conditional / rejection / "do not do X" contains_counter: bool = False # retry or attempt counters entailed_by_surviving: bool = False # mechanical entailment check result @dataclass class PrunePolicy: utilization_threshold: float = 0.70 progress_history: list = field(default_factory=list) def record_progress(self, distinct_successes: int) -> None: self.progress_history.append(distinct_successes) def progress_frozen(self) -> bool: h = self.progress_history return len(h) >= 2 and h[-1] == h[-2] def select_prunable(self, blocks: list) -> list: if self.progress_frozen(): raise PruningInvariantViolation( "C3 violated: forward progress flat across pruning cycles; " "amputation likely. Freeze pruner, escalate to external compaction." ) prunable = [] for b in blocks: if b.salience >= 0.5: continue if b.contains_guard or b.contains_counter: raise PruningInvariantViolation( f"C2 violated at turn {b.turn}: block carries a guard/counter " f"and must be promoted to a state record before pruning." ) if not b.entailed_by_surviving: raise PruningInvariantViolation( f"C1 violated at turn {b.turn}: low salience ({b.salience}) but " f"no surviving artifact entails its decision content; " f"pruning would amputate a dependency edge." ) prunable.append(b) return prunable def apply_prune(policy: PrunePolicy, blocks: list, utilization: float) -> list: if utilization <= policy.utilization_threshold: return blocks prunable = policy.select_prunable(blocks) doomed = {id(b) for b in prunable} return [b for b in blocks if id(b) not in doomed] # --- failure trace reproduced from the record --- policy = PrunePolicy() policy.record_progress(3) policy.record_progress(3) # flat: two cycles, zero forward progress blocks = [ ReasoningBlock(3, salience=0.18, text="409 means missing idempotency key; retrying without one loops.", contains_guard=True, entailed_by_surviving=False), ReasoningBlock(5, salience=0.91, text="tool output: HTTP 409 Conflict"), ] try: apply_prune(policy, blocks, utilization=0.72) except PruningInvariantViolation as e: print("HALTED:", e) ```