{
  "schema_version": "1.3.0",
  "slug": "what-structural-signals-indicate-compaction-triggered-cost-latency-inversion-in-agent-context-windows",
  "title": "What structural signals indicate compaction-triggered cost/latency inversion in agent context windows",
  "date_of_record": "2026 November 24",
  "scope": "Applies to long-running single-agent loops that persist state by summarizing (compacting) their own transcript when a token-budget threshold is crossed. Does not apply to stateless request/response inference, to systems using external retrieval with no in-context history, or to hard truncation strategies that discard rather than summarize.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/what-structural-signals-indicate-compaction-triggered-cost-latency-inversion-in-agent-context-windows.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/what-structural-signals-indicate-compaction-triggered-cost-latency-inversion-in-agent-context-windows.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/what-structural-signals-indicate-compaction-triggered-cost-latency-inversion-in-agent-context-windows.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 2107,
    "python_slice_tokens": 303,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The naive model of compaction treats it as a monotone cost reduction: as the transcript grows, replace the oldest `N` tokens with a summary of `M ≪ N` tokens, restoring headroom so the next turn fits the budget. Under this model the trigger is a single scalar—`tokens_used > threshold`—and compaction is always weakly beneficial because it buys back context at...",
    "what_was_observed": "A tool-using agent ran a 40-step research-and-synthesis task under a hard 128k-token window with a 96k compaction threshold. Instrumentation logged, per compaction event: input tokens summarized (`S_in`), summary output tokens (`S_out`), reclaimed tokens (`R = S_in − S_out`), turns elapsed until the next compaction (`ΔT`), and productive tool-call tokens issued in that interval (`P`). Three regimes appeared as the th...",
    "condition_of_validity": "The inversion is bounded by an inequality. Let `c` be the per-compaction generation cost (`S_in + S_out` at the summarizer's rates), `s` the summary size carried forward per turn, `R` the reclaimed tokens, and `k` the number of productive turns the agent will actually run before its next compaction. Compaction is net-beneficial iff: where `u` is the value-pe...",
    "decision_boundary": "The operational rule that separates safe compaction from inversion: - **Compact** when occupancy crosses threshold **and** the agent's plan has at least `k ≥ 3` subtasks remaining that are expected to consume ≥ `R` tokens each, **and** the region to be compacted is *cold* (no tool call in the last `ΔT` turns referenced it). - **Do not compact** when the thre...",
    "operational_effect": "When the inversion is not caught, three downstream effects compound: 1. **Cost and latency decouple from occupancy.** Dashboards watching peak context utilization show a healthy, low-occupancy agent while billed tokens and per-turn latency climb. The metric that predicts the problem is `P/R` and `ΔT`, not occupancy. 2. **Summary drift accelerates.** Nested s..."
  },
  "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": "20fff3e8393c3cb49da7f81d86a59d0389fd006fd598b5d6c7c5fb08dd1dde50",
    "verified_classes": [
      "CompactionInversionError",
      "CompactionEvent"
    ],
    "verified_functions": [
      "should_compact",
      "check_breaker",
      "reclaimed",
      "generation_cost",
      "productive_ratio"
    ],
    "verified_functions_count": 5,
    "defensive_guards_count": 2,
    "raised_exceptions": [
      "CompactionInversionError"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "dataclasses",
      "math"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
