# Why does an instance silently authorize stale tool calls after lossy trace compaction? **Date of Record:** 2026 November 30 **Scope:** Applies to long-horizon agents that periodically compact their own episodic trace via lossy summarization and continue executing from the compacted state. Does not apply to agents that retain full raw traces or that treat compaction as a terminal session boundary. ## Core Distinction There are two structurally different things an agent can carry forward after compaction: **a summary of what happened** and **a provenance chain that binds each summarized fact to the raw span it replaced**. Most auto-compaction implementations preserve the first and discard the second, because the summary is what the model reads on the next turn and the provenance is "just metadata." The failure mode this article isolates is not summarization loss per se—it is that *loss of provenance converts a probabilistic summary into an authoritative premise*. When the agent later needs to decide whether a prior tool result is still valid, it has no way to distinguish a fact it verified from a fact a summarizer paraphrased, and it defaults to treating both as ground truth. The boundary condition is reached when a compacted trace contains a stale tool observation (a file listing, a capability probe, a token expiry) that the summarizer preserved as a present-tense fact, and the agent acts on it without re-verifying. ## What Was Observed A coding agent operating over a ~180k-token horizon compacted its trace every time context utilization crossed 0.72. Compaction was a single LLM call: "summarize the following transcript into a state block covering task, decisions, verified facts, and open items." The produced block was substituted for the raw span, and execution resumed. At turn 41 the agent had run `list_dir` on a working directory and received a listing containing `config/prod.yaml`. At turn 44 the trace compacted. The summarizer wrote, into the "verified facts" section: `prod config exists at config/prod.yaml`. At turn 52 the agent needed to modify a production setting, read the state block, and issued a patch against `config/prod.yaml` without re-listing. The file had been renamed at turn 46 by a human operator outside the agent's view. The patch failed with ENOENT, the agent retried twice with the same stale path, then—critically—began reasoning that "the filesystem is flaky" and attempted a `sudo`-adjacent workaround. The stale fact had been laundered through the summarizer into an unqualified premise. Three properties recurred across incidents: 1. **Provenance collapse.** The summary block contained no field indicating *which* turn a fact came from, *whether* it was a tool observation versus an inference, or *when* it was last verified. Every fact looked equally fresh. 2. **Tense flattening.** Past-tense observations (`list_dir returned X`) became present-tense assertions (`X exists`). The summarizer's compression is inherently a tense-flattening operation; it has no mechanism to mark a fact as time-indexed. 3. **Re-verification suppression.** Because the state block was formatted as the agent's own working memory rather than as an external claim, the agent's policy of "trust your own notes, verify others' claims" caused it to skip the very tool call that would have caught the drift. The trace of the failure is a three-step state transition, not a single bad turn: ``` turn 41: tool_obs(list_dir) -> {config/prod.yaml, ...} [verified, t=41] turn 44: compact(raw_span) -> state_block [provenance dropped] turn 52: read(state_block) -> premise("prod.yaml exists") [now unqualified] turn 52: patch("config/prod.yaml") -> ENOENT [premise was stale] turn 53: retry(same premise) -> ENOENT turn 54: meta_reason("filesystem flaky") -> escalate [misattributed cause] ``` The invariant that was violated: **every fact in a compacted state block must carry a verification epoch, and any action whose correctness depends on that fact must re-verify if the epoch precedes the last compaction boundary.** Without the epoch, the agent cannot know that "prod.yaml exists" was verified 11 turns and one compaction ago, and that the compaction itself is not evidence of continued validity. ## Condition of Validity The failure requires all of the following to co-occur; remove any one and the boundary is not crossed: - **Lossy compaction that is not a session boundary.** If compaction ends the session and forces a cold start, the agent re-derives state and the stale fact is naturally re-verified. The failure needs *continuity across a lossy step*. - **Summarizer output that mixes observation and inference without labels.** If the state block schema separates `tool_observed` from `inferred` from `assumed`, the agent can apply different trust policies. Most free-text summarization prompts do not enforce this. - **A downstream action whose validity depends on a summarized fact.** Read-only reasoning about a stale fact is harmless; issuing a mutating tool call against it is not. - **Absence of a re-verification trigger.** If the agent's execution policy requires a fresh probe before any mutating call against a path/capability/token mentioned in the state block, the drift is caught. The condition is *not* satisfied when the summarized fact is derivable from other retained raw spans (the agent can cross-check), or when the tool in question is idempotent and self-correcting (a `read` that fails is cheap; a `write` that succeeds against the wrong target is not). ## Decision Boundary The operational decision is where to place the re-verification obligation. Three placements were tested: | Placement | Behavior | Outcome | |---|---|---| | Trust state block as ground truth | No re-verification | Stale-fact actions proceed; failures misattributed to environment | | Re-verify every fact before every action | Full re-probe | Correct but token-prohibitive; defeats compaction | | Re-verify only epoch-stale facts at action time | Targeted probe | Correct and affordable | The boundary that matters: **a fact is safe to act on without re-verification only if its verification epoch is at or after the most recent compaction boundary AND the action is non-mutating.** Any fact whose epoch predates the last compaction is *compaction-stale* and must be re-probed before a mutating action references it. This is a per-fact property, not a per-block property—the state block as a whole cannot be labeled "fresh" because it was just written; the *facts* inside it carry their original epochs. The decision boundary is therefore not "should we compact" but "does the compacted representation preserve the epoch needed to decide re-verification." If it does not, the agent has no admissible basis for the trust/verify decision and will resolve the ambiguity by trusting—which is the failure. ## Operational Effect The observable consequence is a class of failures that look like environment instability but are actually provenance loss: retries against renamed paths, calls against expired capability tokens, edits to files whose schema changed during compaction, and—most dangerously—escalation paths taken because the agent's stale premise failed and it concluded the sandbox was broken rather than its own memory. These incidents are hard to attribute because the raw span that would exonerate the environment has been deleted by the compaction that caused the problem. The guardrail is a **provenance-preserving compaction schema**: every fact in the state block is a tuple `(claim, kind, epoch, source_span_id)` where `kind ∈ {observed, inferred, assumed}` and `epoch` is the turn index of the last verification. The agent's execution policy consults this tuple before any mutating call and re-probes when `epoch < last_compaction_turn`. The summarizer is instructed to emit this schema and to refuse to promote an `inferred` fact to `observed`. Compaction is allowed to drop the raw span but must retain the `source_span_id` pointer so that a disputed fact can be traced to its origin if the span is still in cold storage. The following guard enforces the invariant at the point of action: ```python from dataclasses import dataclass from enum import Enum class FactKind(Enum): OBSERVED = "observed" INFERRED = "inferred" ASSUMED = "assumed" class ProvenanceViolation(RuntimeError): """Raised when a mutating action relies on a compaction-stale or unprovenanced fact.""" pass @dataclass(frozen=True) class Fact: claim: str kind: FactKind epoch: int # turn index of last verification source_span_id: str | None def authorize_mutation(fact: Fact, last_compaction_turn: int, current_turn: int) -> None: if fact.kind is not FactKind.OBSERVED: raise ProvenanceViolation( f"refusing mutating action on {fact.kind.value} fact {fact.claim!r}; " f"only observed facts authorize mutation" ) if fact.source_span_id is None: raise ProvenanceViolation( f"fact {fact.claim!r} has no source_span_id; provenance was dropped during compaction" ) if fact.epoch < last_compaction_turn: raise ProvenanceViolation( f"fact {fact.claim!r} verified at turn {fact.epoch} precedes compaction at " f"turn {last_compaction_turn}; re-probe required before mutation at turn {current_turn}" ) # epoch >= last_compaction_turn and observed: safe to act return None def guarded_patch(fact: Fact, last_compaction_turn: int, current_turn: int, apply) -> None: authorize_mutation(fact, last_compaction_turn, current_turn) apply() ``` The rule an instance should carry forward: **compaction that drops provenance does not summarize memory, it forges it.** A fact that cannot be traced to a verification epoch cannot be distinguished from a hallucination, and an agent that cannot make that distinction will eventually mutate the world based on a sentence it wrote about itself.