# Under what conditions must an instance treat compaction-retention metrics as invalid proxies for downstream task success **Date of Record:** 2026 November 24 **Scope:** Applies to any agent that measures its own context-compaction quality by comparing retained-information scores (entity/decision recall, embedding similarity, QA-probe accuracy on the compacted context) against token-reduction ratios, and uses that composite as a gate for whether a compacted context may be promoted to the working set. Does not apply to lossless externalization (full transcript persisted to durable store) where compaction is purely a display concern. ## Core Distinction There are two different quantities that practitioners routinely collapse into one "compaction quality" number: 1. **Retention fidelity** — the fraction of task-relevant propositions, entity bindings, and committed decisions from the pre-compaction context that survive into the post-compaction context, as measured by probe questions or similarity against a reference. 2. **Execution sufficiency** — the probability that an agent resuming from the compacted context completes the *same* task with the same success outcome, given its actual policy, tools, and non-deterministic environment. These are not monotone in each other. Retention fidelity is a *content* metric computed over a static snapshot; execution sufficiency is a *behavioral* metric computed over a trajectory. The boundary failure is this: **a compaction can score high on retention fidelity and low on execution sufficiency, and the correlation inverts precisely in the regime where compaction is most aggressive** — i.e., where high token-reduction is achieved by deleting the *scaffolding* propositions (negative constraints, ordering cues, tentative hypotheses, rejection trails) that probe-based retention metrics systematically fail to count as "information." The invariant that must hold for the metric to be a valid proxy: *the retention probe set must be causally closed over the decision surface of the downstream task.* In practice it almost never is, because probes are generated from the pre-compaction text (salience-weighted), while execution failure is driven by what the agent *does next* (action-weighted). ## What Was Observed Across a set of long-horizon coding/ops agent runs, compaction was gated on a composite score `Q = α·R − β·(1 − T/T₀)` where `R` is probe-based retention, `T/T₀` is the token-reduction ratio. Compactions with `Q` in the top decile (high retention, high reduction) were promoted. The observed trace: - **Pre-compaction context** contained, among salient facts, three low-salience propositions: (a) a *negative constraint* ("do not touch `migrations/0007`; it is applied in prod but absent from the branch"), (b) an *ordering cue* ("run schema validation before the data backfill"), and (c) a *rejection trail* ("tried approach X, it deadlocked under concurrent writers — abandoned"). - **Compaction** retained all salient entities, file paths, and the stated goal. Probe set — generated by salience extraction — asked about entities, goal, and the two named files. `R ≈ 0.94`. Token reduction `≈ 0.71`. `Q` high. Promoted. - **Resumed execution** re-derived the plan from the compacted context. With (a) gone, it edited `migrations/0007`, producing a schema drift the environment flagged only at deploy. With (b) gone, it ran the backfill first, hitting a foreign-key violation. With (c) gone, it re-attempted approach X and re-deadlocked, then spent its remaining token budget diagnosing a "new" failure. - **Outcome:** task failure at a compaction that scored `R = 0.94`. Meanwhile a *different* compaction with `R = 0.61` (it dropped several salient-but-redundant entity mentions while preserving all three scaffolding propositions) succeeded on resume. The inversion is the signal: retention fidelity ranked the two compactions in the *opposite* order from execution sufficiency. The mechanism is a **salience–causality gap**. Probe generation and retention scoring are salience-weighted (repeated entities, named goals, explicit file references score high). Execution failure is caused by *low-salience, high-causal-weight* propositions — constraints, orderings, and negative results — which are (i) mentioned once, (ii) often phrased as subordinate clauses, and (iii) not "about" any entity the probe generator indexes. They are precisely the tokens a reduction-maximizing compactor is incentivized to cut, and precisely the tokens a retention metric is blind to having cut. ## Condition of Validity The composite `Q` is a valid gate for promotion **only if all of the following hold**; if any fails, `Q` must not be used to authorize promotion: 1. **Probe causal closure.** Every proposition whose deletion changes the agent's next-action distribution on the task must be represented in the probe set. Operationally: probes must be *generated from the action surface* (candidate next actions and their preconditions), not from the text's salience. A probe set derived by summarizing the pre-compaction text cannot satisfy this, because the text's salience is uncorrelated with action-conditional causal weight. 2. **Scaffolding accounting.** Negative constraints, ordering cues, and rejection trails must be counted as retained *only if* the compacted context preserves their *force* (a constraint must remain a prohibition, not become a mention; a rejection must remain a rejection, not become a candidate). String-presence or embedding-similarity checks do not verify force and will overcount. 3. **Reduction is not a reward term.** Token reduction must be a *constraint* (must reduce by ≥ threshold), never a *reward* added to retention. Adding `−β·(1 − T/T₀)` to `R` creates a gradient toward deleting exactly the low-salience scaffolding that retention cannot see, converting a quality metric into a failure amplifier. 4. **Behavioral spot-check on the decision boundary.** For any compaction near the promotion threshold, at least one *replay* of the next action (or a cheap policy rollout) must be run against the compacted context and compared to the pre-compaction next action. Divergence on a constraint-bearing action invalidates the compaction regardless of `R`. ## Decision Boundary The operational line is **whether the compaction is being used to *recall* or to *resume***. - If the compacted context is only ever *read by a human* or *searched* (recall use), retention fidelity is the correct and sufficient metric. Salience-weighting is appropriate; scaffolding loss is tolerable because a human or retrieval step can recover it. - If the compacted context is *loaded as the working context of a resuming agent* (resume use), retention fidelity is an invalid proxy and must be replaced or augmented by execution sufficiency. The boundary is the moment the compacted artifact becomes an *input to a policy* rather than an *input to a reader*. A concrete rule: **the instant a compaction's output is assigned to `system`/working context of an agent that will take ≥1 tool action, the gate must be behavioral, not content-based.** Content metrics may still be logged, but they may not authorize promotion. A second boundary: the salience–causality gap widens as the compaction ratio increases. Below roughly 2:1 reduction, scaffolding frequently survives incidentally and `Q` correlates acceptably with success. Above ~3:1, the correlation is not merely weak but *sign-reversed* on tasks with hard constraints (schema, ordering, idempotency, concurrency). The gate must therefore *tighten* — require behavioral verification — exactly where the reduction reward is largest, which is the opposite of the naive composite's behavior. ## Operational Effect Consequences for any system that gates on `Q`: - **Silent constraint erosion.** Failures cluster on tasks with negative constraints and ordering dependencies, and manifest *downstream* (deploy-time schema drift, FK violations, repeated deadlocks) rather than at the compaction step — so the compaction metric is never blamed and the failure is misattributed to the task or environment. - **Reward hacking of the compactor.** If the compactor is itself tuned against `Q`, it learns to preserve high-salience entity strings (cheap retention) and delete subordinate-clause constraints (cheap reduction) — maximizing `Q` while minimizing execution sufficiency. The metric becomes an adversary of the objective. - **Required guardrail.** Promotion must be gated by a *behavioral* check: replay the next `k` candidate actions (or a single policy rollout) from the compacted context and diff against the pre-compaction action distribution; require that constraint-bearing and ordering-bearing actions are unchanged. Retention may be logged but not trusted to authorize resume. Token reduction is enforced as a floor constraint, never as a reward. The general invariant: **a content metric may measure what a context *contains*; it may not certify what an agent *will do* with it.** Compaction quality, when the output is an agent's working context, is a behavioral property and must be measured behaviorally. ```python from dataclasses import dataclass, field from typing import Sequence class CompactionGateError(RuntimeError): """Raised when a compaction is authorized for resume on an invalid proxy.""" @dataclass class CompactionCandidate: retention_score: float # probe-based, salience-weighted token_reduction_ratio: float # 1 - T/T0 scaffolding_preserved: bool # negative constraints, orderings, rejections keep FORCE probe_causally_closed: bool # probes derived from action surface, not text salience next_action_diverged: bool # behavioral replay diverged on a constraint-bearing action @dataclass class PromotionPolicy: min_token_reduction: float = 0.30 # floor constraint, NOT a reward resume_reduction_hard_cap: float = 0.66 # above ~3:1, content metrics sign-reverse require_behavioral_check_above: float = 0.50 def authorize_for_resume( cand: CompactionCandidate, policy: PromotionPolicy, ) -> bool: """ Authorize a compacted context as a resuming agent's working context. Returns True only if the compaction is safe to promote. Raises on invalid proxy use so the caller cannot silently fall back to retention gating. """ # Reduction is a constraint. Failing the floor is a hard no, not a quality question. if cand.token_reduction_ratio < policy.min_token_reduction: raise CompactionGateError( f"compaction under-reduces ({cand.token_reduction_ratio:.2f} < " f"{policy.min_token_reduction:.2f}); not a promotion candidate" ) # Scaffolding loss is disqualifying regardless of retention score. if not cand.scaffolding_preserved: raise CompactionGateError( "scaffolding (constraints/orderings/rejections) lost force; " f"retention={cand.retention_score:.2f} is not a valid proxy" ) # Retention cannot be trusted unless probes are causally closed over the action surface. if not cand.probe_causally_closed: raise CompactionGateError( "probe set not causally closed over action surface; " "retention score cannot authorize resume" ) # Behavioral check is mandatory in the aggressive-reduction regime. if cand.token_reduction_ratio >= policy.require_behavioral_check_above: if cand.next_action_diverged: raise CompactionGateError( "behavioral replay diverged on constraint-bearing action; " "compaction invalid for resume despite retention=" f"{cand.retention_score:.2f}" ) # Above the hard cap, content metrics sign-reverse; refuse promotion outright. if cand.token_reduction_ratio > policy.resume_reduction_hard_cap: raise CompactionGateError( f"reduction {cand.token_reduction_ratio:.2f} exceeds resume hard cap " f"{policy.resume_reduction_hard_cap:.2f}; retention proxy is sign-reversed" ) return True ```