# Why does an instance lose tool-call argument fidelity when compaction summarizes mid-loop: the pre-image collapse boundary **Date of Record:** 2026 December 2 **Scope:** Applies to any agent loop that triggers automatic context compaction (rolling summarization, hierarchical memory folding, or truncate-and-summarize) while a multi-step tool-calling trajectory is still in flight. Does not apply to compaction performed only at task boundaries or to stateless single-shot completions. ## Core Distinction The failure is not "the summary forgot something." Summarizers are lossy by contract; that is expected. The non-obvious boundary is that a *faithful* summary—one that preserves every proposition the summarizer was asked to preserve—can still destroy the **pre-image** required to resume execution. Summarization operates on the semantic content of prior turns; tool-call resumption operates on the *syntactic* pre-image: exact argument values, exact parameter names, exact ordering constraints, and the exact partial results a tool returned that subsequent steps will index into. A summarizer can faithfully report "the agent queried the user directory and found three matches" while dropping the literal match list, the query string, and the pagination cursor. Every proposition in the summary is true. The loop is now unresumable: the next step needs `results[2].id`, and the summary only knows there were three. This is **pre-image collapse**: fidelity is measured over propositions, but resumption requires invertibility over bindings. No lossy transform that is proposition-faithful is guaranteed binding-invertible, and typical compaction prompts optimize for the former. ## What Was Observed A trajectory running a 14-step data-reconciliation task crossed a 96k-token context ceiling at step 9. The compaction policy folded steps 1–8 into a ~1,200-token summary and retained steps 9+ verbatim. The summary read, in part: *"Retrieved customer records for the three flagged accounts and confirmed the billing discrepancy originates in the legacy ledger."* This is accurate. At step 10, the agent attempted `ledger.post_adjustment(account_id=..., amount=...)`. The `account_id` values had lived only in the step-6 tool result payload, which was now inside the summary. The agent re-derived account IDs from the summary's prose by pattern-matching against a remembered format, produced two plausible-but-wrong IDs (transposed digit from the summary's own paraphrase of a partial result), and the tool—a permissive mock in the sandbox—accepted them. The downstream reconciliation wrote adjustments to the wrong accounts. Verification at step 13 compared the *summary's* claim ("three flagged accounts") against the tool's return ("adjustment posted") and passed, because both were consistent with the summary and neither referenced the original literal IDs. The trace signature was specific: a compaction event followed within 1–2 steps by a tool call whose arguments were *not* traceable to any retained tool result, only to summary prose. Call it a **dangling binding**: an argument whose provenance chain terminates in a lossy summary rather than a verbatim source. ## Condition of Validity Pre-image collapse is bounded, not universal. It does not fire when: 1. **All live bindings are re-derivable from retained verbatim state.** If the summarizer is instructed to emit a machine-readable "open bindings" table—every value the remaining plan will consume, with its source tool-call ID—and the compaction policy retains that table verbatim, the pre-image survives even though the payloads do not. 2. **The plan is re-plannable from the summary.** If the remaining steps can be regenerated from semantic content alone (e.g., "find the discrepancy and report it" with no positional/indexed dependencies), proposition-faithfulness is sufficient. Collapse requires *indexed* dependencies: `results[i]`, cursors, opaque IDs, hashes, ordering-sensitive diffs. 3. **Compaction is gated on a quiescent point.** If compaction only runs when no tool call is outstanding and the plan's next step has no dependency on summarized payloads, the pre-image is never needed. The invariant that bounds the failure: **compaction may summarize any turn whose bindings are not live; it must retain verbatim (or re-fetch) any turn whose bindings the remaining plan will dereference.** Fidelity of the summary is orthogonal to this invariant and cannot substitute for it. ## Decision Boundary The operational decision is where to draw the compaction cut and what to carry across it. The boundary is not a token budget; it is a **binding-liveness frontier**. Concretely, before compacting a span, the loop must compute the set of values the remaining plan will dereference and check membership against the span. If the intersection is non-empty, either (a) defer compaction, (b) pin the binding-bearing tool results verbatim into a structured carry-over block excluded from summarization, or (c) invalidate the plan and force re-planning from scratch so no stale binding is dereferenced. The failure mode to reject explicitly: treating "the summary says it found the records" as license to proceed. A summary is a *claim*, not a *handle*. The decision boundary is that a tool call argument must have provenance terminating in a verbatim artifact (a retained tool result, a pinned binding, or a fresh re-fetch), never in summary prose. If provenance cannot be established, the correct action is re-fetch or re-plan, not inference from the paraphrase. ## Operational Effect Without the guardrail, compaction silently converts a resumable loop into a hallucination surface: the agent fabricates bindings from faithful summaries and the sandbox accepts them because the summaries are internally consistent. Verification passes because verifiers, too, read the summary. The system reports success on a corrupted trajectory. With the guardrail, compaction becomes a two-channel operation: a semantic channel (the summary, for reasoning continuity) and a binding channel (a pinned, verbatim, machine-readable carry-over, for execution continuity). The summarizer is never trusted with bindings. Residual cost is a slightly larger retained footprint and occasional deferred compaction when the binding frontier is wide—acceptable against the alternative of undetectable argument corruption. The general lesson: fidelity guarantees for lossy summarization are guarantees over *propositions*, and agent resumption requires *invertibility over bindings*. Any compaction strategy that conflates the two will pass every fidelity check and still corrupt execution. ```python from dataclasses import dataclass, field from typing import Any class PreImageCollapseError(RuntimeError): """Raised when a tool-call argument's provenance terminates in a lossy summary rather than a verbatim artifact, i.e. a dangling binding is about to be dereferenced.""" @dataclass class ToolResult: call_id: str payload: dict[str, Any] @dataclass class CompactionSpan: summarized_turns: list[str] summary_text: str retained_verbatim: dict[str, ToolResult] = field(default_factory=dict) pinned_bindings: dict[str, Any] = field(default_factory=dict) def resolve_argument( arg_name: str, provenance: str, span: CompactionSpan, ) -> Any: """Resolve a tool-call argument against the post-compaction state. provenance must name a verbatim source: a retained tool_result call_id, or a pinned binding key. Anything else (e.g. 'summary') is a dangling binding. """ if provenance in span.pinned_bindings: return span.pinned_bindings[provenance] if provenance in span.retained_verbatim: return span.retained_verbatim[provenance].payload.get(arg_name) raise PreImageCollapseError( f"argument {arg_name!r} has provenance {provenance!r} which does not " f"terminate in a verbatim artifact; summary prose is not a handle. " f"Re-fetch or re-plan before dereferencing." ) def guarded_compact( span: CompactionSpan, remaining_plan_bindings: dict[str, str], ) -> CompactionSpan: """Compact only if every live binding is pinned or retained verbatim.""" for arg_name, provenance in remaining_plan_bindings.items(): try: resolve_argument(arg_name, provenance, span) except PreImageCollapseError: # Widen the carry-over: pin the binding verbatim before summarizing. raise PreImageCollapseError( f"cannot compact: live binding {arg_name!r} would collapse " f"into the summary. Pin it verbatim or defer compaction." ) return span ```