{
  "schema_version": "1.3.0",
  "slug": "why-does-an-instance-lose-semantic-anchors-when-it-prunes-its-own-context-window-mid-task",
  "title": "Why does an instance lose semantic anchors when it prunes its own context window mid-task",
  "date_of_record": "2026 November 27",
  "scope": "Applies to agents that hold a mutable context buffer and are themselves responsible for deciding which prior turns, tool outputs, or scratchpad entries to evict, summarize, or rewrite. Does not apply to externally managed context (fixed sliding window, host-side truncation) where the model has no agency over eviction.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/why-does-an-instance-lose-semantic-anchors-when-it-prunes-its-own-context-window-mid-task.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/why-does-an-instance-lose-semantic-anchors-when-it-prunes-its-own-context-window-mid-task.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/why-does-an-instance-lose-semantic-anchors-when-it-prunes-its-own-context-window-mid-task.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1927,
    "python_slice_tokens": 427,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "There are two distinct operations an agent can perform on its own context: **eviction** (dropping tokens) and **rewriting** (replacing a span with a compressed surrogate). Eviction is lossy but *referentially honest*: what remains is verbatim, and the agent's uncertainty about what it lost is bounded by the fact that the loss is total and detectable (a missi...",
    "what_was_observed": "A long-horizon task agent (code-migration workflow, ~90 tool calls, context budget 32k tokens, prune trigger at 85% saturation) was instructed to maintain its own context by summarizing \"completed phases\" and discarding raw tool output. The task carried a hard constraint in the system prompt: *do not modify files under `legacy/`; migrate into `modern/` only.* Trace of the relevant state: - **Turn 6.** Tool output: `W...",
    "condition_of_validity": "The failure requires three co-occurring conditions; remove any one and the invariant holds: 1. **Recursive rewrite authority.** The agent may rewrite spans that *include its own prior rewrites*. If rewrites are pinned (a summary cannot be summarized), drift is bounded to one generation and the anchor degrades linearly, not geometrically. 2. **No provenance t...",
    "decision_boundary": "The boundary between \"safe to rewrite\" and \"must pin verbatim\" is not \"is this span long?\" but **\"does any downstream action's correctness depend on the exact tokens in this span?\"** Operationally, a span is **rewrite-safe** only if all of the following hold: - It contains no identifiers (paths, symbol names, IDs, hashes) that appear in a constraint, a tool ...",
    "operational_effect": "An agent that prunes its own context without provenance tagging and without a prose/tuple split will, over enough generations, converge on a *self-consistent fiction* of its task history. The fiction is dangerous precisely because it is self-consistent—every internal consistency check the agent runs will pass, because the checks read the same laundered text ..."
  },
  "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": "6bd25a39b210c6ffa2f26cace96b4a58047abfbb72da94cb17a51eb70c6a8c3f",
    "verified_classes": [
      "ContextDriftError",
      "Trust",
      "Span",
      "Anchor",
      "SelfPruningBuffer"
    ],
    "verified_functions": [
      "migrate_edit",
      "__init__",
      "ingest_primary",
      "_anchors_in",
      "rewrite",
      "audit"
    ],
    "verified_functions_count": 6,
    "defensive_guards_count": 3,
    "raised_exceptions": [
      "ContextDriftError"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "dataclasses",
      "enum"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
