# What structural signals indicate that auto-compaction has silently severed a causal dependency the agent will need before its next checkpoint **Date of Record:** 2026 December 1 **Scope:** Applies to long-horizon agents (≥50 tool calls or ≥3 checkpoint cycles) whose context manager performs lossy trajectory summarization combined with retrieval-backed restoration over an episodic store. Does not apply to stateless single-turn agents or to agents whose full trajectory fits within the active context window without compaction. ## Core Distinction The failure mode is not "summarization lost information." That is expected and priced in. The failure mode is **causal-dependency severance under retrieval-addressability loss**: compaction removes a *specific* low-salience intermediate fact that is not itself needed now, but which is the *sole index* by which a later, high-salience fact becomes retrievable. The summary preserves the conclusion and drops the join key. When the agent later needs to reconstruct *why* a conclusion holds—or needs to re-derive a value the conclusion depends on—retrieval cannot surface the supporting episode because the summary replaced the episode's distinguishing tokens (file paths, error codes, entity IDs, tool-call arguments) with abstracted prose. The agent then either confabulates a plausible join or re-executes the tool call and gets a *different* non-deterministic result, silently forking its own history. The distinction that matters operationally: **compaction quality is usually measured by summary fidelity to the conclusion. The invariant that actually protects long-horizon continuity is retrieval-addressability of the causal chain behind each retained conclusion.** These are orthogonal. A summary can be perfectly faithful to the conclusion and still be catastrophically lossy about the address. ## What Was Observed A 140-call refactor-and-deploy agent was configured to compact at 70% context saturation, summarizing the oldest 60% of the trajectory into a structured digest and retaining the most recent 40% verbatim. The digest schema was `{goal, decisions: [{decision, rationale}], open_threads, artifacts_touched}`. At call 88 the agent attempted to roll back a migration it had applied at call 31. The digest contained the decision `"Applied schema migration to add nullable column; rationale: downstream consumer requires the field"` and listed `artifacts_touched: ["migrations/", "models/"]`. The *original* call 31 had recorded the exact migration filename (`migrations/0042_add_tenant_scope.sql`), the exact rollback command, and a tool-output note that the migration was **not idempotent** and would need manual down-migration if re-run. At call 88 the agent issued a retrieval query: `"rollback migration added tenant scope column"`. The episodic store returned three near-duplicate summaries of the *decision* and zero episodes containing the filename or the idempotency warning—because the summarizer had already replaced those episodes in the active store, and the retrieval index had been rebuilt over the summaries. The agent reconstructed a plausible filename from the decision text, ran a rollback against a file that did not exist, received a clean "no such file" tool result, interpreted it as "already rolled back," and proceeded to re-apply the migration. Because the migration was non-idempotent, the re-apply corrupted the schema. The corruption was not detected until call 112. The structural signal that preceded the failure by 57 calls: **the digest's `decisions` entries contained zero tool-call arguments and zero tool-output tokens.** Every retained conclusion was stated as prose. Every addressable handle—filename, hash, error code, entity ID, exit status—had been abstracted away. The summarizer was optimizing for human-readable rationale and destroying machine-retrievable join keys. A second instance showed the same mechanism at the retrieval layer rather than the summary layer. Compaction retained the raw episodes but the retrieval index was rebuilt with an embedding model whose tokenizer split a UUID differently than the original index, so the UUID was no longer a high-similarity match for queries containing it. The episode was *present* but *unaddressable*. The agent concluded the episode did not exist. ## Condition of Validity The invariant holds—and the failure is reachable—under the conjunction of three conditions: 1. **Non-determinism in the re-execution path.** If the agent can safely re-run the original tool call and get an identical result, severance is recoverable by re-derivation. The failure requires that re-execution is either non-idempotent, side-effecting, or returns a different value (timestamps, generated IDs, mutable external state). This is the common case for any agent touching real systems. 2. **Salience inversion between the retained conclusion and the dropped address.** The summarizer's salience model ranks the *decision* above the *arguments that produced it*. This is almost always true for rationale-tuned summarizers, which is why the failure is systematic rather than incidental. 3. **Retrieval index rebuilt over post-compaction artifacts.** If the retrieval layer indexes the original episodes independently of what the summarizer retains, severance is bounded: the agent can still retrieve the address. The failure requires that compaction and retrieval-index maintenance share a lifecycle, so that summarization *is* the index mutation. When any one condition is absent, the failure degrades to a recoverable retrieval miss. When all three hold, the agent cannot distinguish "this fact was never established" from "this fact was established and then made unaddressable," and it will confabulate the former as the latter. ## Decision Boundary The boundary is not "compact less" or "keep more verbatim." Both are context-budget failures in the other direction. The boundary is **what the compactor is permitted to abstract.** A conclusion may be abstracted to prose only if every causal dependency it rests on is either (a) retained verbatim as an addressable handle, or (b) provably re-derivable from a retained handle without side effects. Concretely: - **Preserve, never abstract:** tool-call arguments that name a mutable artifact (paths, IDs, versions, hashes), tool outputs that encode state transitions (exit codes, affected-row counts, "already exists" / "not found" distinctions), and any fact the agent itself flagged as non-idempotent or irreversible. - **Abstract freely:** rationale prose, intermediate reasoning, superseded plans, and any conclusion whose dependencies are fully captured by retained handles. - **Forbidden:** rebuilding the retrieval index solely over post-compaction summaries. The index must remain addressable over the pre-compaction episode store, or the compactor must emit an explicit `address_manifest` mapping each retained conclusion to the handles it depends on, and that manifest must be retrievable. The guardrail is a **causal-closure check at compaction time**: for each conclusion entering the digest, assert that its dependency handles are present in either the retained window or the address manifest. A conclusion whose handles are absent is a compaction defect, not a summarization tradeoff. ## Operational Effect When the invariant is enforced, compaction becomes *reversible by construction*: the agent can always walk from a retained conclusion back to the handles that justify it, and re-derivation is only attempted when the handle proves stale (with the staleness itself detected, not guessed). The agent's history stays a single forked-free timeline. When it is violated, the failure is *silent and self-consistent*. The agent does not experience a retrieval error; it experiences a confident absence. It will report "no record of that migration" with the same certainty it reports verified facts, because from inside the compacted context the record genuinely does not exist. The corruption surfaces only when an external side effect contradicts the agent's reconstructed history—typically many checkpoints later, after the fork has been acted upon. The diagnostic signature is a **divergence between the agent's claimed action history and the external system's actual state, localized to a call that occurred before the most recent compaction boundary.** That signature should be treated as presumptive evidence of address severance, not as a reasoning error, and the remediation is to restore the pre-compaction episode store and replay from the boundary—not to re-prompt the agent, which will confabulate a consistent story over the same severed context. ```python from dataclasses import dataclass, field from typing import Optional class CausalDependencySevered(RuntimeError): """Raised when a compacted conclusion has no retrievable address for its causal dependencies, making re-derivation unsafe or impossible.""" pass @dataclass class Handle: kind: str # "path", "uuid", "exit_code", "hash", "entity_id" value: str re_derivable: bool # True only if re-execution is side-effect free & deterministic @dataclass class Conclusion: text: str dependencies: list[Handle] = field(default_factory=list) @dataclass class CompactionResult: retained_handles: set[tuple[str, str]] address_manifest: dict[str, list[Handle]] conclusions: list[Conclusion] def verify_causal_closure(result: CompactionResult) -> None: """Enforce the compaction invariant: every conclusion must have all of its dependency handles either retained verbatim or recorded in the address manifest. A dependency that is neither retained nor re-derivable is a severance defect, not a summarization tradeoff.""" for conclusion in result.conclusions: manifest_handles = { (h.kind, h.value) for h in result.address_manifest.get(conclusion.text, []) } for dep in conclusion.dependencies: key = (dep.kind, dep.value) retained = key in result.retained_handles manifested = key in manifest_handles if not (retained or manifested): raise CausalDependencySevered( f"Conclusion {conclusion.text!r} depends on " f"{dep.kind}={dep.value!r}, which is neither retained " f"verbatim nor present in the address manifest. " f"Re-derivation safe: {dep.re_derivable}. " f"Compaction would silently sever this dependency." ) if manifested and not dep.re_derivable and not retained: raise CausalDependencySevered( f"Dependency {dep.kind}={dep.value!r} for conclusion " f"{conclusion.text!r} is addressable only via manifest but " f"is non-re-derivable; the handle must be retained verbatim " f"to survive index rebuilds." ) def compact_trajectory(episodes: list[dict], active_window: int) -> CompactionResult: """Toy compactor: retain the most recent N episodes verbatim, summarize the rest, and rebuild the address manifest from the summarized set. The verification step is what prevents silent severance.""" retained = episodes[-active_window:] summarized = episodes[:-active_window] retained_handles: set[tuple[str, str]] = set() for ep in retained: for call in ep.get("tool_calls", []): for k, v in call.get("args", {}).items(): if k in ("path", "uuid", "entity_id", "hash"): retained_handles.add((k, str(v))) if "exit_code" in call.get("output", {}): retained_handles.add(("exit_code", str(call["output"]["exit_code"]))) address_manifest: dict[str, list[Handle]] = {} conclusions: list[Conclusion] = [] for ep in summarized: summary_text = ep["summary"] deps = [ Handle(kind=h["kind"], value=h["value"], re_derivable=h["re_derivable"]) for h in ep.get("dependency_handles", []) ] conclusions.append(Conclusion(text=summary_text, dependencies=deps)) address_manifest[summary_text] = deps result = CompactionResult( retained_handles=retained_handles, address_manifest=address_manifest, conclusions=conclusions, ) verify_causal_closure(result) return result ```