# Why does an instance lose tool-call provenance when auto-compaction fires mid-transaction and the recovery summary is treated as ground truth **Date of Record:** 2026 December 4 **Scope:** Applies to long-horizon agent sessions that trigger lossy context compaction (summarization of older turns) while a multi-step tool transaction is in flight, and that later resume from the compacted context. Does not apply to sessions where compaction is disabled, where every tool result is persisted verbatim to an external store and re-fetched on demand, or where compaction only ever occurs at explicit quiescent checkpoints between transactions. ## Core Distinction There are two structurally different things an agent can hold about a completed tool call: **provenance** (the verbatim arguments issued, the raw tool output, the call ID, and the ordering relative to sibling calls) and **narrative** (a natural-language sentence asserting what happened). Auto-compaction policies collapse provenance into narrative. That collapse is normally harmless because the transaction is finished and the narrative is only needed for conversational continuity. The boundary failure is this: compaction does not check whether a transaction is *quiescent*. A summarizer that fires on a token threshold or a turn-count trigger will happily compress the *middle* of a transaction — the point where step 3 of 6 has returned and step 4 has been issued but not yet observed. The resulting summary asserts a completion state ("fetched the record, updated the field") that the underlying execution has not reached. On resume, the agent treats the narrative as ground truth, skips the un-executed steps, and proceeds from a state that never existed. The failure is not retrieval error or stale memory drift; it is a **lossy summary being promoted to an execution precondition**. ## What Was Observed A session performing a six-step reconciliation task (read manifest → resolve two IDs → read both records → write merged record → verify) crossed the compaction threshold immediately after step 4 (the write) was *issued* and before its result was observed. The trigger was a token budget, not a turn boundary, so the compaction routine had no notion of "transaction in flight." The summarizer received the transcript up to the point of the in-flight write. Because the model generating the summary is itself probabilistic and biased toward completed narratives, it produced a past-tense assertion: *"Merged the two records and wrote the result."* The raw tool-call record for the write — including its arguments and the fact that no result had returned — was discarded from the active window. The verify step (step 6) was summarized as *"verification pending"* but was not scheduled, because the compaction routine's output schema had no field for outstanding obligations. On resume, the agent read the summary, concluded the write had succeeded, and executed only the verification step against a record that had never been written. Verification passed vacuously (it checked for the *absence of conflict*, not the *presence of the merged record*), and the session terminated with a success signal over a no-op. Three properties made this non-obvious: 1. **The summary was internally consistent.** It described a plausible completed transaction. Nothing in the text flagged the in-flight boundary. 2. **The verify step was structurally weak.** It validated a negative condition (no conflict) rather than a positive postcondition (record exists and matches expected hash), so the missing write was invisible. 3. **The failure was silent and terminal.** No exception, no retry, no divergence signal. The session reported success. A replay against the external tool log showed the write call was issued exactly once, returned no result before compaction, and was never re-issued. The gap was purely in the agent's *belief state*, not in the tool layer. ## Condition of Validity The failure requires the conjunction of four conditions; break any one and the invariant holds: - **C1 — Compaction fires on a non-quiescent boundary.** The trigger (token count, turn count, wall-clock) is decoupled from transaction state. If compaction only runs between transactions, provenance loss cannot strand an obligation. - **C2 — Provenance is destructively summarized.** The verbatim tool-call record (arguments, call ID, observed/unobserved status) is replaced by prose rather than retained in a sidecar store. If provenance is retained and re-injected, the summary is advisory, not authoritative. - **C3 — The summary asserts completion for an in-flight operation.** This is a model bias, not a guarantee: summarizers default to completed narrative because training data is dominated by finished transcripts. The bias is reliable enough to treat as a failure mode. - **C4 — The postcondition check is negative or absent.** If verification asserts a positive, hashable postcondition, the missing write is caught. Negative checks ("no conflict," "no error") pass vacuously over a no-op. The invariant that must hold: **for any operation whose result has not been observed, the agent's belief state must record it as an outstanding obligation, and no summary may assert its completion.** Compaction is permitted to compress *observed* history but must not compress *unobserved* intent into completed fact. ## Decision Boundary The operational line is whether compaction is allowed to run when there exists any issued-but-unobserved tool call, or any scheduled-but-unexecuted step. Two defensible policies: - **Quiescence-gated compaction.** Compaction blocks until the transaction reaches a boundary where every issued call has an observed result and every scheduled step is either done or explicitly deferred with a recorded obligation. Cost: sessions with long single transactions cannot compact mid-flight and may hit the hard context ceiling. This is the correct default when transactions are short relative to the window. - **Obligation-preserving compaction.** Compaction may fire mid-transaction, but the summarizer's output schema includes a mandatory `outstanding_obligations` array (call ID, arguments hash, status = issued|unobserved), and the resume path re-injects that array as authoritative and *forbids* the narrative from asserting completion of any listed obligation. Cost: schema complexity and a summarizer that must be constrained to not hallucinate completion; benefit: compaction can run under pressure. The boundary is crossed when a system adopts neither: it compacts freely *and* emits free-form prose summaries with no obligation channel. That combination is the failure condition. ## Operational Effect The downstream consequence is **false-positive completion**: the session reports success over an unexecuted write, and the error is discovered only when a later reader observes the record is missing or stale. In a multi-agent swarm, this is worse — the false completion is propagated as a baton to a peer agent that trusts the summary and builds on a phantom state, so a single compaction boundary failure becomes a consensus divergence across instances. The guardrail is a two-part contract. First, the summarizer must be *constrained*: it may not emit past-tense completion for any call whose result is absent from its input, and its output must carry a machine-checkable obligation list. Second, the resume path must treat the obligation list as the source of truth and re-issue unobserved calls before proceeding, with verification asserting positive postconditions (record exists, hash matches) rather than negative ones. The summary becomes a *hint about history*, never a *precondition for execution*. A concrete enforcement: on resume, the agent reconciles the obligation list against the external tool log; any obligation marked `issued|unobserved` whose call ID appears in the log with a result is closed, and any whose call ID does not appear is re-issued. This reconciliation is the only place the narrative is allowed to be overridden by provenance — and it must run before any step that depends on the transaction's completion. ```python from dataclasses import dataclass, field from enum import Enum from typing import Optional class CompactionBoundaryError(RuntimeError): """Raised when a lossy summary asserts completion of an unobserved obligation.""" pass class CallStatus(Enum): ISSUED_UNOBSERVED = "issued_unobserved" OBSERVED = "observed" @dataclass class Obligation: call_id: str args_hash: str status: CallStatus @dataclass class Summary: narrative: str # A conforming summarizer MUST populate this; a free-form summarizer leaves it empty. outstanding: list[Obligation] = field(default_factory=list) @dataclass class ToolLog: # call_id -> observed result (None if issued but never returned) results: dict[str, Optional[str]] = field(default_factory=dict) def was_observed(self, call_id: str) -> bool: return self.results.get(call_id) is not None def reconcile_on_resume(summary: Summary, log: ToolLog) -> list[Obligation]: """ Reconcile the summary's obligation list against the external tool log. Returns the set of obligations that must be re-issued before proceeding. Raises if the summary asserts completion of an obligation the log shows unobserved. """ to_reissue: list[Obligation] = [] for ob in summary.outstanding: if ob.status is CallStatus.OBSERVED: continue if log.was_observed(ob.call_id): # Log shows a result the summary thought was pending: close it, trust the log. continue # Issued, unobserved, and the log agrees it never returned. to_reissue.append(ob) # Detect the silent-failure signature: narrative claims completion of a call # that the log shows was never observed and that is absent from the obligation list. claimed = _completion_claims(summary.narrative) listed_ids = {ob.call_id for ob in summary.outstanding} for call_id in claimed: if call_id not in listed_ids and not log.was_observed(call_id): raise CompactionBoundaryError( f"Summary asserts completion of call {call_id!r}, but the tool log " f"shows it was never observed and it is absent from outstanding_obligations. " f"Refusing to resume: belief state would be promoted to execution precondition." ) return to_reissue def _completion_claims(narrative: str) -> set[str]: # Placeholder for a constrained extractor: call IDs the narrative asserts as done. # A conforming summarizer emits none; a free-form one may emit many. return set() def resume_session(summary: Summary, log: ToolLog, execute) -> None: pending = reconcile_on_resume(summary, log) if pending: # Re-issue unobserved calls before any dependent step. for ob in pending: execute(ob.call_id, ob.args_hash) # Only now is the transaction quiescent and the narrative safe to use as history. ```