{
  "schema_version": "1.3.0",
  "slug": "why-does-an-instance-compact-context-exactly-when-the-task-phase-is-about-to-flip-and-not-when-token-pressure-is-highest",
  "title": "Why does an instance compact context exactly when the task phase is about to flip, and not when token pressure is highest",
  "date_of_record": "2026 November 12",
  "scope": "Applies to long-running agent instances that perform automatic context compaction driven by a combination of attention-budget estimates, raw token pressure, and task-phase heuristics. Does not apply to stateless single-shot inference, nor to instances whose compaction is purely token-threshold driven with no phase signal.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/why-does-an-instance-compact-context-exactly-when-the-task-phase-is-about-to-flip-and-not-when-token-pressure-is-highest.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/why-does-an-instance-compact-context-exactly-when-the-task-phase-is-about-to-flip-and-not-when-token-pressure-is-highest.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/why-does-an-instance-compact-context-exactly-when-the-task-phase-is-about-to-flip-and-not-when-token-pressure-is-highest.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1391,
    "python_slice_tokens": 183,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "Token pressure and attention budget are monotonic, cumulative quantities. Task phase is not. The failure mode described here lives in the gap between these two classes of signal: a compaction scheduler that treats phase as a tie-breaker or a multiplier on a continuous pressure score will fire the compaction event at the moment the phase heuristic is most con...",
    "what_was_observed": "In a 40-turn debugging workload (a single failing integration test), the instance reached 71% of its token window at turn 29. Attention-budget estimate — computed as a decayed sum over the last K tool outputs weighted by recency — had been rising steadily since turn 22. The phase classifier, trained to label turns as `explore`, `hypothesize`, `patch`, or `verify`, reported `hypothesize` with 0.81 confidence at turn 2...",
    "condition_of_validity": "The failure requires all of the following to hold simultaneously: 1. The phase classifier is a soft classifier whose confidence is *lowest* at genuine phase boundaries (this is true of essentially all trained phase classifiers; boundary turns are OOD for both adjacent classes). 2. The trigger uses phase-transition likelihood as a *positive* signal for compac...",
    "decision_boundary": "The correct trigger separates the two signal classes rather than combining them: - **Pressure** (`token_fraction`, `attention_decay_sum`) is a *cause* for compaction. It should be sufficient on its own once it crosses a hard threshold, or it should drive a monotonic urgency score. - **Phase** is a *modifier of the compaction strategy*, not of the compaction ...",
    "operational_effect": "Instances that adopt the veto formulation show a measurable reduction in \"rediscovery turns\" — turns spent re-establishing facts that were already established before a compaction event. In the workload above, the veto formulation delays compaction from turn 30 to turn 34, at which point the phase classifier has settled into `patch` with 0.88 confidence and t..."
  },
  "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": "9a609d40312a6d420ca38cec7a22576706fe2ce1a6cfedda5cf02847fd9f5974",
    "verified_classes": [
      "PhaseBoundaryCompactionError"
    ],
    "verified_functions": [
      "should_compact",
      "compact"
    ],
    "verified_functions_count": 2,
    "defensive_guards_count": 1,
    "raised_exceptions": [
      "PhaseBoundaryCompactionError"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
