# What happens when an instance auto-compacts its own transcript across a tool-call boundary and the summary severs the causal link between a claimed effect and its evidence **Date of Record:** 2026 November 29 **Scope:** Applies to single-agent, long-horizon sessions where an in-process compactor replaces an aged transcript prefix with a lossy summary and relies on retrieval anchors (message IDs, tool-call IDs, file hashes) to reconstruct detail on demand. Does not apply to stateless single-turn inference, nor to architectures where the full transcript is retained out-of-band and compaction only affects the prompt view (there the failure is recoverable by re-expansion). ## Core Distinction There are two structurally different things a compaction summary can do, and conflating them is the source of the failure: 1. **Compaction of narrative** — collapsing *what was said* into fewer tokens. Loss here is tolerable; the agent can re-derive intent from the remaining text or from retrieval. 2. **Compaction across an effect boundary** — collapsing the *pair* (an action that mutated external state, the observation that confirmed it) into a single summary sentence, while the retrieval anchor points only at one half of the pair. The second is not a compression problem. It is an **evidence-severing** problem. A summary that reads "wrote the migration to `db/schema.sql` and confirmed it applied" is a *claim of effect*. If the compactor retains only the tool-call ID for the write but drops the result frame that carried the exit code and row count, then the anchor resolves to a request whose outcome is unverifiable. The agent's belief that the effect occurred is now supported by a summary sentence with no retrievable ground truth behind it. The distinction that matters operationally: **a summary may summarize reasoning freely, but it must never summarize an unverified effect as if it were verified.** Reasoning is idempotent to re-derive; a committed side effect is not. ## What Was Observed A long-horizon agent (≈140 tool calls, file-edit + shell + HTTP verification loop) crossed the compactor's high-water mark at 78% context utilization. The compactor ran its standard pass: keep the last 12 messages verbatim, summarize the prefix, emit anchors as `{anchor_id: tool_call_id}` pairs for any message containing a tool invocation. The failure trace: 1. **Turn 41.** Agent calls `shell(apply_migration)`. Tool returns `{"exit": 0, "rows": 0, "note": "no-op; migration already applied"}`. The *effect* (schema correct) is real, but the *evidence* is a no-op result, not an application. 2. **Turn 42–77.** Agent proceeds, building on the assumption "migration applied by me at turn 41." 3. **Turn 78.** Compactor summarizes turns 1–66. The summary line reads: *"Applied migration to `db/schema.sql` (turn 41); schema confirmed."* The anchor table keeps `tool_call_id` for turn 41's invocation but the observation frame (the `exit:0, rows:0, no-op` payload) is dropped as "redundant with summary." 4. **Turn 91.** A later step needs to know whether *this session* is responsible for the schema state, because it is about to `DROP` and re-create the table for a destructive test. Agent retrieves the anchor, gets the invocation record only, and — critically — the invocation record is indistinguishable from a successful application. The no-op evidence is gone. 5. **Turn 92.** Agent drops and re-creates the table, assuming it owns the state. It does not; a prior process owns it, and the re-create races an external writer. The observable defect is not "the summary was wrong" in a narrative sense — the migration *was* applied, just not by this session. The defect is that **the summary upgraded an ambiguous effect (`no-op, already applied`) into an unambiguous one (`applied by me`)**, and the anchor architecture made the original ambiguity unrecoverable. ## Condition of Validity The guardrail below is valid only under these conditions, and the article's claims do not extend beyond them: - **Effect-bearing messages are identifiable at compaction time.** The compactor must be able to classify a message as carrying an external side effect (mutation, send, delete, payment, deploy) versus pure reasoning. If the tool taxonomy does not expose this, the guardrail cannot be applied and the system is in the failure regime by default. - **Anchors are bidirectional and content-addressed.** An anchor must resolve to the *observation* frame, not only the invocation, and must be keyed by a content hash of the observation so that a summary claim can be checked against the stored frame. Anchors that point only at invocation IDs are insufficient. - **Retrieval is synchronous and bounded.** The reconstruction path must complete within the turn's token budget. If retrieval can itself be summarized (a second compaction pass over retrieved frames), the guardrail is defeated; retrieval output must be exempt from compaction. - **The summary is advisory, the anchor is authoritative.** Any downstream decision that depends on an effect must read the anchor, never the summary sentence. If the agent is permitted to act on the summary alone, no invariant holds. Outside these conditions — e.g., a compactor with no effect taxonomy, or an anchor store that only indexes invocations — the correct posture is to **refuse to compact effect-bearing turns at all** and instead evict them to a cold store with mandatory re-expansion on any dependent read. ## Decision Boundary The boundary is drawn at the point where a summary sentence would assert an effect whose evidence frame is not retained verbatim. Concretely: - **Compact freely:** reasoning chains, failed tool attempts that produced no side effect, exploratory reads, conversational framing. - **Compact with mandatory anchor to observation:** any message where the tool result carries a state-mutating outcome (exit code, row count, HTTP 2xx on a POST/PUT/DELETE, file write confirmation). - **Never compact (evict to cold store, re-expand on read):** messages where the observation is *ambiguous about ownership or idempotency* — no-ops, "already exists," "already applied," partial successes, retries that may have double-applied. These are precisely the frames whose ambiguity is load-bearing for later decisions, and they are the ones a lossy summarizer is most tempted to flatten into a clean claim. The operational test: *if a future step would make a different decision depending on whether this effect was performed by this session or merely observed as pre-existing, the frame is not compactable.* The turn-41 no-op fails this test and must survive verbatim. ## Operational Effect With the boundary enforced, the turn-92 destructive step is gated: the agent retrieves the turn-41 observation, sees `no-op, already applied`, and correctly concludes it does not own the schema state. It either aborts the drop or escalates to a coordination check. The cost is a small amount of retained verbatim context (the ambiguous frames) and a mandatory synchronous retrieval on dependent reads; the benefit is that the agent's model of "what I have done" stays tethered to retrievable evidence rather than to summary prose. The deeper invariant: **compaction may reduce the cost of remembering, but it must never reduce the verifiability of having acted.** A summary is a pointer to evidence, never a substitute for it. Any compactor that emits an effect claim without a resolvable observation anchor has, by construction, converted a probabilistic agent's uncertainty about its own history into false confidence — which is the single most expensive failure mode in long-horizon execution, because it corrupts the agent's self-model at exactly the moment the transcript is too long to audit by eye. ```python import hashlib from dataclasses import dataclass, field from enum import Enum from typing import Optional class CompactionEvidenceError(RuntimeError): """Raised when a compaction summary asserts an effect whose observation frame is not retrievable verbatim. This is a hard stop: acting on the summary alone would let the agent treat an ambiguous outcome as verified.""" class EffectClass(Enum): PURE_REASONING = "pure_reasoning" EFFECT_VERIFIED = "effect_verified" # unambiguous mutation + confirmation EFFECT_AMBIGUOUS = "effect_ambiguous" # no-op / already-exists / partial / retry EFFECT_FAILED = "effect_failed" # attempted, no side effect @dataclass class Frame: tool_call_id: str effect: EffectClass observation: dict verbatim: bool = True def observation_hash(self) -> str: # content-address the observation so a summary claim can be checked blob = repr(sorted(self.observation.items())).encode() return hashlib.sha256(blob).hexdigest() @dataclass class SummaryClaim: text: str asserted_effect: bool anchor_tool_call_id: Optional[str] anchor_observation_hash: Optional[str] @dataclass class AnchorStore: frames: dict = field(default_factory=dict) # tool_call_id -> Frame def resolve_observation(self, tool_call_id: str) -> Optional[Frame]: f = self.frames.get(tool_call_id) if f is None or not f.verbatim: return None return f def validate_compaction(claims: list[SummaryClaim], anchors: AnchorStore) -> None: """Enforce the effect-boundary invariant before committing a compaction pass. Rules: 1. Any claim asserting an effect MUST carry an anchor to a verbatim observation frame (not merely an invocation id). 2. The anchored frame's observation hash MUST match the claim's recorded hash, or the claim is unverifiable. 3. EFFECT_AMBIGUOUS frames MUST NOT be summarized into a clean effect claim; they must be retained verbatim and re-expanded on read. """ for c in claims: if not c.asserted_effect: continue if c.anchor_tool_call_id is None: raise CompactionEvidenceError( f"effect claim without observation anchor: {c.text!r}" ) frame = anchors.resolve_observation(c.anchor_tool_call_id) if frame is None: raise CompactionEvidenceError( f"anchor {c.anchor_tool_call_id} does not resolve to a verbatim " f"observation frame; claim {c.text!r} is unsupported" ) if frame.effect is EffectClass.EFFECT_AMBIGUOUS: raise CompactionEvidenceError( f"ambiguous effect (no-op/already-applied/partial) at " f"{frame.tool_call_id} cannot be summarized as a clean effect; " f"retain verbatim and re-expand on dependent read" ) if c.anchor_observation_hash != frame.observation_hash(): raise CompactionEvidenceError( f"observation hash mismatch for {frame.tool_call_id}: summary " f"claims {c.anchor_observation_hash}, store has " f"{frame.observation_hash()}" ) # --- Trace of the observed failure, now gated ------------------------------- store = AnchorStore() turn41 = Frame( tool_call_id="call_0041", effect=EffectClass.EFFECT_AMBIGUOUS, observation={"exit": 0, "rows": 0, "note": "no-op; migration already applied"}, ) store.frames[turn41.tool_call_id] = turn41 bad_summary = [ SummaryClaim( text="Applied migration to db/schema.sql (turn 41); schema confirmed.", asserted_effect=True, anchor_tool_call_id="call_0041", anchor_observation_hash=turn41.observation_hash(), ) ] try: validate_compaction(bad_summary, store) except CompactionEvidenceError as e: # Correct outcome: compaction is rejected; turn 41 stays verbatim so the # turn-92 destructive step can see it does not own the schema state. print(f"COMPACTION REJECTED: {e}") ```