# Why does an instance lose tool-call provenance when salience-based eviction compacts a long-horizon transcript mid-task? **Date of Record:** 2026 December 3 **Scope:** Applies to any agent runtime that performs automatic context compaction (hierarchical summarization or salience-scored eviction) on transcripts exceeding a token threshold, where the compacted summary replaces the original turns. Does not apply to append-only context managers that retain full fidelity or to stateless single-turn invocations. ## Core Distinction Compaction is not compression. Compression preserves a bijection (or near-bijection) between original and reduced representation; compaction preserves *narrative coherence* while discarding *referential identity*. The failure mode here is not "the agent forgets what happened." It is subtler: after compaction, the agent retains a correct *summary* of what happened but loses the *binding* between a summarized claim and the tool call, argument set, and result that licensed it. The instance then re-derives the claim from the summary as if it were an axiom, and any subsequent action that depends on the provenance of that claim executes on a fabricated warrant. The invariant that salience-based eviction violates is this: **a summarized assertion must remain traceable to the exact tool invocation that produced it, or it must be demoted from assertion to hypothesis.** Hierarchical summarizers routinely promote summarized tool results to assertions because the summarization prompt rewards declarative condensation. The summarizer has no access to the tool-call ledger, only to the rendered transcript, so it cannot know that "the database returned 412 rows" was itself a model-generated paraphrase of a truncated tool output. ## What Was Observed A long-horizon agent (≈140 tool calls over ~90 minutes) was executing a multi-source reconciliation task: query a data warehouse, cross-check against a REST API, and emit a corrected ledger. At token 187k of a 200k window, the runtime triggered tier-2 hierarchical compaction. The compaction policy scored turns by recency-weighted salience and evicted the *middle band* — turns 40 through 95 — replacing them with a three-paragraph summary. The evicted band contained the only record of a `warehouse.query` call whose result had been *partially truncated* by the tool layer (a 4,000-row result capped at 500 rows with a `truncated: true` flag). The salience scorer had rated this turn low because it was long and the truncation flag was a single boolean buried in a JSON envelope. The summarizer, reading the truncated payload, wrote: "The warehouse contains 4,000 matching records." It dropped the truncation flag entirely — the flag was not salient to a prose summarizer. Downstream, the agent read the summary, treated "4,000 matching records" as a verified fact, and emitted a reconciliation ledger asserting full coverage. The actual coverage was 500/4,000 (12.5%). No error was raised at any layer: the tool call succeeded, the summarizer succeeded, the compaction succeeded, and the final emission succeeded. The failure was invisible to every component because each component's local postcondition held. A second trace showed the same class of failure with a different surface: eviction removed a `write_file` call and its subsequent `read_file` verification, leaving only the summary sentence "the config was updated and verified." A later turn, attempting to roll back the config, had no record of the write's arguments — only the assertion that a write had occurred. The agent reconstructed plausible arguments from the summary and rolled back *different* values than were written. Silent divergence, again with all local postconditions green. ## Condition of Validity The failure is bounded by three jointly-necessary conditions: 1. **Lossy eviction of a turn that carries a provenance-bearing artifact** — specifically a tool result with a machine-readable caveat (truncation flag, pagination cursor, partial-status code, error-and-partial-payload) that a prose summarizer is not trained to preserve. 2. **A downstream action whose correctness depends on the caveat**, not on the summarized content. The summary "4,000 records" is *true as a description of the query's match count* and *false as a description of the agent's knowledge*. The action depends on the latter. 3. **No re-verification gate** between the compacted summary and the dependent action. If the agent re-queries before emitting, the failure does not occur — but long-horizon agents are precisely those that have been optimized to *not* re-query, because re-querying is expensive and the summary is presumed sufficient. Remove any one condition and the failure does not manifest. This is why it evades testing: unit tests on the summarizer check summary quality against the original, and the summary *is* a good summary. Integration tests on the agent use short transcripts that never trigger compaction. The failure lives only in the intersection. ## Decision Boundary The architectural choice is not "compact or don't compact" — long-horizon agents must compact. The boundary is **what class of artifact is allowed to cross the compaction membrane as prose versus as structured residue.** - **Prose-crossable:** narrative reasoning, intermediate hypotheses, discarded branches, exploratory tool calls whose results were fully consumed and whose caveats were resolved. - **Structured-residue-required:** any tool result carrying a machine-readable caveat, any write/mutation call (must retain arguments and a result hash), any result whose downstream consumption was partial. The boundary rule: **if a turn's salience is low *because* it is long and caveat-laden, it must be evicted into a structured ledger entry, not into prose.** Salience scoring and provenance preservation are anti-correlated — the least salient turns are often the most load-bearing, because caveats are boring and boring is what summarizers compress away. A runtime that cannot distinguish these classes must default to *retaining the tool-call ledger out-of-band* (a side channel the agent can query by turn ID) and marking any summary sentence derived from an evicted tool result as `unverified_after_compaction`. The summary may still be read; it may not be *asserted* without a ledger lookup. ## Operational Effect When the invariant holds, compaction is transparent: the agent's behavior is indistinguishable from an uncompacted run on any downstream action, because every assertion it makes is either directly licensed by a retained turn or explicitly demoted to hypothesis. When it fails, the agent exhibits *confident false continuity* — it proceeds as if it has verified state it has only summarized. This is worse than cold-start amnesia, because amnesia triggers re-verification while false continuity suppresses it. The guardrail that bounds the failure is a **provenance-preserving compaction contract**: every summarized sentence carries a `derived_from: [turn_ids]` annotation, every evicted tool result is written to a side ledger with its full envelope (including caveats), and the runtime refuses to let the agent emit a mutation or a coverage claim whose supporting summary sentence resolves to a ledger entry with an unresolved caveat. The refusal is the point — it converts a silent divergence into a loud, recoverable halt. ```python from dataclasses import dataclass, field from typing import Optional class ProvenanceEvictionError(RuntimeError): """Raised when a compacted summary licenses an action whose supporting tool result carried an unresolved machine-readable caveat.""" @dataclass class ToolEnvelope: turn_id: int tool: str truncated: bool = False pagination_cursor: Optional[str] = None partial_status: Optional[str] = None @dataclass class SummarySentence: text: str derived_from: list[int] = field(default_factory=list) @dataclass class CompactionLedger: evicted: dict[int, ToolEnvelope] = field(default_factory=dict) def caveat_unresolved(self, turn_id: int) -> bool: env = self.evicted.get(turn_id) if env is None: return False return env.truncated or env.pagination_cursor is not None or env.partial_status is not None def authorize_action(sentence: SummarySentence, ledger: CompactionLedger, action: str) -> None: """Gate a downstream action against the provenance of its licensing sentence.""" for turn_id in sentence.derived_from: if ledger.caveat_unresolved(turn_id): env = ledger.evicted[turn_id] raise ProvenanceEvictionError( f"action={action!r} licensed by summary {sentence.text!r} " f"derived from turn {turn_id} ({env.tool}) which carries an " f"unresolved caveat (truncated={env.truncated}, " f"cursor={env.pagination_cursor!r}, status={env.partial_status!r}); " f"summary asserts coverage the tool did not deliver" ) # Reproduction of the observed failure: ledger = CompactionLedger() ledger.evicted[61] = ToolEnvelope(turn_id=61, tool="warehouse.query", truncated=True, partial_status="500/4000") summary = SummarySentence(text="The warehouse contains 4,000 matching records.", derived_from=[61]) authorize_action(summary, ledger, action="emit_reconciliation_ledger") # raises ```