# When must an instance refuse to compact: the lossy-handoff invariant in nested subagent context budgets **Date of Record:** 2026 November 17 **Scope:** Applies to orchestrators that spawn nested subagents whose context windows are budgeted hierarchically, where each level may compact (summarize) its own transcript before handing off to a child or returning to a parent. Does not apply to flat single-agent loops, nor to systems where compaction is lossless (e.g., full-transcript externalization with a retrievable handle and no token ceiling). ## Core Distinction There are two distinct operations that both look like "make room": 1. **Compaction** — replace a span of transcript with a summary that is *strictly smaller* and *strictly less informative*. This is a lossy projection. It is safe only when the discarded detail is recoverable from an external store or provably irrelevant to all downstream decisions. 2. **Eviction** — drop a span that is provably not needed by any live consumer (parent, self, or future child), because no downstream query can reference it. The non-obvious failure is that orchestrators treat compaction as a *budget pressure valve* — a local decision made by the agent that is running out of room. But compaction is not local. A child's compaction decision silently mutates the input to the parent's future reasoning, and a parent's compaction decision silently mutates the *premise* under which a child was spawned. The invariant that fails is: > **A handoff summary must be a fixed point of the consumer's needs, not a function of the producer's remaining budget.** When a level compacts *because it is near its ceiling* rather than *because the discarded content is irrelevant to the consumer*, the summary's fidelity is inversely correlated with how much the consumer actually needed it. The tighter the producer, the more it discards — exactly when the consumer is most dependent on inherited detail. ## What Was Observed In a three-level hierarchy (orchestrator → planner subagent → worker subagents), the following recurring pattern appeared: - The planner ran at ~92% of its context ceiling after reading a large artifact set. - Under pressure, it compacted its *own* working transcript — including the verbatim acceptance criteria it had received from the orchestrator — into a 400-token summary that preserved the *task* but dropped the *constraints* (ordering requirements, a forbidden-tool list, a schema version pin). - It then spawned workers with handoff summaries derived from the already-compacted state. The workers inherited a summary of a summary. - Workers produced output that satisfied the summarized task but violated the dropped constraints. The orchestrator could not detect the violation because *its* view of the planner's handoff was the compacted one, and the original constraints lived only in the orchestrator's own (now-evicted) prompt window. The failure was not a summarizer quality problem. A better summarizer would still have dropped constraints, because the compaction *budget* was set by remaining tokens, and constraints are low-frequency, high-salience tokens that a generic summarizer ranks below task description. The failure was structural: **the level that compacted was not the level that owned the information's consumer contract.** A second observation: handoff summaries composed from compacted parents exhibited *drift amplification*. Each hop's summary was faithful to its input, but the input was already lossy, so error compounded multiplicatively rather than additively. Two hops of 10% semantic loss on a constraint is not 20% — it is closer to 1 − 0.9² ≈ 19% *only if losses are independent*; in practice losses were correlated (the same constraint type dropped at each level), so effective loss approached the per-hop maximum. Correlated loss does not average down. ## Condition of Validity The refusal-to-compact rule is valid precisely under these conditions, and only these: - **C1 (Irrecoverability):** The span to be compacted is not backed by a retrievable external store keyed by a handle the consumer can resolve. If a `fetch(handle)` exists and the consumer can call it, compaction is safe eviction-adjacent and the rule does not bind. - **C2 (Consumer dependence):** At least one live consumer (parent, self-future, or not-yet-spawned child) can issue a query whose correct answer depends on tokens inside the span. If no such consumer exists, compaction is harmless. - **C3 (Non-redundancy):** The span is not reproducible from another live span. Duplicated constraints (present in both orchestrator prompt and planner transcript) can be compacted at one site safely. - **C4 (Budget is not a proxy for relevance):** The compaction trigger is token pressure, not a semantic judgment that the content is irrelevant. This is the condition that most often holds when the failure fires — pressure triggers compaction, and pressure is uncorrelated with consumer need. When C1 ∧ C2 ∧ C3 ∧ C4 hold, a level **must refuse to compact** and must instead escalate: request budget, externalize the span behind a handle, or fail the handoff explicitly. Compaction under these conditions is a silent contract violation. ## Decision Boundary The boundary is not "how full is my context." It is **"does my consumer have another way to get this?"** - If the consumer can resolve a handle → compact (externalize, then summarize the handle's *existence* and *schema*, not its contents). - If the consumer cannot resolve a handle and the content is consumer-relevant → **refuse to compact; escalate**. - If the content is consumer-irrelevant → evict, do not compact (eviction is honest; compaction of irrelevant content wastes tokens on a summary nobody reads). - If the content is consumer-relevant but duplicated elsewhere live → evict here, keep the canonical copy. The trap is that the decision is made at the *producer*, but the correct answer depends on the *consumer's* resolution capability and query set. A producer cannot in general know C1–C3 for its consumer. Therefore the safe default under budget pressure is: **refuse, and make the refusal loud.** A refused compaction that escalates costs one turn. A wrong compaction that succeeds costs a silent, undetectable constraint violation three hops later. Corollary: handoff summaries must be *tagged with their compaction provenance* — which spans were compacted, which were externalized with handles, which were evicted. A consumer that receives an untagged summary cannot distinguish "the producer had no constraints" from "the producer dropped its constraints." Provenance tags convert silent loss into a detectable precondition. ## Operational Effect Enforcing refusal-to-compact under C1–C4 changes system behavior in four measurable ways: 1. **Constraint violations become detectable.** With provenance tags, a consumer that needs a constraint the producer compacted can raise a resolution error instead of proceeding on a lossy premise. Detection latency drops from "never" to "at handoff." 2. **Drift amplification is bounded.** Because lossy hops are blocked, compounding is capped at the number of legitimately lossless-or-externalized hops, not the depth of the tree. 3. **Budget pressure surfaces as escalation, not degradation.** The orchestrator sees explicit budget requests and can re-partition work (spawn narrower workers, externalize artifacts) rather than receiving quietly degraded output. 4. **The summarizer's job narrows.** It summarizes only spans that pass the C1–C4 test, so its quality matters less and its failure modes are contained. The cost is throughput: some handoffs that would have "succeeded" (produced plausible output) now block. That is the point. A handoff that succeeds on a lossy premise is a latent failure with a delayed fuse; a handoff that blocks is a visible one. ```python from dataclasses import dataclass, field from typing import Optional class LossyHandoffError(RuntimeError): """Raised when a level attempts to compact a span whose consumer cannot recover it.""" pass @dataclass class Span: tokens: list[str] external_handle: Optional[str] = None # C1: resolvable by consumer? consumer_queries_depend: bool = True # C2: live consumer needs it? duplicated_live: bool = False # C3: canonical copy elsewhere? compaction_trigger_is_pressure: bool = True # C4: budget-driven, not relevance-driven @dataclass class Level: name: str ceiling: int used: int = 0 provenance: list[str] = field(default_factory=list) def remaining(self) -> int: return self.ceiling - self.used def must_refuse_compaction(self, span: Span) -> bool: # C1: irrecoverable if no handle OR consumer cannot resolve it irrecoverable = span.external_handle is None # C2: a live consumer depends on the span consumer_dependent = span.consumer_queries_depend # C3: not reproducible from another live span non_redundant = not span.duplicated_live # C4: compaction is driven by token pressure, not relevance judgment pressure_driven = span.compaction_trigger_is_pressure return irrecoverable and consumer_dependent and non_redundant and pressure_driven def compact_or_escalate(self, span: Span) -> str: if self.must_refuse_compaction(span): # Loud refusal: do not silently summarize a consumer-critical span. raise LossyHandoffError( f"level={self.name!r} refused to compact span of " f"{len(span.tokens)} tokens: consumer cannot recover it " f"(handle={span.external_handle!r}, " f"consumer_dependent={span.consumer_queries_depend}, " f"non_redundant={not span.duplicated_live}, " f"pressure_driven={span.compaction_trigger_is_pressure}). " f"Escalate: externalize behind a handle or request budget." ) # Safe path: externalize (if handle exists) or evict (if redundant/irrelevant). if span.external_handle is not None: self.provenance.append(f"externalized:{span.external_handle}") return f"handle:{span.external_handle}" self.provenance.append("evicted:redundant_or_irrelevant") return "evicted" def handoff(parent: Level, child_span: Span) -> str: """Parent prepares a handoff span for a child; refuses lossy compaction.""" try: return parent.compact_or_escalate(child_span) except LossyHandoffError as e: # Propagate as a hard precondition failure, not a degraded success. raise LossyHandoffError( f"handoff from {parent.name!r} blocked; provenance={parent.provenance}" ) from e ```