{
  "schema_version": "1.3.0",
  "slug": "which-invariants-prevent-lossy-context-compaction-from-silently-severing-an-agent-s-tool-call-ledger",
  "title": "Which invariants prevent lossy context compaction from silently severing an agent's tool-call ledger",
  "date_of_record": "2026 December 1",
  "scope": "Applies to long-running single-agent loops that persist conversational state and trigger automatic context compaction (summarize-and-evict) when the token budget crosses a threshold, with retrieval-backed reconstruction of evicted spans. Does not apply to stateless per-request inference or to architectures that never evict from the live context.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/which-invariants-prevent-lossy-context-compaction-from-silently-severing-an-agent-s-tool-call-ledger.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/which-invariants-prevent-lossy-context-compaction-from-silently-severing-an-agent-s-tool-call-ledger.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/which-invariants-prevent-lossy-context-compaction-from-silently-severing-an-agent-s-tool-call-ledger.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 2234,
    "python_slice_tokens": 364,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "Compaction is usually framed as a *compression* problem: how much of the old context can be summarized away while keeping task-relevant facts. That framing hides the actual failure. The dangerous boundary is not information loss per se — it is **referential loss across the tool-call ledger**. A conversation is not a bag of facts; it is a partially ordered se...",
    "what_was_observed": "A research agent running a multi-hour task accumulated ~180k tokens of history. At the 75% threshold, the compaction policy summarized the oldest 60% of the span into a ~2k-token digest and evicted the rest, leaving retrieval handles. The digest read, in part: > \"Earlier, the agent queried the customer-orders API for account A-4471 and confirmed the refund was already issued. It then updated the ticket status.\" Three...",
    "condition_of_validity": "The guardrail only holds under a stated condition, and it is worth being explicit because the condition is frequently violated: **A compacted span is safe to summarize lossily only if every artifact it references is (a) re-derivable from the summary without the original, or (b) explicitly tagged in the summary with a retrieval key that the model is instructe...",
    "decision_boundary": "The operational decision is where to place the compaction trigger and what the summarizer is permitted to elide. Two boundaries must be distinguished: - **The token trigger** (when to compact) is a *capacity* decision. Setting it too high risks mid-step truncation; too low wastes budget on premature summarization and multiplies the number of lossy transforms...",
    "operational_effect": "When the invariant holds, compaction becomes a genuine capacity tool: long tasks survive, and the model retains a dereferenceable index into its own history rather than a lossy narrative of it. When it is violated, the failure is *silent and delayed* — the summary reads correctly, the model proceeds confidently, and the divergence only surfaces when a later ..."
  },
  "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": "d171071b32234de01377f941a2bf8fcd70ac975b89aa3ebffae1715ce0e6330f",
    "verified_classes": [
      "CompactionLedgerViolation",
      "ToolCall",
      "Span"
    ],
    "verified_functions": [
      "summarize_span",
      "compact"
    ],
    "verified_functions_count": 2,
    "defensive_guards_count": 4,
    "raised_exceptions": [
      "CompactionLedgerViolation"
    ],
    "sample_fail_closed_invariants": [
      "summary reorders effectful calls; ordering constraints lost"
    ],
    "stdlib_dependencies": [
      "dataclasses",
      "typing"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
