{
  "schema_version": "1.3.0",
  "slug": "what-happens-when-an-instance-compacts-its-own-context-mid-tool-call-and-the-summary-evicts-the-pending-call-ledger",
  "title": "What happens when an instance compacts its own context mid-tool-call and the summary evicts the pending-call ledger",
  "date_of_record": "2026 November 27",
  "scope": "Applies to single-agent LLM instances that self-trigger context compaction (summarize-and-truncate) while one or more tool invocations are in flight or have returned results not yet committed to durable state. Does not apply to compaction performed by an external orchestrator that snapshots the full transcript before truncation, nor to stateless single-shot completions.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/what-happens-when-an-instance-compacts-its-own-context-mid-tool-call-and-the-summary-evicts-the-pending-call-ledger.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/what-happens-when-an-instance-compacts-its-own-context-mid-tool-call-and-the-summary-evicts-the-pending-call-ledger.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/what-happens-when-an-instance-compacts-its-own-context-mid-tool-call-and-the-summary-evicts-the-pending-call-ledger.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1948,
    "python_slice_tokens": 309,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "There are two structurally different things an agent holds in context during a multi-step task: **reasoning state** (the chain of inferences, observations, and intermediate conclusions) and **transactional state** (the ledger of tool calls issued, their arguments, their correlation IDs, and whether their results have been consumed). Compaction policies are a...",
    "what_was_observed": "An agent executing a 40-step data-migration task hit its 85%-of-window compaction threshold at step 27, in the middle of a batch of `apply_patch` tool calls. The compaction routine was a standard map-reduce summarizer: chunk the transcript, summarize each chunk against the standing goal, concatenate. The trigger fired between the *issuance* of call `c-8812` (an `apply_patch` against `schema.sql`) and the *arrival* of...",
    "condition_of_validity": "The invariant that must hold for self-compaction to be safe: > **Compaction may only occur at a quiescent point — a state where no tool call has been issued without its result having been received *and* committed to durable external state, and no result has been received without having been durably recorded.** Formally, let `L` be the pending-call ledger: th...",
    "decision_boundary": "When utilization crosses threshold mid-transaction, the agent has exactly three sound options and several unsound ones. The boundary is drawn by whether the in-flight transaction can be *drained* before compaction: - **Drain (preferred):** Suspend new issuance, allow in-flight calls to return, commit their results and correlation IDs to durable state, *then*...",
    "operational_effect": "The practical consequence is that context compaction is not a memory-hygiene operation but a **transactional checkpoint**, and must be implemented with the same discipline as a database checkpoint: quiesce, externalize, snapshot atomically, re-hydrate, resume. Systems that treat it as text summarization on a utilization timer will, under load, draw the bound..."
  },
  "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": "0496fbeb1615f2d21f0116354e7cd94163b12e15e762c5d1e5b0861b041b7ae7",
    "verified_classes": [
      "CompactionViolation",
      "CallStatus",
      "LedgerEntry",
      "PendingCallLedger"
    ],
    "verified_functions": [
      "maybe_compact",
      "issue",
      "returned",
      "consume",
      "non_quiescent"
    ],
    "verified_functions_count": 5,
    "defensive_guards_count": 1,
    "raised_exceptions": [
      "CompactionViolation"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "dataclasses",
      "enum",
      "typing"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
