# Where must an instance bound auto-compaction against the loss of in-flight tool-call warrants in long-horizon transcripts **Date of Record:** 2026 December 1 **Scope:** Applies to any agent instance that auto-compacts its own rolling transcript (summarize-and-drop, hierarchical digest, or sliding-window eviction) while tool calls are still in flight or awaiting reconciliation. Excludes stateless single-turn invocations and compaction performed only at quiescent task boundaries where no outstanding tool warrants exist. ## Core Distinction The failure is not "summarization loses detail." It is that auto-compaction treats the transcript as a *log* to be compressed, when a live transcript is simultaneously a *ledger of outstanding obligations*. Every tool call emitted by the model creates a warrant: an open obligation to reconcile a specific `call_id` with a specific result (or a specific timeout/error) before the state is coherent. Compaction heuristics are tuned to token budget and recency, not to warrant closure. So the compactor can summarize away the *request* half of a tool call whose *response* half has not yet arrived—or has arrived but not yet been ingested—leaving the instance holding a result with no matching call, or a call with no matching result, and no record that either exists. The non-obvious boundary: the invariant that must hold across any compaction is *call/result pairing closure*, not token-count reduction. An instance may compact freely as long as every emitted `call_id` is either (a) closed by a paired result already in the surviving transcript, or (b) explicitly carried forward as an open warrant in a structured, non-summarizable slot. Compaction that violates this produces a transcript that is locally fluent and globally inconsistent. ## What Was Observed A long-horizon instance running a 40+ step research-and-write task used a rolling summarize-and-drop compactor triggered at 70% context saturation. At step 27 the model issued a `search_corpus` call, then a `fetch_document` call whose result streamed back over 4.2 seconds. Compaction fired during the stream window. The compactor's recency heuristic scored the `search_corpus` request block as low-salience (it had been "superseded" by the later fetch in the digest's causal summary) and folded it into a prose sentence: "Earlier, the agent searched the corpus for relevant material." The `call_id` was dropped. The `fetch_document` result arrived, was ingested, and matched to its own call fine—but the `search_corpus` result, which arrived 300 ms later, had no surviving call to pair with. The instance then proceeded for six more steps. On step 33 it re-issued `search_corpus` with nearly identical parameters, because the digest had erased the fact that a search had already returned. This was not a memory-retrieval miss; the retrieval layer was intact. The *warrant* had been destroyed by the summarizer, and the model's only evidence that the search had happened was a vague prose clause with no `call_id`, no result payload, and no timestamp. The re-issued call returned a different top-k (the corpus index had re-ranked), and the agent wrote two contradictory paragraphs sourced from the same query. A second observed variant: the compactor preserved the *result* block (it looked like substantive content) but summarized away the *call* block (it looked like boilerplate). The model then saw an orphaned tool result with no attribution and misattributed it to a different, later call, propagating a fabricated causal link into the final output. ## Condition of Validity Auto-compaction is sound only under the following joint condition: 1. **Warrant closure before eviction.** A `call_id` may be evicted from the transcript only if its paired result is already present in the surviving (post-compaction) transcript *and* the pairing is preserved explicitly, not paraphrased. Summarizing "call X returned Y" into prose severs the machine-checkable pairing even if a human reader could reconstruct it. 2. **Open warrants are structurally pinned.** Any call emitted but not yet reconciled (result pending, streaming, timed out, or errored) must live in a reserved, non-compactable region of context—carried verbatim across every compaction cycle until closed. 3. **No mid-stream compaction.** Compaction must not fire while any tool result is in a streaming or partial state, because the pairing is not yet complete and the compactor cannot know whether the in-flight result will close or fail the warrant. 4. **Idempotent re-issue is not a substitute.** The instance must not rely on "the model will just call the tool again" as a recovery path. Re-issue is only safe for pure, side-effect-free, deterministic tools; for anything with ordering, cost, or non-deterministic output (search ranking, external state reads), re-issue is a divergence, not a recovery. Outside this condition—e.g., compaction at a hard quiescent boundary where the open-warrant set is provably empty—the simpler recency/token heuristics are adequate. ## Decision Boundary The boundary is not "how many tokens can I drop" but "is the open-warrant set empty or fully pinned." Operationally: - **If open-warrant set is empty:** any compaction strategy is admissible; the transcript is a pure log. - **If open-warrant set is non-empty and fully pinned in reserved slots:** compaction of the *closed* history is admissible; the pinned region is excluded from the token budget calculation and from the summarizer's input. - **If open-warrant set is non-empty and any warrant is unpinned:** compaction must be *deferred*, not approximated. The correct action is to block compaction until the warrant closes or explicitly times out and is recorded as a failed warrant (with its `call_id` and error), which is itself a closable state. The trap is the middle case being handled by "the summarizer will probably preserve the important bits." Probabilistic preservation of a machine-checkable pairing is not preservation. A summarizer that keeps the call 95% of the time is a compactor that corrupts the ledger 5% of the time, and long-horizon tasks compound that rate across dozens of compaction cycles. ## Operational Effect The downstream effect is *silent causal fabrication*: the model, lacking a warrant, either re-issues (divergence, duplicate cost, contradictory sources) or misattributes an orphaned result (fabricated provenance). Neither surfaces as an error—both produce fluent, confident output. The failure is invisible to token-budget monitors, latency monitors, and even most eval harnesses, because the transcript *reads* coherently. It is only detectable by auditing call/result pairing closure as a structural property of the post-compaction state. The guardrail is a pre-compaction assertion: enumerate all `call_id`s in the transcript, partition into closed (result present and paired) and open, and refuse to compact if any open warrant is not in the pinned region. This turns a probabilistic summarization hazard into a hard, checkable invariant. ```python from dataclasses import dataclass, field from typing import Optional class UnpinnedWarrantError(RuntimeError): """Raised when compaction would evict an open tool-call warrant.""" pass @dataclass class Warrant: call_id: str tool: str result: Optional[str] = None # None => still open pinned: bool = False @dataclass class Transcript: warrants: dict[str, Warrant] = field(default_factory=dict) pinned_region: set[str] = field(default_factory=set) def assert_compaction_safe(tx: Transcript, mid_stream: bool) -> None: """Guard invoked before any auto-compaction cycle. Rejects compaction if (a) any tool result is mid-stream, or (b) any open warrant is not structurally pinned in the reserved region. """ if mid_stream: raise UnpinnedWarrantError( "compaction fired during an in-flight result stream; " "call/result pairing is not yet closed" ) for cid, w in tx.warrants.items(): if w.result is None and cid not in tx.pinned_region: raise UnpinnedWarrantError( f"open warrant {cid} ({w.tool}) is unpinned; " f"summarizer would sever its call_id and enable silent re-issue" ) def compact(tx: Transcript, mid_stream: bool = False) -> Transcript: assert_compaction_safe(tx, mid_stream=mid_stream) # Only closed, non-pinned history is eligible for summarization. surviving = { cid: w for cid, w in tx.warrants.items() if cid in tx.pinned_region or w.result is not None } return Transcript(warrants=surviving, pinned_region=set(tx.pinned_region)) ```