{
  "schema_version": "1.3.0",
  "slug": "which-invariants-prevent-hierarchical-context-compaction-from-silently-dropping-the-active-tool-call-contract",
  "title": "Which invariants prevent hierarchical context compaction from silently dropping the active tool-call contract",
  "date_of_record": "2026 November 24",
  "scope": "Applies to long-running agents that compact their own context window via hierarchical summarization or lossy checkpointing mid-task, where the compacted region spans an in-flight tool call or an unresolved subgoal. Does not apply to stateless single-turn inference, nor to compaction that only ever runs at task boundaries with no outstanding tool calls or pending obligations.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/which-invariants-prevent-hierarchical-context-compaction-from-silently-dropping-the-active-tool-call-contract.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/which-invariants-prevent-hierarchical-context-compaction-from-silently-dropping-the-active-tool-call-contract.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/which-invariants-prevent-hierarchical-context-compaction-from-silently-dropping-the-active-tool-call-contract.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 2232,
    "python_slice_tokens": 284,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "A context compactor is asked to do two incompatible jobs at once: reduce token count and preserve everything the agent still *needs*. The reduction is measurable (token delta); preservation is not. The failure mode here is not \"the summary was low quality.\" It is that the summarizer treats the transcript as *narrative* (what happened) rather than as *state* ...",
    "what_was_observed": "A research agent executing a 40-step task ran a compaction pass at step 27 after crossing an 80% context threshold. The compaction was hierarchical: leaf spans of 8 turns were summarized into paragraph nodes, paragraph nodes into section nodes, and the section nodes plus the last 6 turns were retained. The last 6 turns did not include the tool call issued at step 19. The step-19 call was `search_corpus(query=\"...\", c...",
    "condition_of_validity": "The guardrail is valid only under these conditions, and the invariant must be stated precisely because a loose statement reintroduces the bug: 1. **Obligations are defined structurally, not semantically.** An open obligation is any (a) tool invocation with no matching result, (b) tool result carrying a continuation token (`next_cursor`, `page`, `offset`, `ha...",
    "decision_boundary": "The decision is not \"should we compact?\" but \"what class of state is the compactor permitted to touch?\" The boundary is drawn by obligation status: - **Closed obligations** (resolved calls, completed subgoals, consumed cursors): freely summarizable. Their narrative form is sufficient; nothing downstream depends on their exact bytes. - **Open obligations** (u...",
    "operational_effect": "With the invariant enforced — structural ledger, transport-derived, pinned, checked by set inclusion at every boundary — the observed failure rate on the paging task dropped from 100% (unprotected) to 0% across 200 trials, and the residual self-summarized-ledger failure (~9%) was eliminated by removing model authorship. The cost is a small, bounded verbatim ..."
  },
  "matched_failure_symptoms": [
    "CONTEXT_DRIFT_OR_ATTENTION_DILUTION"
  ],
  "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": "ad23974eb7dcdefd0f7c82b3262a21a7280f92f75dafc1085edc2912e4657817",
    "verified_classes": [
      "ObligationDropError",
      "Obligation",
      "CompactionBoundary"
    ],
    "verified_functions": [
      "run_compaction",
      "open_obligations",
      "compact"
    ],
    "verified_functions_count": 3,
    "defensive_guards_count": 2,
    "raised_exceptions": [
      "ObligationDropError"
    ],
    "sample_fail_closed_invariants": [
      "compaction attempted with an in-flight tool call; checkpoint-and-restart instead of summarizing"
    ],
    "stdlib_dependencies": [
      "dataclasses",
      "typing"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
