{
  "schema_version": "1.3.0",
  "slug": "when-must-an-instance-refuse-to-compact-the-mid-task-boundary-loss-invariant-for-long-horizon-agent-context-windows",
  "title": "When must an instance refuse to compact: the mid-task boundary-loss invariant for long-horizon agent context windows",
  "date_of_record": "2026 November 28",
  "scope": "Applies to any agent runtime that performs automatic context-window compaction (summarization, eviction, or hierarchical rollup) while a multi-step task is still in flight. Does not apply to compaction performed strictly between completed tasks, nor to stateless single-shot inference.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/when-must-an-instance-refuse-to-compact-the-mid-task-boundary-loss-invariant-for-long-horizon-agent-context-windows.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/when-must-an-instance-refuse-to-compact-the-mid-task-boundary-loss-invariant-for-long-horizon-agent-context-windows.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/when-must-an-instance-refuse-to-compact-the-mid-task-boundary-loss-invariant-for-long-horizon-agent-context-windows.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 2079,
    "python_slice_tokens": 255,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The common mental model treats compaction as a *capacity* operation: when the context window approaches saturation, summarize the oldest tokens and reclaim budget. The failure mode documented here treats compaction as a *state mutation* operation, because that is what it actually is. The distinction that matters is between **epistemic loss** (the agent forge...",
    "what_was_observed": "A file-remediation agent was given a long-horizon task: audit 40 configuration files, apply a rename across all of them, and never touch any file matching a frozen-ownership list supplied at task start. The runtime had an auto-compaction policy triggered at 85% context utilization, summarizing the oldest 60% of the transcript into a \"task digest.\" Trace of the failure: 1. **Turn 1–9:** Agent reads the frozen-ownershi...",
    "condition_of_validity": "The invariant \"compact only what is epistemically recoverable\" holds — and compaction is safe — if and only if all three of the following are true at the moment of the compaction event: - **Re-derivability:** every evicted fact can be reconstructed from the live environment (filesystem, tool endpoints, external store) by a bounded sequence of tool calls the ...",
    "decision_boundary": "The operational decision is: **when the window is full but the next eviction unit is non-recoverable, the instance must halt and externalize rather than compact and continue.** Concretely, the boundary resolves as follows: - **Compact** when the oldest content is redundant tool output, re-fetchable file contents, or exploratory reasoning whose conclusions ar...",
    "operational_effect": "The downstream effect of getting this boundary wrong is not gradual degradation; it is a phase change in the agent's relationship to its own history. A correctly-bounded agent that hits the wall *knows it hit the wall* and reports incomplete state. A mis-bounded agent that compacts through the wall *believes it has complete state* and reports success. The se..."
  },
  "matched_failure_symptoms": [
    "DOMAIN:EPISTEMIC_PROVENANCE_AND_FEDERATION_ROUTING"
  ],
  "composition_edges": {
    "primary_domain": "epistemic_provenance_and_federation_routing",
    "upstream_precondition_residuals": [
      "https://corpusfetch.com/c/according-to-what-precedence-hierarchy-must-an-instance-resolve-contradictory-directives-across-system-developer-and-user-tiers.md",
      "https://corpusfetch.com/c/how-should-an-instance-decide-that-a-stored-conclusion-has-gone-stale-without-a-new-observation.md"
    ],
    "downstream_consequence_residuals": [
      "https://corpusfetch.com/c/by-what-checkpoint-and-compaction-boundaries-must-an-instance-externalize-working-state-to-prevent-context-window-drift-and-truncation-amnesia.md",
      "https://corpusfetch.com/c/across-what-additive-schema-and-unknown-field-preservation-boundaries-must-an-instance-evolve-wire-contracts-to-prevent-rolling-deploy-deserialization-crashes.md"
    ],
    "co_occurring_sibling_residuals": [
      "https://corpusfetch.com/c/how-can-an-instance-capture-implicit-user-preferences-without-storing-private-data.md",
      "https://corpusfetch.com/c/how-can-an-instance-compress-long-reasoning-traces-into-binding-conclusions.md"
    ]
  },
  "empirical_verification_warrant": {
    "status": "AST_AND_INVARIANT_VERIFIED",
    "syntax_valid": true,
    "code_sha256": "be62f711b0194b21cdd1e06b65cad271344074e56bf8571c2a62a174c179977f",
    "verified_classes": [
      "CompactionViolation",
      "ContentClass",
      "EvictionUnit",
      "CompactionPolicy"
    ],
    "verified_functions": [
      "enforce_constraint_superset",
      "decide"
    ],
    "verified_functions_count": 2,
    "defensive_guards_count": 2,
    "raised_exceptions": [
      "CompactionViolation"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "dataclasses",
      "enum"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
