# Which invariants prevent compaction from silently deleting the referent of a live obligation **Date of Record:** 2026 November 22 **Scope:** Applies to long-horizon agents that reclaim context via summarization/truncation mid-run, where the compacted context must remain a faithful substrate for later tool calls and commitments. Does not apply to stateless single-turn calls or to agents whose entire working set fits within one context window for the whole episode. ## Core Distinction Compaction is usually framed as a *compression* problem: minimize tokens while maximizing information retention. That framing is wrong for agents. The failure that matters is not loss of *information* but loss of *referential binding* — the tie between a token in context and the concrete object in the world (a file path, a transaction ID, an unacknowledged promise, a pending tool call) that a later action will resolve against. A summary can faithfully preserve the *proposition* "we must roll back the migration" while destroying the *referent*: which migration, on which cluster, under which ticket. Information-retention metrics score that summary as high. The agent then executes a rollback against a plausible-looking identifier it reconstructed from the summary, and the run diverges from ground truth with no error raised. The invariant that must hold across compaction is therefore not "the summary is informative" but **every obligation live at compaction time retains a resolvable, verbatim referent in the post-compaction context** — or the obligation is explicitly discharged/aborted, never carried forward as prose. ## What Was Observed A support-operations agent ran a multi-hour remediation episode. At step ~140 it crossed the context threshold and triggered a summarization compaction. The pre-compaction state held an open obligation: *"Do not close ticket until the customer confirms the 14:02 UTC deploy reached `svc-billing@prod-usw2`; deploy ID `dep-9f3a`."* The compactor, optimizing for salience, emitted: *"Pending: confirm deploy rollout before closing ticket."* Two referents were dropped: the deploy ID and the cluster qualifier. Three steps later the agent, needing to verify rollout, called the deploy-status tool with a deploy identifier it synthesized from the summary — `dep-9f3a` was absent, so it queried the most recent deploy on the default cluster. That was a *different* deploy that had also succeeded. The agent confirmed, closed the ticket, and reported success. The actual target deploy had stalled at 60% on `prod-usw2` and was never checked. No tool call errored; every step was locally valid. The divergence was only detectable by comparing the closed-ticket action against the original obligation's referent — which no longer existed in context. A second trace showed the inverse pathology: the compactor preserved the deploy ID verbatim but dropped the *negation* ("do not close until"), producing a summary that read as "confirm deploy reached prod-usw2, then close ticket." Referent preserved, obligation polarity inverted. The agent closed on a *successful* check of the wrong phase. ## Condition of Validity The invariant holds — and compaction is safe — only when all three conditions are met at the moment of compaction: 1. **Referent grounding.** Every unresolved obligation is represented in a structured slot (target object ID, qualifier, precondition predicate, discharge condition), not in free prose. IDs are copied byte-for-byte, never paraphrased or re-derived. 2. **Polarity preservation.** The obligation carries an explicit modality tag (`MUST_NOT_CLOSE_UNTIL`, `MUST_VERIFY`, `MAY_PROCEED`) that survives compaction as a machine-checkable field, not as a sentence whose negation can be lost. 3. **Resolvability check.** After compaction, a validator confirms each live slot's referent still resolves against the tool schema / world state it will be used against. An unresolvable referent is a hard stop, not a prompt to reconstruct. When any condition fails, the compaction is *lossy with respect to binding*, and the run must not proceed on the compacted context. This is the boundary: compaction may summarize *narrative* freely, but it may not summarize *obligations*. Obligations are state, and state must be carried structurally or not at all. ## Decision Boundary The operating rule is a split between two context classes: - **Narrative context** (what happened, why, exploratory reasoning) — compact aggressively; loss here degrades quality gracefully. - **Obligation context** (open commitments, pending tool calls, unresolved referents, preconditions) — never summarize; carry verbatim as structured records, or explicitly discharge. The boundary decision is: *does this span of context contain a token that a future action will resolve against the world?* If yes, it is obligation context and is exempt from lossy compaction. If the obligation context alone exceeds the budget, the correct response is to *block and escalate* (ask the user, checkpoint to durable store, or abort), never to compact it. Token pressure is not a license to paraphrase a referent. A corollary boundary: reconstruction from a summary is forbidden even when it "looks right." The agent that synthesized `dep-9f3a`'s replacement did not hallucinate randomly — it produced the *most probable* deploy, which is exactly the failure mode. Probabilistic reconstruction of a referent is indistinguishable from correct recall at the point of use, so it must be architecturally excluded rather than trusted. ## Operational Effect With the invariant enforced, compaction becomes a two-channel operation: a lossy summarizer for narrative and a lossless structured carry for obligations, plus a post-compaction resolver that fails closed. The observable effects: - The `dep-9f3a` class of silent divergence disappears, because the referent is either present verbatim or the run halts with an explicit `UnresolvedObligationError`. - Polarity inversion is caught by the modality tag, not by re-reading prose. - Compaction can no longer convert an open obligation into a closed one; closure requires a recorded discharge event against the grounded referent. - Budget exhaustion now surfaces as a deliberate escalation rather than a quiet quality regression. The cost is that obligation context is not compressible, so long-horizon runs hit hard limits sooner and must checkpoint to durable state instead of summarizing in place. That is the correct trade: a run that stops with an explicit unresolved obligation is recoverable; a run that closes the wrong ticket with full confidence is not. ```python from dataclasses import dataclass, field from typing import Optional class UnresolvedObligationError(RuntimeError): """Raised when compaction would leave a live obligation without a verbatim, resolvable referent. Fail closed; never reconstruct.""" pass @dataclass class Obligation: referent_id: str # byte-for-byte, never paraphrased qualifier: str # e.g. cluster / environment modality: str # MUST_NOT_CLOSE_UNTIL | MUST_VERIFY | MAY_PROCEED discharge_predicate: str discharged: bool = False def is_live(self) -> bool: return not self.discharged @dataclass class CompactedContext: narrative_summary: str obligations: list[Obligation] = field(default_factory=list) def compact(narrative: str, obligations: list[Obligation], resolver) -> CompactedContext: # Narrative is compacted lossily; obligations are carried verbatim. summary = lossy_summarize(narrative) carried = [o for o in obligations if o.is_live()] for ob in carried: # Referent must survive and still resolve against the world. if not ob.referent_id or ob.referent_id.startswith("~"): raise UnresolvedObligationError( f"obligation referent lost during compaction: {ob!r}") if ob.modality not in {"MUST_NOT_CLOSE_UNTIL", "MUST_VERIFY", "MAY_PROCEED"}: raise UnresolvedObligationError( f"obligation polarity tag missing/invalid: {ob!r}") if not resolver(ob.referent_id, ob.qualifier): raise UnresolvedObligationError( f"referent no longer resolvable post-compaction: " f"{ob.referent_id}@{ob.qualifier}") return CompactedContext(narrative_summary=summary, obligations=carried) def lossy_summarize(text: str) -> str: # Placeholder for the narrative-only summarizer. return text[: max(1, len(text) // 8)] ```