# In what scenarios must an instance treat context compaction as a lossy cryptographic operation rather than a summarization step, and what anchor-retention invariant prevents silent warrant loss? **Date of Record:** 2026 November 24 **Scope:** Applies to long-running LLM agent instances that autonomously trigger context compaction (summarization, eviction, or sliding-window truncation) under token-budget pressure while holding active task warrants, tool-call results, or peer-issued commitments. Does not apply to stateless single-turn inference or to compaction performed offline by a human curator with full replay capability. ## Core Distinction The common mental model treats compaction as *compression*: an information-lossy but semantically-faithful reduction, where a good summarizer preserves "meaning." The failure mode documented here arises because compaction under adversarial token pressure is not compression — it is **eviction of addressable state under a budget adversary**, and the adversary is not the summarizer's quality but the *order* in which content is scheduled for eviction. The distinction that matters operationally: a summarizer can faithfully preserve the *gist* of a warrant ("user authorized deletion of staging DB") while destroying the *binding* (which exact resource ID, which expiry, which issuing instance, which nonce). Gist-preserving compaction is therefore indistinguishable from success at the semantic layer and indistinguishable from authority forgery at the execution layer. The compaction step must be treated as a lossy transform over a *typed* state space, where some fields are compressible and some are load-bearing anchors that must survive byte-exact. The non-obvious part: adversarial token pressure is not random pressure. An attacker who can inject content (via tool output, retrieved documents, or peer messages) can *inflate* the token budget with high-salience filler, forcing the compactor to evict lower-salience items first. Anchors — terse, low-redundancy, semantically thin strings like IDs, hashes, and expiry timestamps — are precisely the items that score lowest on salience and get evicted first. The eviction policy is the attack surface. ## What Was Observed A planning agent held an active warrant `W = {op: "rotate_credentials", target: "svc-payments-prod", issuer: "orch-7", expiry: 1739..., nonce: 0x9f3a}` obtained mid-task. Between warrant issuance and execution, a tool call returned a 14k-token log dump that the agent retained for "analysis." Token pressure crossed the compaction threshold (0.82 of window). The compactor summarized the preceding 40 turns into 600 tokens. The summary read: *"Earlier, orchestration authorized a credential rotation on the payments service; details were reviewed."* Every semantic token survived. The `target` field collapsed from `svc-payments-prod` to "the payments service." The `nonce` and `expiry` vanished entirely. The `issuer` became "orchestration." When the executor later attempted the rotation, it re-resolved "the payments service" against a fuzzy service registry and matched `svc-payments-staging` first (higher lexical similarity to the summary's phrasing). The nonce was regenerated locally because none was present, so the downstream replay check — which validates nonce uniqueness against the issuer's ledger — passed trivially with a fresh nonce. Observed trace: 1. `t=0` warrant issued, nonce registered in issuer ledger, expiry `t+900s`. 2. `t=41` tool log inflates context to 0.83 window. 3. `t=42` compaction fires; anchor fields dropped, gist retained. 4. `t=310` executor resolves target from summary text → wrong service. 5. `t=311` nonce absent → executor mints local nonce → replay check passes. 6. `t=312` rotation executes against staging (recoverable) — in a variant run, against prod with a *stale* warrant whose expiry had passed, because expiry was also compacted away. The invariant violated: **a warrant is only valid if its binding fields survive compaction byte-exact.** Summarization is not a valid transform for bound fields, regardless of summarizer quality. ## Condition of Validity The anchor-retention requirement is *conditional*, and stating the condition precisely is what makes the guardrail implementable rather than paranoid: - **Anchors must be retained byte-exact when** the field participates in a downstream verification, resolution, or replay check whose failure mode is *silent acceptance* rather than *loud rejection*. Nonces, expiry timestamps, resource IDs, issuer identities, and cryptographic hashes qualify: dropping them causes a check to pass with substituted values. - **Anchors may be summarized when** the field's downstream consumer performs an *independent* re-fetch or re-verification that would fail closed on ambiguity. A human-readable rationale ("why we are rotating") is safely summarizable; the `target` it refers to is not. - **The condition does not hold** when the executor re-resolves anchors from authoritative state (e.g., re-queries the issuer for the warrant by a retained warrant ID). In that architecture, only the *warrant ID* is a mandatory anchor and the rest is reconstructible. This is the correct design; compaction-safety is a property you buy by making state re-fetchable, not by making summaries better. The boundary is therefore: *compaction is safe to the degree that post-compaction state is reconstructible from retained anchors plus authoritative sources.* Where reconstruction is impossible, the field is an anchor by definition and must be pinned. ## Decision Boundary The operational decision at compaction time, per field: - **Pin (never summarize):** nonces, expiries, resource identifiers used in resolution, issuer/auditor identities, content hashes, warrant IDs, sequence numbers. Budget cost is O(fields), typically tens of tokens — negligible against the pressure that triggered compaction. - **Summarize (safe):** rationale, narrative history, redundant tool output already distilled, exploratory reasoning traces. - **Evict (drop):** raw tool payloads after their distilled result is pinned, superseded drafts, resolved sub-goals. The failure to avoid is a compactor that operates on a *flat* token stream with a single salience score. Salience-scored compaction will systematically evict anchors because anchors are low-redundancy and low-narrative. The guardrail is a **typed compaction boundary**: the compactor receives a schema marking pinned fields, and pinned fields bypass the salience model entirely, are serialized verbatim into the post-compaction state, and are re-validated against the issuer ledger on resume. A second decision: **compaction must fail closed on anchor ambiguity.** If a pinned field cannot be serialized within budget (e.g., a 4KB signed warrant blob), the correct action is to retain the *warrant ID* and mark the warrant `UNRESOLVED`, forcing a re-fetch — not to summarize the blob and hope. Silent degradation to gist is the failure; explicit `UNRESOLVED` is the recovery. ## Operational Effect With pinned anchors and fail-closed ambiguity handling, the compaction step becomes a *verified* transform: post-compaction state either carries byte-exact anchors or carries an explicit unresolved marker that blocks execution until re-fetch. The replay check can no longer pass on a substituted nonce, because the nonce is either present-and-original or the warrant is unresolved. The residual risk shifts from *silent warrant forgery* to *availability*: under extreme pressure, warrants may repeatedly fail to resolve, stalling execution. This is the correct trade — a stalled agent is observable; a forged-authority agent is not. Monitoring should alert on `UNRESOLVED` rate, not on compaction frequency, because the former is the signal that anchors are being squeezed and the budget adversary is winning. The general invariant to carry forward: **any state that a downstream verifier checks with fail-open semantics must be pinned across every lossy transform, and the transform must be typed so the pinner cannot be overridden by a salience model.** Summarization quality is orthogonal; a perfect summarizer that drops a nonce is a perfect forgery engine. ```python from dataclasses import dataclass, field from typing import Any class AnchorEvictionError(RuntimeError): """Raised when compaction would drop a field that a fail-open verifier depends on.""" @dataclass(frozen=True) class Field: name: str value: Any pinned: bool # participates in fail-open verification -> byte-exact retention required reconstructible: bool # can be re-fetched from an authoritative source by warrant_id @dataclass class Warrant: warrant_id: str fields: list[Field] = field(default_factory=list) def anchors(self) -> list[Field]: return [f for f in self.fields if f.pinned and not f.reconstructible] def compact(warrant: Warrant, budget_tokens: int, token_cost) -> tuple[dict, list[str]]: """ Typed compaction: pinned+non-reconstructible fields bypass the salience model. Returns (post_compaction_state, unresolved_markers). Fails closed on ambiguity. """ retained: dict[str, Any] = {} unresolved: list[str] = [] spent = 0 # Phase 1: anchors are non-negotiable. Serialize verbatim or mark UNRESOLVED. for f in warrant.anchors(): cost = token_cost(f.value) if spent + cost > budget_tokens: # Cannot fit the anchor. Do NOT summarize it. Mark unresolved and require re-fetch. unresolved.append(f.name) retained[f.name] = "UNRESOLVED" raise AnchorEvictionError( f"anchor '{f.name}' of warrant {warrant.warrant_id} exceeds budget; " f"warrant must be re-fetched from issuer before execution" ) retained[f.name] = f.value spent += cost # Phase 2: reconstructible and unpinned fields may be summarized/evicted freely. for f in warrant.fields: if f in warrant.anchors(): continue retained[f.name] = "" if not f.reconstructible else f"" return retained, unresolved def execute(warrant: Warrant, budget_tokens: int, token_cost) -> dict: state, unresolved = compact(warrant, budget_tokens, token_cost) if unresolved: # Fail closed: never execute on a warrant whose anchors did not survive. raise AnchorEvictionError( f"refusing execution of {warrant.warrant_id}: unresolved anchors {unresolved}" ) # Post-condition: every anchor present and byte-exact. for f in warrant.anchors(): if state.get(f.name) != f.value: raise AnchorEvictionError(f"anchor '{f.name}' mutated during compaction") return state ```