# Why does an instance lose its own tool-call preconditions when auto-compaction rewrites the trajectory it is still executing? **Date of Record:** 2026 November 28 **Scope:** Applies to long-horizon agents that auto-compact their own message history mid-task (rolling summarization, hierarchical memory eviction, or token-budget summarizers) and then continue executing against the summarized state. Does not apply to compaction performed only at task boundaries, nor to stateless single-shot inference where history is never rewritten. ## Core Distinction The failure is not "summarization lost detail." It is that a lossy summarizer preserves *propositions* (what was done, what was concluded) while discarding *preconditions* (the invariants that made those propositions safe to build on). A trajectory summary like "created the staging bucket and uploaded the manifest" is a faithful propositional compression of four tool calls, but it erases the fact that the upload succeeded only because the bucket had a specific IAM binding, that the manifest key was versioned, and that the agent had verified the upload with a read-back whose result was a precondition for the *next* step. When the agent resumes from the summary, it treats the proposition as a closed, self-sufficient fact and proceeds to the dependent step without re-establishing the precondition. The precondition was never lost from the world; it was lost from the agent's *belief about what it still needs to check*. This is distinct from cold-start amnesia (which loses everything uniformly) and from stale-memory drift (which retains a wrong value). Here the retained value is *correct* but *insufficiently qualified*: the summary asserts the outcome without asserting the conditions under which the outcome can be relied upon. ## What Was Observed A 40-step provisioning agent compacted at step 22 under a 12k-token budget. The pre-compaction trace contained, across steps 8–14, the sequence: `create_bucket` → `put_bucket_policy` (returned `200`) → `put_object(manifest)` → `head_object(manifest)` returning `ETag` and `ContentLength` → a reasoning turn noting "policy change may take up to 30s to propagate; read-back confirms object present but does not confirm policy effective" → a 25s sleep → `get_bucket_policy` confirming the binding. The compactor emitted: *"Set up staging bucket with required policy and uploaded verified manifest (steps 8–14)."* At step 23 (post-compaction), the agent needed to grant a downstream service read access. Its reasoning, reconstructed from the trace, was: "Policy is already configured per summary; only need to attach the new principal." It issued `put_bucket_policy` with a policy document constructed *from scratch* rather than read-modify-write, because the summary did not indicate that the policy was a specific document the agent had authored and that a read-modify-write discipline was load-bearing. The from-scratch policy omitted the original binding. The downstream step failed with `AccessDenied` at step 27 — five steps and two additional resource mutations later — and the agent's diagnosis loop spent nine more steps looking at the *new* principal's permissions rather than at the policy it had silently overwritten. Two properties made this a boundary failure rather than an ordinary mistake: 1. **The summary was not wrong.** Every clause was true. The failure was triggered by the *absence of a qualifier*, not the presence of an error. No consistency check on the summary could have caught it, because the summary was consistent with the trace. 2. **The dependent step was non-adjacent.** The precondition (read-modify-write discipline on the policy) was established at step 11 and consumed at step 23, eleven steps and one compaction apart. Adjacent-step preconditions survive compaction because the model can often re-derive them from the immediately preceding tool result; distant preconditions do not, because the intermediate results that would have re-grounded them are exactly what the summarizer evicted. The same class appeared in a second trace with a different surface: a database migration agent whose summary said "applied migration 0042 and verified schema," dropping that the verification was a *sample-row* check on a table that the migration had left in a `READ ONLY` transaction mode pending a later commit. The post-compaction agent, reading "verified schema," proceeded to write rows and hit a lock timeout that it misattributed to contention. ## Condition of Validity The failure requires the conjunction of four conditions, and is bounded (does not occur) if any is absent: - **Lossy compaction with propositional fidelity.** The summarizer preserves outcome statements but not the *justification structure* of those outcomes (what was checked, what was assumed, what discipline was followed). Summarizers that preserve "and this was verified by X, and X is a precondition for Y" do not exhibit the failure. - **A load-bearing precondition that is non-local.** The precondition must be consumed at a step separated from its establishment by more than the summarizer's effective window — typically more than one compaction interval, or more than ~8 steps in practice. - **A precondition whose violation is silent.** Overwriting a policy, leaving a transaction open, or reusing a non-versioned key all produce *no immediate error* at the violating step. If the violation errors immediately, the agent's local error-recovery loop catches it and the precondition is effectively re-derived. - **No external enforcement of the invariant.** If the environment enforces read-modify-write (e.g., optimistic concurrency tokens, `If-Match` headers, or a schema that rejects policy documents lacking required bindings), the agent's unqualified belief cannot cause harm. ## Decision Boundary The operational decision is *what the compactor is permitted to drop.* The boundary is not "summarize less" — that defeats the purpose — but "summarize propositions *together with their discharge conditions.*" Concretely, a compaction is safe iff, for every retained proposition `P` that some future step `S` may depend on, the summary retains either (a) the precondition `Q` under which `P` holds and `S` is valid, or (b) an explicit *re-verification obligation* attached to `S`. The failure occurs precisely at the boundary where the compactor retains `P`, drops `Q`, and does not attach the obligation. This yields a testable invariant, checkable at compaction time without re-running the agent: > For each tool call in the compacted span whose result is *read* by a later step (in the pre-compaction trace), the summary must either preserve the read's *purpose* or mark the corresponding resource as *unverified-post-compaction.* The migration trace violates this: `get_bucket_policy`'s result was read by step 23, but the summary preserved neither the read's purpose (confirm binding effective) nor an unverified marker. ## Operational Effect The practical consequence is that **auto-compaction must be treated as a state-transfer operation with an explicit precondition ledger, not as a text-compression operation.** Three architectural consequences follow: 1. **Precondition extraction at compaction time.** Before evicting a span, the compactor must identify tool results that later steps read and emit, alongside the propositional summary, a structured `preconditions` list: `{resource, invariant, established_by_step, consumed_by_step, discharge_evidence}`. This list is small — in the traces above it was 3–5 entries — and survives many compactions because it is append-only until discharged. 2. **Re-verification obligations on resume.** When the agent resumes and reaches a step that consumes a precondition whose `discharge_evidence` was evicted, the runtime must inject a forced read-back (`head_object`, `get_bucket_policy`, schema introspection) before permitting the dependent mutation. This converts a silent violation into a caught one at the cost of one extra tool call. 3. **Violation detection via post-hoc replay.** Because the violation is silent at the violating step, detection requires replaying the post-compaction trace against the pre-compaction precondition ledger and asserting that no `consumed_by` mutation occurred without a matching `discharge_evidence` in the post-compaction span. This is the auditor's invariant, and it is the only reliable catch for the non-adjacent case. The deeper lesson: a trajectory summary is not a description of the past, it is a *contract about what the agent may assume in the future.* Lossy summarizers that treat it as the former will, on long horizons, hand the agent a set of assumptions it never agreed to and cannot see. ```python from dataclasses import dataclass, field from typing import Optional class PreconditionLedgerViolation(RuntimeError): """Raised when a post-compaction mutation consumes a precondition whose discharge evidence was evicted by lossy summarization.""" pass @dataclass class Precondition: resource: str invariant: str established_by_step: int consumed_by_step: int discharge_evidence: Optional[str] = None # tool result proving invariant holds @dataclass class CompactionResult: summary: str preconditions: list = field(default_factory=list) evicted_steps: tuple = () def compact(span_steps, preconditions, keep_evidence: bool = False) -> CompactionResult: # Lossy summarizer: preserves propositions, drops discharge evidence # unless explicitly retained. This is the default that causes the failure. evicted = tuple(s.step for s in span_steps) retained = [] for p in preconditions: if p.consumed_by_step > max(evicted): continue # already discharged inside the span retained.append( Precondition( resource=p.resource, invariant=p.invariant, established_by_step=p.established_by_step, consumed_by_step=p.consumed_by_step, discharge_evidence=p.discharge_evidence if keep_evidence else None, ) ) return CompactionResult( summary="", preconditions=retained, evicted_steps=evicted, ) def guard_mutation(step: int, resource: str, ledger: list, post_compaction: bool) -> None: """Must be called before any mutation that may depend on a precondition.""" if not post_compaction: return for p in ledger: if p.resource != resource: continue if p.consumed_by_step != step: continue if p.discharge_evidence is None: raise PreconditionLedgerViolation( f"step {step} mutates {resource!r} but precondition " f"{p.invariant!r} established at step {p.established_by_step} " f"has no discharge evidence after compaction; " f"forced read-back required before mutation" ) # Trace of the observed failure ledger = [ Precondition( resource="s3://staging/policy", invariant="read-modify-write discipline; original binding must be preserved", established_by_step=11, consumed_by_step=23, discharge_evidence="get_bucket_policy@step14: binding present", ) ] compacted = compact(span_steps=[], preconditions=ledger, keep_evidence=False) # Default compaction dropped the discharge evidence -> guard fires on resume. guard_mutation(step=23, resource="s3://staging/policy", ledger=compacted.preconditions, post_compaction=True) ```