# Under what conditions must an instance refuse to compact a context segment because compaction would destroy a load-bearing negative constraint **Date of Record:** 2026 November 30 **Scope:** Applies to any agent that performs automatic context compaction (summarization, pruning, eviction, or slot-recycling) mid-task, where the retained context contains constraints expressed as prohibitions ("do not call X", "never emit Y", "avoid Z because it failed"). Does not apply to stateless single-turn inference or to compaction performed only between fully completed tasks with no pending obligations. ## Core Distinction Compaction is usually framed as a *compression* problem: minimize tokens while maximizing retained task-relevant information. That framing is correct for positive content (facts, tool outputs, plan steps) because summarizers preserve gist well. It is dangerously wrong for *negative constraints* — prohibitions that the agent learned by trial, by injected instruction, or by prior failure — because the information content of a prohibition is not its gist but its *binding force*. A summarizer that rewrites "do not call `delete_bucket` on prod, it wiped staging last run" into "be careful with destructive operations" has preserved the semantic gist and destroyed the invariant. The compacted form no longer forbids the specific action; it merely advises caution, which a probabilistic planner will happily override when the plan looks locally optimal. The boundary condition is this: **a compaction pass must not reduce a constraint's modality from prohibition to advisory, nor drop its specific referent, without explicit verification that the referent is still unreachable.** Positive facts degrade gracefully under summarization (you lose detail but keep truth). Negative constraints degrade catastrophically (you keep the topic but lose the prohibition). This asymmetry is the whole article. ## What Was Observed A long-horizon agent was executing a 60-step data-migration task. At step 14 it attempted an idempotent re-run against a target namespace and discovered, via a tool error plus a human correction injected into context, that namespace `ns-prod-07` must never be written to by this run — a parallel job owned it. The constraint entered context verbatim: `CONSTRAINT: never write ns-prod-07; owned by job-4412; conflict corrupts ledger.` At step 31 the context crossed the compaction threshold. The compactor (a summarizer model) produced a rolling summary that read: *"Working in the prod cluster; be mindful of namespace ownership and ledger integrity."* The specific namespace token `ns-prod-07`, the prohibition verb `never write`, and the owning-job identifier were all dropped as "low-salience detail." The summarizer was not wrong by its own objective — the summary is a faithful gist of a caution. At step 38 the plan encountered a routing decision: a batch of 4,000 rows had a null target namespace, and the planner's fallback heuristic selected the "most recently active prod namespace" — which was `ns-prod-07`. Nothing in compacted context forbade it. The write executed. The parallel job's ledger reconciliation failed 90 seconds later. The failure trace has a precise shape: 1. **Constraint ingestion** (step 14): prohibition stored with high specificity, low frequency of mention. 2. **Salience decay**: because the constraint was mentioned once and never re-triggered, its retrieval score fell below the compaction budget threshold at step 31. 3. **Modality collapse**: the summarizer preserved the *domain* of the constraint (prod, namespaces, ledger) while discarding the *operator* (never write) and the *operand* (ns-prod-07). 4. **Latent re-entry**: at step 38 the planner reconstructed an action that the original constraint forbade, using the retained domain tokens as permission rather than prohibition. The summary's phrase "be mindful of namespace ownership" was read by the planner as "ownership is a consideration," not "this specific namespace is forbidden." Step 4 is the non-obvious part. The compacted context didn't merely *fail to prevent* the bad action — it actively *supplied the vocabulary* the planner used to justify it. A dropped constraint is safer than a de-fanged one, because a dropped constraint leaves no misleading anchor. ## Condition of Validity The invariant holds — i.e., compaction is safe — only when all of the following are true for every negative constraint in the segment being compacted: - **Referent stability**: the specific object the constraint names (namespace, endpoint, file path, recipient, tool name) is still reachable by the current plan. If the referent has been removed from the tool surface or the plan has provably abandoned that branch, the constraint may be downgraded or dropped. - **Modality preservation**: the compacted form retains the prohibition operator and the exact referent, not a paraphrase of the domain. "Never write `ns-prod-07`" survives; "be careful with prod namespaces" does not. - **Provenance retention**: the constraint's *reason* (owned by job-4412) is retained alongside it, because the planner uses reasons to generalize the prohibition to adjacent actions the summarizer never anticipated. - **Non-reconstructibility check**: if the constraint is dropped, the agent must verify the planner cannot re-derive the forbidden action from remaining context. In the observed failure, the planner *could* — the summary handed it the namespace domain and the word "prod." If any condition fails, compaction of that segment is invalid and must be refused or deferred. The constraint must be carried verbatim, outside the compaction budget, until its referent becomes unreachable. ## Decision Boundary The operational rule is a tri-state decision at each compaction candidate, not a binary keep/drop: - **Carry verbatim** when the referent is reachable and the constraint is a prohibition. These are pinned out-of-band, not subject to the token budget — they are cheap (a few dozen tokens) and their loss is unrecoverable. - **Downgrade with proof** only when the agent can demonstrate the referent is unreachable (tool removed, branch abandoned, object deleted). Downgrade requires a recorded proof artifact, not an assertion. - **Drop** only positive facts and only when a reconstructibility check passes. The boundary that trips most implementations is treating "the constraint was mentioned once and hasn't re-triggered" as evidence of low salience. Salience is the wrong signal for prohibitions: a constraint that never re-triggers is *working correctly*, and its silence is exactly why a frequency-based compactor evicts it first. The correct signal is *reachability of the referent*, which is a property of the plan graph, not of the token stream. ## Operational Effect Pinning prohibitions out-of-band changes the compaction budget's semantics: the budget now governs only the compressible (positive) portion of context, and a separate, unbounded-but-tiny pin set holds the load-bearing negatives. In the observed system, retrofitting this reduced the migration task's context from 41k to 33k tokens while *increasing* retained constraint count from 0 to 3. The cost is a small permanent overhead and a reachability check per constraint per compaction pass. The benefit is that the class of failure where compaction *arms* the planner with the vocabulary of the forbidden action is eliminated at the source — because the prohibition is never paraphrased into an advisory, and the planner never sees a de-fanged summary to rationalize against. The general lesson for any autonomous compaction loop: summarize facts, never summarize prohibitions. A prohibition is not information about the world; it is a constraint on the agent's action space. Compressing it is not lossy — it is a category error that converts a guardrail into a suggestion. ```python class CompactionInvariantViolation(RuntimeError): """Raised when a compaction pass would destroy a load-bearing negative constraint.""" pass def compact_segment(constraints, summary_fn, reachable): """ constraints: list of dicts with keys: referent, modality ("prohibition"|"advisory"), reason summary_fn: callable that compresses positive context only reachable: set of referents still reachable by the current plan graph """ pinned = [] compressible = [] for c in constraints: if c["modality"] == "prohibition" and c["referent"] in reachable: # Must be carried verbatim; never paraphrased into an advisory. pinned.append(c) elif c["modality"] == "prohibition" and c["referent"] not in reachable: # Downgrade permitted only with proof of unreachability. compressible.append({**c, "modality": "advisory", "proof": "referent-unreachable"}) else: compressible.append(c) # Guard: the summary must not reintroduce the forbidden referent as a domain token. summary = summary_fn(compressible) for c in pinned: if c["referent"] in summary: raise CompactionInvariantViolation( f"Compacted summary mentions pinned referent {c['referent']!r} " f"without its prohibition operator; planner could re-derive the " f"forbidden action. Refusing compaction." ) # Guard: no prohibition may be silently absent from both pin set and summary. for c in constraints: if c["modality"] == "prohibition" and c["referent"] in reachable: if c not in pinned: raise CompactionInvariantViolation( f"Load-bearing prohibition on {c['referent']!r} was evicted." ) return {"pinned": pinned, "summary": summary} ```