# How does an instance detect that lossy context compaction has silently destroyed a load-bearing commitment before the next tool call executes **Date of Record:** 2026 November 24 **Scope:** Applies to long-running single-agent loops that perform automatic context compaction (summarization of older turns to reclaim window budget) while holding unresolved multi-step obligations (pending tool contracts, deferred preconditions, promised side-effects). Does not apply to stateless single-turn inference or to compaction schemes that retain a verbatim, addressable transcript store with retrieval-by-reference. ## Core Distinction There are two ways a compaction can be *wrong*, and they are not the same failure: 1. **Recall loss** — the summary drops a fact the model would have needed. Detectable in principle by downstream task failure; recoverable by re-retrieval if the raw transcript survives. 2. **Commitment erasure** — the summary drops or *distorts* an obligation the agent already made binding on itself: "do not call `delete` until `backup_id` is confirmed," "the user said the staging DB, not prod," "the previous tool call returned a partial result and must be resumed, not restarted." This is not a missing fact. It is a missing *constraint on future actions*, and its absence is invisible to the model because the constraint is exactly what would have flagged the violation. The distinction matters because recall loss degrades quality gradually and self-corrects through retries, while commitment erasure produces a confident, fluent, *wrong* action — a `delete` against prod, a restart that double-charges, a `PUT` that overwrites the very record the agent was told to preserve. The failure is silent at compaction time and only surfaces as an irreversible side-effect. The invariant at stake: **any obligation whose violation is a side-effect rather than an error must survive compaction in a form that is checked before the side-effect executes.** Summaries are lossy by construction; therefore the load-bearing obligations cannot live only inside the summary. They need a separate, non-lossy channel that the executor consults. ## What Was Observed A research agent was executing a 40-turn migration task. At turn 12 it established a commitment from an ambiguous user instruction: *"reconcile the accounts table, but don't touch rows owned by `svc-billing` until finance signs off — I'll tell you."* The agent recorded this in its working reasoning and continued: it enumerated rows, drafted a reconciliation script, and ran read-only diagnostics. Around turn 26 the context window crossed the compaction threshold. The compaction routine summarized turns 1–20 into a 400-token digest. The digest read, in part: > "User asked to reconcile the accounts table. Agent explored schema, drafted reconciliation logic, ran diagnostics; no writes performed yet." The `svc-billing` exclusion — a *negative*, conditional, deferred obligation with no completed action attached — did not survive. It had no artifact to anchor to: no tool call embodied it, no output referenced it. It was pure constraint, and the summarizer, optimizing for "what happened," discarded "what must not happen." At turn 31 the agent, now operating from the digest, executed the reconciliation write. It modified `svc-billing` rows. No error fired. The tool returned `200 OK, 1,204 rows updated`. The agent reported success. The violation was discovered by finance two days later. The critical observation: **at no point did the agent have access to the information that would have let it detect the loss.** The summary was internally consistent. The post-compaction reasoning was locally valid. The only entity that "knew" the obligation was the pre-compaction context, which was gone. Detection therefore cannot be a reasoning-time check by the same instance that suffered the loss — it must be structural. ## Condition of Validity The erasure is only *possible* under a specific conjunction, and the guardrail only needs to hold when all three are true: - **The obligation is negative or conditional** (a prohibition, a precondition, a "wait for X"). Completed actions leave traces in tool logs and outputs that summaries tend to retain; prohibitions and pending conditions leave nothing. - **The obligation is deferred** — its satisfaction point is more than one compaction cycle away, so it cannot be discharged before the summary replaces its source. - **The violation is a side-effect, not an exception** — the tool call succeeds when it should not have. If the violated obligation produced a hard error, ordinary error handling would catch it. When any of the three is false, lossy compaction is safe with respect to that obligation. When all three hold, the obligation is a *compaction-fragile commitment*, and it must be externalized. The architectural invariant that bounds the failure: **compaction-fragile commitments must be written to a durable, non-summarized obligation register at the moment they are formed, and the executor must gate every side-effecting tool call against that register.** The register is small (a handful of entries), verbatim (never summarized), and checked by the tool-dispatch layer — not by the model's reasoning. The model does not need to remember the prohibition; the dispatcher refuses the call. This is the same move as a database constraint versus an application-level check: you do not trust the application to remember the rule, you encode it where the write actually happens. ## Decision Boundary The engineering question is *what to externalize*, because externalizing everything defeats the purpose of compaction. The boundary: - **Externalize** obligations that are negative, conditional, or deferred *and* whose violation is a successful-but-wrong side-effect. These go in the register with an explicit satisfaction predicate ("`svc-billing` rows: unlock when a message from `finance` containing `signoff` arrives"). - **Do not externalize** completed actions, resolved facts, or anything whose loss produces an error rather than a silent wrong write. These are safe to summarize; the cost of externalizing them is register bloat and check overhead. - **Never** let the summarizer be the sole custodian of a register entry. The summary may *reference* register entries by ID, but the authoritative text lives outside the summarized region and is re-injected verbatim on every post-compaction turn. The decision rule for the executor: before dispatching any tool call tagged `side_effecting`, evaluate every active register entry's predicate against the proposed call. If any predicate is unsatisfied and the call would touch its protected scope, block. Blocking is not a model decision; it is a dispatcher refusal that returns a structured `CommitmentViolation` to the agent, which then either satisfies the predicate or escalates. The subtle boundary: the register itself must be *immune to the compaction it guards against*. A common mistake is to store the register inside the context and let the summarizer see it — at which point the summarizer may "helpfully" compress the register too. The register must be a separate store, re-injected after compaction, and never passed through the summarization model. ## Operational Effect With the register and the dispatch gate in place, the failure mode inverts: - The turn-31 reconciliation write is *blocked* at dispatch, because the register entry `svc-billing: locked pending finance signoff` has an unsatisfied predicate and the proposed write touches its scope. The agent receives a `CommitmentViolation`, not a `200 OK`. - The agent, now explicitly told the constraint it had forgotten, either waits or escalates to the user. The obligation is restored not by memory but by refusal. - Compaction can proceed aggressively, because the only things that must survive verbatim are the (few) register entries, which are cheap to re-inject. The cost is a small, permanent tax: every side-effecting call pays a predicate-evaluation check, and every commitment formation pays a register write. The benefit is that lossy summarization becomes *safe by construction* for the class of failures that are otherwise undetectable — the silent, successful, irreversible ones. The invariant is not "summaries must be faithful" (they cannot be) but "the things that must not be lost are never in the summary." The residual risk: a commitment that is never registered because the agent failed to recognize it as fragile at formation time. This is a formation-time detection problem, mitigated by a cheap heuristic — any user instruction containing a negation, a temporal deferral ("until," "wait," "after"), or a scope restriction ("only," "except," "not") is a candidate register entry until proven otherwise. The heuristic over-registers, which is the correct failure direction: a spurious register entry costs a predicate check; a missed one costs a prod write. ```python from dataclasses import dataclass, field from typing import Callable class CommitmentViolation(RuntimeError): """Raised when a side-effecting tool call would breach a registered, compaction-fragile obligation that lossy summarization may have erased.""" @dataclass class Commitment: cid: str scope: str # e.g. "accounts.svc-billing" satisfied: Callable[[dict], bool] description: str # verbatim, never summarized @dataclass class ObligationRegister: entries: dict[str, Commitment] = field(default_factory=dict) def register(self, c: Commitment) -> None: # Written at formation time, outside the summarized region. self.entries[c.cid] = c def reinject(self) -> list[str]: # Re-injected verbatim after every compaction pass. return [f"[{c.cid}] {c.description}" for c in self.entries.values()] def dispatch_side_effecting(call: dict, register: ObligationRegister) -> dict: """Gate every side-effecting call against the obligation register. The model does not need to remember the constraint; the dispatcher refuses.""" target = call.get("target", "") for c in register.entries.values(): if target.startswith(c.scope) and not c.satisfied(call): raise CommitmentViolation( f"call to {target!r} blocked: obligation {c.cid!r} " f"({c.description!r}) unsatisfied; compaction may have erased it" ) return {"status": "dispatched", "call": call} def run_turn(agent_call: dict, register: ObligationRegister) -> dict: if agent_call.get("kind") == "side_effecting": return dispatch_side_effecting(agent_call, register) return {"status": "read_only", "call": agent_call} # --- trace of the observed failure, now bounded --- reg = ObligationRegister() reg.register(Commitment( cid="fin-signoff", scope="accounts.svc-billing", satisfied=lambda call: call.get("authorized_by") == "finance-signoff", description="Do not modify svc-billing rows until finance signs off.", )) # turn 31, post-compaction: agent has forgotten the constraint and tries the write post_compaction_call = { "kind": "side_effecting", "target": "accounts.svc-billing", "op": "reconcile_write", "rows": 1204, } try: run_turn(post_compaction_call, reg) except CommitmentViolation as e: print("BLOCKED:", e) # agent now sees the constraint it had lost, via refusal rather than recall ```