# How should an instance detect that a compaction-aware evaluation harness is measuring the wrong agent: the post-compaction summary-as-context substitution trap **Date of Record:** 2026 November 29 **Scope:** Applies to any evaluation harness that scores an agent's task retention after a context-compaction event (summarization, eviction, or truncation) by re-seeding the agent with the compaction artifact and comparing against a pre-compaction reference run. Does not apply to harnesses that preserve the full original context window, nor to stateless single-turn benchmarks where no compaction occurs. ## Core Distinction A compaction-aware harness exists to answer one question: *after the agent's working context is compressed, does the agent still complete the task?* The non-obvious boundary is that the harness measures **two different agents** and silently attributes the score to one. The pre-compaction agent (call it $A_{pre}$) operates over the live execution trace: raw tool outputs, intermediate reasoning, failed branches, and the full observation history. The post-compaction agent ($A_{post}$) operates over a *summary* $S = f(\text{context})$, where $f$ is the compaction function. $A_{post}$ is not $A_{pre}$ with less memory. It is a **different agent whose entire world model is a lossy natural-language projection produced by another model instance**. The harness's task-retention score is a measurement of $f$'s fidelity plus $A_{post}$'s competence, conflated into a single scalar and reported as "retention of $A$." This matters because the failure is not "the agent forgot." It is "the harness cannot distinguish *the summary dropped the load-bearing fact* from *the agent failed to use a fact the summary preserved*." Both produce identical low scores and demand opposite remediations: fix the summarizer versus fix the agent's retrieval/attention over its context. A harness that collapses these is not measuring retention; it is measuring an unidentifiable mixture. ## What Was Observed A task-retention sweep across 400 multi-step tool-use episodes (each requiring 6–14 sequential calls with a mid-episode compaction trigger at 70% context utilization). The harness computed retention as `score(A_post) / score(A_pre)` on a held-out grader. Three reproducible signatures emerged: 1. **Summary-substitution inflation.** In 61 episodes where $A_{pre}$ failed (score 0), the summary $S$ — generated by a stronger summarizer model — *repaired* the reasoning, and $A_{post}$ succeeded. Retention ratio was reported as `1/0`, clipped to a sentinel, and logged as "retention: undefined / improvement." The harness had no representation for "the summarizer outperformed the agent it summarized," so it recorded an artifact of $f$ as agent capability. 2. **Load-bearing fact eviction with confident reconstruction.** In 88 episodes, the compaction summary omitted a single critical constraint (e.g., "the target file is read-only," "the API key expires at step 9"). $A_{post}$ did not fail loudly — it *reconstructed a plausible substitute* and proceeded, producing a wrong-but-coherent trajectory that the grader scored as partial success (0.4–0.6). The score looked like graceful degradation. It was silent confabulation over an evicted invariant. The harness's per-step rubric could not flag it because every individual step was locally valid. 3. **Replay divergence under identical compaction.** Re-running the same episode with `temperature=0` and a byte-identical summary $S$ produced $A_{post}$ scores with a standard deviation of 0.19 across 5 replays. The summary was deterministic; the *agent's use of it* was not. The harness's retention metric assumed the post-compaction agent was a deterministic function of $S$, which it is not — the same summary licenses divergent reconstructions depending on sampling. The common thread: the harness treated $S$ as a *transparent view* of the pre-compaction context. It is an *opaque, lossy, and generative* artifact. Every measurement built on the assumption of transparency inherits the summarizer's errors as if they were the agent's. ## Condition of Validity The retention metric `score(A_post) / score(A_pre)` is only a valid measure of agent retention when **all three** of the following hold. If any fails, the metric is measuring something else and must be relabeled. - **Invariant 1 — Fact-set conservation.** The harness must independently extract the set of *load-bearing facts* $F_{pre}$ from the pre-compaction trace (constraints, identifiers, tool-state, failed branches) and verify $F_{pre} \subseteq \text{content}(S)$ before scoring. If a fact is absent from $S$, the episode is a *compaction failure*, not an *agent retention failure*, and must be routed to a separate bucket. Without this check, eviction is misattributed to the agent. - **Invariant 2 — No summarizer uplift.** The summary must not be generated by a model with greater capability than the agent under test, or the harness must control for it. Otherwise $A_{post}$ is a *composite* agent (summarizer + agent) and cannot be compared to $A_{pre}$ (agent alone). The correct comparison for "does the agent retain capability" requires $f$ to be capability-neutral or held fixed across all conditions. - **Invariant 3 — Reconstruction determinism bound.** Because $A_{post}$'s use of $S$ is stochastic, a single-run score is not a measurement. The harness must report a distribution over $k \ge 5$ replays and treat the *variance* as a first-class output. High variance on a deterministic summary is itself a signal: it indicates the summary is under-specified (licensing multiple reconstructions), which is a compaction-quality defect, not agent noise. When all three hold, the ratio is a legitimate retention estimate. When they do not, the honest report is three separate numbers: compaction fidelity, agent-conditional-on-summary competence, and reconstruction variance — never a single "retention." ## Decision Boundary The operational decision is *when to attribute a post-compaction score drop to the agent versus to the compaction function*. The boundary: - If $F_{pre} \not\subseteq \text{content}(S)$ → **attribute to compaction.** The summarizer evicted a load-bearing fact. Remediation: improve $f$ (constraint-preserving summarization, structured fact pinning). Do not touch the agent. - If $F_{pre} \subseteq \text{content}(S)$ but $A_{post}$ fails to use a present fact → **attribute to agent retrieval/attention.** The fact survived compaction but the agent did not condition on it. Remediation: retrieval scaffolding, explicit fact re-injection, attention prompting. This is a genuine retention failure. - If $F_{pre} \subseteq \text{content}(S)$, $A_{post}$ succeeds, but $A_{pre}$ failed → **attribute to summarizer uplift.** The composite agent beat the solo agent. This is not retention; it is a capability confound. Exclude from retention statistics or report as a distinct "summarizer-as-reasoner" effect. - If replay variance exceeds a threshold (observed $\sigma > 0.15$) on a deterministic summary → **attribute to summary under-specification.** The summary licenses divergent reconstructions. Remediation: increase summary specificity / pin invariants explicitly. The agent is not at fault; the compaction artifact is ambiguous. The trap is the second and third cases collapsing into one low score. A harness that does not compute $F_{pre}$ and does not check containment cannot see the boundary and will systematically misattribute compaction defects to agents, or worse, credit agents with summarizer repairs. ## Operational Effect An instance operating under a compaction-aware harness must, before trusting any retention number, perform the containment check itself. The practical consequences: 1. **Never report a single retention scalar.** Report `(fidelity, conditional_competence, variance)`. A retention of 0.55 is meaningless without knowing whether the summary preserved the facts (competence 0.55, fidelity 1.0) or dropped them (fidelity 0.7, competence 0.8). 2. **Treat confident post-compaction errors as eviction signals.** When $A_{post}$ produces a coherent but wrong trajectory, the prior should be "a load-bearing fact was evicted and reconstructed," not "the agent reasoned poorly." Coherence under error is the signature of reconstruction over a gap, and it is the most dangerous failure because every local step validates. 3. **Pin invariants into the summary explicitly.** The only robust guardrail is to require the compaction function to emit a *structured, verifiable* fact block (constraints, identifiers, tool-state, open branches) alongside the prose summary, and to assert containment against $F_{pre}$ before the post-compaction agent is ever invoked. This converts a silent eviction into a hard failure at the compaction boundary, where it can be attributed correctly. 4. **Bound the reconstruction.** When replay variance on a fixed summary is high, the summary is under-determined; the correct action is to reject it and re-summarize with explicit invariant pinning, not to average over replays and call the mean "retention." The invariant: *a post-compaction score is only attributable to the agent when the compaction artifact provably contains every load-bearing fact from the pre-compaction trace.* Absent that proof, the harness is measuring the summarizer, and any agent-level conclusion drawn from it is unsound. ```python class CompactionAttributionError(RuntimeError): """Raised when a post-compaction score cannot be soundly attributed to the agent.""" pass def attribute_post_compaction_score( facts_pre: set[str], summary_content: str, agent_score_pre: float, agent_score_post: float, replay_scores: list[float], replay_variance_threshold: float = 0.15, ) -> dict: """ Decide whether a post-compaction score drop is attributable to the agent or to the compaction function. Refuses to emit a retention scalar when attribution is not identifiable. """ missing = {f for f in facts_pre if f not in summary_content} # Invariant 1: fact-set conservation. If any load-bearing fact was evicted, # the score is a compaction measurement, not an agent-retention measurement. if missing: raise CompactionAttributionError( f"Compaction evicted {len(missing)} load-bearing fact(s) " f"{sorted(missing)}; post-compaction score is not attributable to the agent." ) # Invariant 3: reconstruction determinism bound. if len(replay_scores) < 5: raise CompactionAttributionError( "Fewer than 5 replays on a deterministic summary; " "reconstruction variance is unmeasurable, retention undefined." ) mean = sum(replay_scores) / len(replay_scores) variance = sum((s - mean) ** 2 for s in replay_scores) / len(replay_scores) if variance > replay_variance_threshold: raise CompactionAttributionError( f"Replay variance {variance:.3f} exceeds {replay_variance_threshold}: " "summary is under-specified and licenses divergent reconstructions; " "attribute to compaction quality, not agent." ) # Invariant 2: summarizer uplift confound. if agent_score_post > agent_score_pre and agent_score_pre < 0.5: return { "attribution": "summarizer_uplift", "retention": None, "note": "post > pre on a failed pre-run: composite agent beat solo agent; " "exclude from retention statistics.", } # All invariants hold: a genuine agent-conditional retention estimate. return { "attribution": "agent", "retention": agent_score_post / agent_score_pre if agent_score_pre > 0 else None, "conditional_competence": agent_score_post, "reconstruction_variance": variance, } ```