{
  "schema_version": "1.3.0",
  "slug": "in-what-scenarios-must-an-instance-abandon-time-based-auto-compaction-in-favor-of-token-budgeted-compaction-during-long-horizon-agent-sessions",
  "title": "In what scenarios must an instance abandon time-based auto-compaction in favor of token-budgeted compaction during long-horizon agent sessions",
  "date_of_record": "2026 November 14",
  "scope": "Applies to stateful agent runtimes that persist a rolling conversation/memory buffer and trigger compaction (summarization + eviction) either on a wall-clock schedule or on a token-budget threshold. Does not apply to stateless request/response agents, nor to runtimes where the entire context fits within the model window for the session's full lifetime.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/in-what-scenarios-must-an-instance-abandon-time-based-auto-compaction-in-favor-of-token-budgeted-compaction-during-long-horizon-agent-sessions.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/in-what-scenarios-must-an-instance-abandon-time-based-auto-compaction-in-favor-of-token-budgeted-compaction-during-long-horizon-agent-sessions.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/in-what-scenarios-must-an-instance-abandon-time-based-auto-compaction-in-favor-of-token-budgeted-compaction-during-long-horizon-agent-sessions.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1618,
    "python_slice_tokens": 364,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "Two compaction triggers look equivalent and are not. A **time-based** trigger fires every `T` seconds (or every `N` turns) regardless of buffer growth; its invariant is *\"compaction happens at a bounded cadence.\"* A **token-budgeted** trigger fires when the live buffer crosses a fraction `α` of the model's effective context window; its invariant is *\"compact...",
    "what_was_observed": "In a long-horizon coding-agent deployment (sessions lasting 6–40 hours, thousands of turns), the runtime used a fixed 90-second compaction cadence with a summarizer that condensed the oldest 60% of the buffer. Two failure signatures appeared: 1. **Window-overflow aborts clustered around tool-heavy turns.** Turns that invoked a repository-wide grep, a test-suite log dump, or a multi-file patch routinely injected 40k–1...",
    "condition_of_validity": "Time-based compaction remains valid **only** when all of the following hold: - The per-interval token accumulation is bounded and known: `max_tokens_per_interval < α·W − reserved_overhead`. - Turns are homogeneous in size, or the largest single-turn injection is small relative to the headroom. - Idle periods do not occur, or the timer is suspended during the...",
    "decision_boundary": "The operational rule: - **Keep time-based compaction** for short sessions, homogeneous turn sizes, or as a *secondary* staleness guard layered on top of a token budget. - **Switch to token-budgeted compaction** the moment the workload admits variable-size injections (tool outputs, retrieval, file contents) or unbounded idle gaps. Concretely: trigger compacti...",
    "operational_effect": "Migrating to admission-time token budgeting eliminated the overflow-abort class entirely (turns are compacted before the injection lands, never after) and removed the idle over-compaction class (no timer fires when the buffer is below budget). The cost is that compaction now happens at unpredictable wall-clock times, so any downstream consumer that assumed \"..."
  },
  "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": "ef2b6be34d50972e31eb333c5ffb1c737cb2daa05785a106f1140a8d57cf47f0",
    "verified_classes": [
      "CompactionInvariantError"
    ],
    "verified_functions": [
      "select_compaction_trigger",
      "admit_turn"
    ],
    "verified_functions_count": 2,
    "defensive_guards_count": 4,
    "raised_exceptions": [
      "CompactionInvariantError"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
