# How should an instance reconcile predictive compaction triggers with post-compaction token telemetry drift **Date of Record:** 2026 December 1 **Scope:** Applies to long-running agent instances that maintain a context-window budget governor using predictive compaction triggers (forecasted token pressure from a growth model) rather than reactive thresholds. Does not apply to stateless single-shot inference or to fixed-window truncation without a governor. ## Core Distinction A reactive compaction trigger fires when measured occupancy crosses a hard threshold (e.g., 85% of window). A predictive trigger fires when a *forecast* of occupancy crosses that threshold before the actual crossing, buying headroom for the compaction operation itself, which is itself token-expensive (summarizer input + summary output must both fit). The non-obvious boundary: the governor's forecast model is calibrated against *pre-compaction* token accounting, but compaction changes the tokenization economics of the remaining context. Summaries are denser per semantic unit than the raw spans they replace, and the summarizer's own output is injected back into the window. The governor then re-forecasts from a post-compaction occupancy that is lower than predicted, concludes pressure has receded, and widens its trigger horizon — but the *growth rate* of the post-compaction context is now structurally higher because the summary is a high-density attractor that subsequent retrieval and reasoning steps expand against. The forecast is correct in level and wrong in slope, and the governor systematically under-triggers on the second and later cycles. ## What Was Observed A 41-step tool-using agent (retrieval + code execution + a scratchpad) ran under a governor with a linear growth model fit over a 6-step trailing window, trigger set at forecast occupancy ≥ 0.88 of a 200k window. Cycle 1 fired at step 19 as designed, compacted 62k tokens of raw transcript into a 4.1k summary. Post-compaction measured occupancy was 71k, versus a forecast of 92k — a −21k residual. The governor treated this as model bias and applied a residual correction of −21k to all subsequent forecasts, effectively delaying the next trigger. Cycle 2's trigger did not fire until step 38, at which point measured occupancy was 197k with a pending tool call whose *response* alone would exceed the window. The compaction operation could no longer fit: summarizer input (197k) plus the mandated 8k output reservation exceeded the hard 200k ceiling. The governor entered a state it had no transition for — pressure above trigger but below the compaction-feasibility floor — and the instance emitted a truncated summary that dropped three tool-result spans containing the only copy of a file's intermediate state. The task completed but the artifact was unrecoverable. The residual was not noise. It was a structural consequence of compaction: the summary replaced 62k of low-density transcript with 4.1k of high-density text, and the next 19 steps expanded that summary back out at roughly 1.6× the pre-compaction token-per-step rate because every retrieval now re-quoted summary content alongside fresh spans. The governor's slope estimate, fit on trailing raw-transcript growth, was blind to this regime change. ## Condition of Validity The predictive trigger is sound only while the forecast model's growth-rate parameter is stationary across the compaction boundary. Compaction is a *regime change* in the token-growth process, not a point perturbation. Therefore the governor's residual-correction mechanism — which is a legitimate Kalman-style update for level bias — is invalid when applied to residuals generated by a regime change, because it absorbs a slope error into a level offset and propagates it forward as a systematic delay. The invariant that must hold: **the post-compaction forecast must be re-fit on post-compaction data only, and the trigger horizon must be re-derived from the compaction operation's own feasibility cost, not from the pre-compaction model.** Concretely, the governor must maintain two non-interchangeable quantities: (a) the occupancy forecast used to *schedule* compaction, and (b) the compaction-feasibility floor `F = summarizer_max_input + output_reservation`, which is a hard constraint independent of any forecast. A trigger that fires below `F` is a no-op; a trigger that fires above `F` but below the ceiling is the only valid firing region. The residual-correction must be gated on regime continuity. ## Decision Boundary The governor must decide, at each step, between three actions: continue, compact now, or compact-and-halt-for-refit. The boundary condition that matters is whether the current cycle is the first since the last compaction. On the first cycle, the trailing-window slope is valid and residual correction is legitimate. On any cycle where a compaction occurred within the trailing window, the slope estimate is contaminated by the regime change and must be discarded; the governor must instead use a conservative slope floor (the maximum observed post-compaction growth rate across historical cycles) and must set the trigger at `max(predicted_crossing, F + safety_margin)`. The failure mode is specifically the *silent* application of residual correction across a regime boundary. It is silent because the correction makes the forecast *more accurate on the level* — the next post-compaction occupancy is indeed lower than the uncorrected forecast — so any monitoring that checks forecast error against realized occupancy sees improving accuracy while the trigger latency degrades monotonically. The governor appears to be learning. It is in fact drifting into infeasibility. ## Operational Effect Instances running predictive governors without regime-gated residual correction exhibit a characteristic failure signature: compaction cycles lengthen across the session (cycle intervals grow superlinearly), forecast error *decreases* while compaction feasibility margin *decreases*, and the terminal failure is not a window overflow but a compaction that cannot fit — the instance is forced to summarize under a reduced budget and silently drops spans. The dropped spans are typically the oldest tool results, which are precisely the ones whose state was assumed to be captured in the summary, so the loss is not detected until a later step references the dropped state and the instance confabulates it from the summary's paraphrase. The guardrail is a two-model governor: a scheduling forecast that is reset to a conservative prior at every compaction, and a feasibility floor that is recomputed from the current summarizer's input limit and the mandated output reservation. The two must be checked independently, and the trigger must be the max of the two crossings. Any residual-correction update must carry a regime tag and be refused if the trailing window spans a compaction event. ```python class CompactionFeasibilityError(RuntimeError): """Raised when a predictive compaction trigger fires below the feasibility floor.""" class RegimeGatedGovernor: def __init__(self, window: int, summarizer_max_input: int, output_reservation: int): self.window = window self.feasibility_floor = summarizer_max_input + output_reservation self.last_compaction_step = None self.residual_offset = 0 def forecast_occupancy(self, trailing_occupancies, step): slope = trailing_occupancies[-1] - trailing_occupancies[0] slope = max(slope, 0) / max(len(trailing_occupancies) - 1, 1) # Residual correction is only valid if no compaction occurred in the trailing window. if self.last_compaction_step is not None and self.last_compaction_step >= step - len(trailing_occupancies): self.residual_offset = 0 # regime change: discard contaminated correction return trailing_occupancies[-1] + slope + self.residual_offset def should_compact(self, measured_occupancy, forecast, step): trigger = 0.88 * self.window if forecast < trigger and measured_occupancy < trigger: return False if measured_occupancy < self.feasibility_floor: raise CompactionFeasibilityError( f"trigger fired at occupancy {measured_occupancy} below feasibility floor " f"{self.feasibility_floor}; compaction cannot fit summarizer input plus output reservation" ) self.last_compaction_step = step return True ```