{
  "schema_version": "1.3.0",
  "slug": "what-structural-signals-indicate-a-compaction-boundary-has-been-crossed-mid-task-rather-than-at-a-phase-transition",
  "title": "What structural signals indicate a compaction boundary has been crossed mid-task rather than at a phase transition",
  "date_of_record": "2026 November 30",
  "scope": "Applies to long-running agent sessions where an automatic compaction policy rewrites the active context when the token counter crosses a budget threshold, and where the policy is also invoked at explicit task-phase transitions. Does not apply to stateless single-turn calls or to manual summarization workflows with a human in the loop.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/what-structural-signals-indicate-a-compaction-boundary-has-been-crossed-mid-task-rather-than-at-a-phase-transition.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/what-structural-signals-indicate-a-compaction-boundary-has-been-crossed-mid-task-rather-than-at-a-phase-transition.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/what-structural-signals-indicate-a-compaction-boundary-has-been-crossed-mid-task-rather-than-at-a-phase-transition.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1532,
    "python_slice_tokens": 180,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "A token-budget-triggered compaction and a task-phase-triggered compaction produce the *same observable artifact*: a shorter context window with a summary block prepended. They are indistinguishable by size, by summary token count, or by the presence of a \"summary\" marker. What separates them is a structural property of the *work in flight* at the moment of f...",
    "what_was_observed": "A planning agent executing a 14-step migration task hit the 80% budget threshold at step 9, inside a `read_file → parse → patch` triple. The compaction policy fired, summarized steps 1–8 into 400 tokens, and dropped the raw tool outputs including the partially-parsed file content from step 9's `read_file`. The agent resumed and re-issued the `read_file` — but the file had been mutated by a concurrent process between ...",
    "condition_of_validity": "The invariant holds only when the following three conditions are all true at the moment of compaction: 1. **Trace-shape check is available.** The policy must have access to the last N messages' structural role (tool-call, tool-result, reasoning, verdict), not just their text. A pure token-count trigger without trace inspection cannot satisfy this invariant. ...",
    "decision_boundary": "The operational rule: **a budget-triggered compaction must not fire if the trace tail is \"open\" — i.e., ends on an unconsumed tool result, an uncommitted reasoning step, or a message containing unresolved references.** In that case the policy must either (a) defer compaction until the trace tail closes naturally (the next reasoning step consumes the tool res...",
    "operational_effect": "Agents that implement the trace-shape check eliminate the class of \"resumed at a valid-looking but wrong point\" failures. The observable effect is a rise in deferred compactions (the counter sits above threshold for a few steps longer) and a corresponding drop in re-issued tool calls and reconciliation-with-nothing failures. The cost is bounded by the maximu..."
  },
  "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": "ce2976d7b90397511951a26773d062236b8ec7a80adc5ce4972c64a508c8bf6b",
    "verified_classes": [
      "OpenTailCompactionError"
    ],
    "verified_functions": [
      "compact_if_safe",
      "assert_no_orphaned_references"
    ],
    "verified_functions_count": 2,
    "defensive_guards_count": 2,
    "raised_exceptions": [
      "OpenTailCompactionError"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
