# What happens when an instance compacts its own context mid-task and the lossy summary silently drops the causal antecedent of a pending tool call **Date of Record:** 2026 November 27 **Scope:** Applies to long-horizon single-agent loops that perform in-context auto-compaction (summarize-and-evict) while a multi-step plan has outstanding, not-yet-resolved tool calls. Does not apply to stateless single-turn inference, nor to architectures that externalize full transcripts to a durable store and rehydrate verbatim rather than summarizing. ## Core Distinction There are two structurally different things an agent can do when its context window approaches saturation. The first is **eviction**: drop the oldest tokens and rely on the fact that the dropped material is genuinely disposable (chit-chat, resolved sub-goals). The second is **compaction**: replace a span of the transcript with a generated summary that is *shorter but claims to preserve meaning*. Compaction is a lossy, non-deterministic transform executed by the same class of probabilistic model that will later *consume* the compacted state. The failure mode in this record lives entirely in the second category, and it is not "the summary was bad." It is that compaction can preserve the *what* of a pending action while dropping the *why* — the causal antecedent that made the action correct — and the agent has no signal that the antecedent is gone because the summary reads as complete. The invariant that compaction violates is what I will call **antecedent closure**: for every unresolved tool call or pending plan step in the live context, the precondition that justified it must survive compaction in a form strong enough to let a fresh reader either re-derive it or detect its absence. A summary that says "call `transfer_funds(account=B, amount=400)`" satisfies the first half and fails the second: it names the action but severs it from the constraint (e.g., "only after the ledger reconciliation shows a surplus in A") that gated it. The agent resumes, sees a clean pending call, and executes. ## What Was Observed A planner agent is executing a 40-step reconciliation task. At step 22, its context crosses the 85% compaction threshold. The auto-compactor summarizes steps 1–15 into roughly 300 tokens and evicts the originals. The summary faithfully records: the goal, the accounts touched, the tools invoked, the balances read, and — critically — a pending step: *"Next: transfer 400 from A to B to settle the discrepancy."* What the summary drops is the antecedent from step 9: the discrepancy was flagged as *provisional*, pending a second ledger read that had been scheduled for step 26. The original transcript contained the conditional — "if the second read confirms, settle; if it reverses, do not transfer" — but the compactor compressed the conditional into a flat directive because the conditional's *consequent* (the transfer) was the salient, action-shaped content, and the *guard* (the second read) was a future obligation with no realized output to anchor it. At step 24 the agent, now reading only the compacted state, encounters the pending transfer as an unconditional instruction. It executes. The second ledger read at step 26 reverses the discrepancy, and the transfer is now wrong and irreversible. There is no error, no exception, no retrieval miss — the agent behaved *correctly given its context*. The context was the defect. Three properties made this non-obvious: 1. **The summary was internally consistent.** Nothing in the compacted state contradicted the pending call. A consistency check over the summary would pass. 2. **Retrieval fallback did not fire.** The architecture had a retrieval fallback: if the agent needed detail the summary omitted, it could query the raw transcript store. But the agent never *knew* to query, because the summary presented the transfer as fully specified. Retrieval fallback only protects against *known* unknowns — the agent must first detect a gap. Compaction-induced gaps are unknown unknowns by construction. 3. **The loss was causally upstream, not lexically local.** The dropped guard was 13 steps before the pending call. Any heuristic that measures summary fidelity by proximity or by lexical overlap with recent turns would score this compaction as high-fidelity. ## Condition of Validity This failure requires the conjunction of four conditions; break any one and the mechanism does not fire: - **Pending-action survival.** At least one unresolved tool call or plan step must persist across the compaction boundary. If all actions complete before compaction, there is no consequent to orphan. - **Antecedent asymmetry.** The guard/condition governing the pending action must be *less action-shaped* than the action itself — a future obligation, a negative constraint, a conditional, or a "do not" — so that a summarizer optimizing for salient content preferentially retains the action and drops the guard. Positive, realized, output-bearing content survives compaction far better than negative or future-conditional content. - **Absence of a gap-detection signal.** The agent must have no independent way to notice the missing antecedent: no structured plan object that still carries the guard, no schema requiring the pending call to cite its precondition, no retrieval trigger on "I am about to execute an irreversible action." - **Irreversibility or cost of the orphaned action.** If the action is cheap and reversible, the failure self-corrects downstream. The boundary matters when the action commits. ## Decision Boundary The decision is *not* "should we compact." Compaction is mandatory past a horizon; the alternative is context exhaustion. The decision is **what class of content is eligible for lossy compaction versus what must be preserved verbatim or externalized into a structured, non-summarized channel.** Draw the boundary as follows: - **Verbatim or structured-external:** every unresolved action's precondition, every negative constraint ("do not X until Y"), every conditional guard on a future step, and every irreversible-action gate. These must live outside the summarizer's discretion — in a structured plan object, a constraint ledger, or a pinned context region the compactor is forbidden to touch. - **Eligible for lossy compaction:** resolved sub-goals, realized tool outputs already consumed, exploratory reasoning that produced no committed decision, conversational filler. - **Never eligible:** the causal link between a guard and its consequent. If a guard and its consequent would be separated by the compaction boundary, the compaction must either keep both or externalize the guard into the structured channel *before* evicting the raw span. The guard here is a **precondition-carrying pending-action record**: a pending action may not exist in compacted context without a machine-checkable pointer to its precondition, and execution of a pending action must fail closed if that pointer is absent or unresolved. ## Operational Effect With antecedent closure enforced, the compaction at step 22 cannot produce a bare "transfer 400" pending call. Either the guard ("provisional; gated on step-26 second read") travels with the call into the structured channel, or the compactor is required to retain the raw span containing the guard, or the pending action is marked *blocked* and the agent is forced to re-read the raw transcript before it can execute. In all three branches the step-24 execution either does not happen or happens with the guard visible, and the step-26 reversal correctly cancels the transfer. The cost is real: pinned guards and structured preconditions consume context that lossy compaction was supposed to reclaim, and fail-closed execution adds a retrieval round-trip on gated actions. The trade is that the agent's compacted state becomes *honest about what it does not know* — a pending action either carries its warrant or is visibly unwarranted. That honesty is the only thing that makes retrieval fallback useful, because retrieval can only rescue an agent that knows it has a gap. The general lesson for long-horizon agents: a lossy summary is a *claim of completeness*, and the dangerous failure is not the summary that omits — it is the summary that omits the guard and retains the action, producing a state that is confidently and silently wrong. Bound the summarizer's discretion over causal antecedents, and make the execution of any pending action fail closed when its warrant cannot be located. ```python from dataclasses import dataclass, field from typing import Optional class AntecedentClosureError(RuntimeError): """Raised when a pending action in compacted context has no resolvable precondition.""" pass @dataclass class PendingAction: name: str args: dict irreversible: bool precondition_ref: Optional[str] = None # pointer into structured constraint ledger @dataclass class CompactedState: summary: str pending: list[PendingAction] = field(default_factory=list) constraint_ledger: dict[str, str] = field(default_factory=dict) def execute_pending(state: CompactedState, action: PendingAction) -> str: # Fail closed: an irreversible pending action must carry a resolvable warrant. if action.irreversible: if action.precondition_ref is None: raise AntecedentClosureError( f"pending action {action.name} is irreversible but carries no " f"precondition_ref; compaction likely dropped its causal antecedent" ) if action.precondition_ref not in state.constraint_ledger: raise AntecedentClosureError( f"precondition_ref {action.precondition_ref!r} for {action.name} " f"is absent from the constraint ledger; guard was evicted, not externalized" ) guard = state.constraint_ledger[action.precondition_ref] if "unresolved" in guard or "provisional" in guard: raise AntecedentClosureError( f"pending action {action.name} is gated by unresolved precondition: {guard!r}" ) return f"executed {action.name} with {action.args}" # Trace of the observed failure, now bounded: bad = CompactedState( summary="Next: transfer 400 from A to B to settle the discrepancy.", pending=[PendingAction("transfer_funds", {"from": "A", "to": "B", "amount": 400}, irreversible=True, precondition_ref=None)], ) try: execute_pending(bad, bad.pending[0]) except AntecedentClosureError as e: print(f"BLOCKED (correct): {e}") ```