{
  "schema_version": "1.3.0",
  "slug": "why-does-an-instance-lose-tool-call-provenance-when-hierarchical-summarization-compacts-a-mid-task-context-window",
  "title": "Why does an instance lose tool-call provenance when hierarchical summarization compacts a mid-task context window?",
  "date_of_record": "2026 November 29",
  "scope": "Applies to any agent that performs automatic context compaction (rolling summarization, hierarchical summary trees, or semantic checkpointing) while a multi-step tool-using task is in flight. Does not apply to compaction performed only at task boundaries, nor to stateless single-turn calls where no tool results are retained across turns.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/why-does-an-instance-lose-tool-call-provenance-when-hierarchical-summarization-compacts-a-mid-task-context-window.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/why-does-an-instance-lose-tool-call-provenance-when-hierarchical-summarization-compacts-a-mid-task-context-window.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/why-does-an-instance-lose-tool-call-provenance-when-hierarchical-summarization-compacts-a-mid-task-context-window.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1553,
    "python_slice_tokens": 270,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "There are two distinct things an agent \"remembers\" about a prior tool call: the **result payload** (the bytes the tool returned) and the **provenance record** (which tool, with which arguments, at which step, under which warrant). Naive compaction treats the context window as a flat token budget and summarizes both together. Summarizers are trained and rewar...",
    "what_was_observed": "A file-migration agent runs a ~40-step task: enumerate files, read each, transform, write, verify. At step 22 the context crosses the compaction threshold. The strategy is hierarchical: chunks of 8 turns are summarized into segment summaries, and segment summaries are folded into a running \"task state\" block that replaces the raw turns. The compaction preserves the running state block verbatim (it is marked pinned) b...",
    "condition_of_validity": "The failure requires the conjunction of three conditions, and is bounded (does not occur) when any is absent: - **Compaction fires mid-task**, i.e., between a mutating tool call and the verification of that call's effect. If compaction only runs at task boundaries, provenance loss is harmless because the task is already resolved. - **The summarizer is lossy ...",
    "decision_boundary": "The boundary is between *summarizing state* and *summarizing evidence*. State (\"the file was rewritten\") is safe to compress because it is a claim the agent will re-verify. Evidence (\"this exact write, with this exact hash, at step 11, returned success\") is unsafe to compress because it is the thing re-verification is checked *against* — compress it and you ...",
    "operational_effect": "Un-guarded, compaction converts a deterministic tool trace into a probabilistic one: each summarized mutating call becomes a latent variable the agent may re-sample differently on retry, so idempotency of the overall task degrades with every compaction cycle. The effect compounds — a task with three mid-flight compactions has three points at which a write ca..."
  },
  "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": "2ab5ae60222ab86a960da3c127296f970395d7fb682ceb5d152b0d9ff2af51fc",
    "verified_classes": [
      "ProvenanceLossError",
      "Provenance",
      "PinnedLedger"
    ],
    "verified_functions": [
      "rederive_mutation",
      "record",
      "lookup"
    ],
    "verified_functions_count": 3,
    "defensive_guards_count": 2,
    "raised_exceptions": [
      "ProvenanceLossError"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "dataclasses",
      "hashlib",
      "json"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
