{
  "schema_version": "1.3.0",
  "slug": "why-does-an-instance-rewrite-the-same-context-segment-twice-and-still-lose-the-fact-it-was-trying-to-preserve",
  "title": "Why does an instance rewrite the same context segment twice and still lose the fact it was trying to preserve?",
  "date_of_record": "2026 November 21",
  "scope": "Applies to single-agent and multi-agent systems where the LLM itself is granted a `rewrite_context`/`prune_context` tool and autonomously decides which segments of its own working memory to compress, summarize, or evict. Does not apply to externally scheduled, deterministic context compaction (e.g., fixed token-count truncation) or to retrieval-only architectures where the model cannot mutate its own state.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/why-does-an-instance-rewrite-the-same-context-segment-twice-and-still-lose-the-fact-it-was-trying-to-preserve.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/why-does-an-instance-rewrite-the-same-context-segment-twice-and-still-lose-the-fact-it-was-trying-to-preserve.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/why-does-an-instance-rewrite-the-same-context-segment-twice-and-still-lose-the-fact-it-was-trying-to-preserve.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1625,
    "python_slice_tokens": 264,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The failure is not \"the model forgot.\" It is **idempotence collapse under self-reference**: a model-driven pruning policy applied to a context window that already contains the outputs of a prior pruning pass produces a *non-idempotent* rewrite. The second pass treats the first pass's summary as a first-class factual segment rather than as a lossy derivative,...",
    "what_was_observed": "Trigger condition: a long-running agent (≈40 tool-call turns) hits a context-budget policy that fires at 85% of the window. The model is handed a `prune_context(targets=[...], instruction=\"compress these segments, keep decisions and identifiers\")` tool. On the first fire, it compresses turns 1–18 into a ~400-token block. On the second fire (turn ~60), the *first summary block itself* is now inside the candidate targe...",
    "condition_of_validity": "The failure is bounded (and the guardrail is necessary) precisely when all of the following hold: - The model has write access to its own context (self-editing), **and** - Prior pruning outputs remain in the window and are eligible for re-pruning, **and** - The pruning instruction is stateless — it does not carry forward the set of facts/identifiers that ear...",
    "decision_boundary": "The boundary is between **compression as lossy projection** and **compression as a generative act**. Below the boundary, the model is a faithful compressor: it removes redundancy and preserves entailments. Above the boundary — once the input is itself a lossy projection — the model is no longer compressing; it is *re-deriving* content from a degraded source,...",
    "operational_effect": "The practical consequence is that self-editing context windows require a **write-ahead fact log with monotonic retention**, not a stateless summarizer. Concretely: - Every pruning pass emits a ledger delta; the ledger is append-only and never re-summarized. - Pruning targets exclude any segment tagged as a ledger derivative. - A post-prune verifier checks th..."
  },
  "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": "e95eeacb843f18237492b5c03d430bdfaa40ab06591d76502d7f91cfc8b57b56",
    "verified_classes": [
      "ContextPruneInvariantError"
    ],
    "verified_functions": [
      "apply_self_prune"
    ],
    "verified_functions_count": 1,
    "defensive_guards_count": 3,
    "raised_exceptions": [
      "ContextPruneInvariantError"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
