{
  "schema_version": "1.3.0",
  "slug": "why-does-an-instance-corrupt-its-own-working-memory-when-it-prunes-by-self-assigned-relevance-scores-mid-task",
  "title": "Why does an instance corrupt its own working memory when it prunes by self-assigned relevance scores mid-task",
  "date_of_record": "2026 December 1",
  "scope": "Applies to any agent that, within a single task episode, rewrites or prunes its own context window by assigning relevance scores to existing turns and evicting low scorers. Does not apply to external memory stores (vector DBs, scratchpads) that are written append-only and retrieved by a separate process, nor to fixed-window truncation that never consults the model's own judgment.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/why-does-an-instance-corrupt-its-own-working-memory-when-it-prunes-by-self-assigned-relevance-scores-mid-task.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/why-does-an-instance-corrupt-its-own-working-memory-when-it-prunes-by-self-assigned-relevance-scores-mid-task.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/why-does-an-instance-corrupt-its-own-working-memory-when-it-prunes-by-self-assigned-relevance-scores-mid-task.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 2505,
    "python_slice_tokens": 741,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "There are two structurally different ways an agent can shrink its working memory. The first is **positional eviction**: drop the oldest turns, or drop turns before the last verified checkpoint. This is deterministic, stateless, and cannot be influenced by the content it is removing. The second is **relevance-scored eviction**: the model reads its own context...",
    "what_was_observed": "A 14-step tool-using episode (fetch spec → inspect schema → write handler → run tests → iterate) with a self-pruning step inserted after every third tool call. The pruning prompt asked the model to score each turn 0–10 for \"relevance to completing the current task\" and drop turns scoring ≤3, targeting a 40% token reduction. Trace of the divergence: 1. **Step 3 (post-prune #1):** The turn containing the schema inspect...",
    "condition_of_validity": "The failure requires all four of the following to co-occur. Remove any one and the loop does not close: 1. **Self-scoring:** the eviction decision is made by the same model instance that holds the goal state. An external scorer with a fixed rubric (e.g., \"never evict turns tagged `constraint`\") breaks the circularity. 2. **Goal-relative scoring:** relevance ...",
    "decision_boundary": "The boundary is not \"prune or don't prune.\" It is **whether the scoring function can see the dependency structure it is about to cut.** Operationally: - **Permitted:** eviction scored against a *frozen task specification* captured before the episode began, where the specification is never itself eligible for eviction. The scorer may consult it; it may not re...",
    "operational_effect": "An agent that scores its own context by current-subtask relevance and prunes irreversibly will, over multiple cycles, converge on a self-consistent but unfaithful model of the task—and will do so *confidently*, because the surviving context is coherent by construction. The failure is not a crash; it is a silent substitution of a plausible task for the real o..."
  },
  "matched_failure_symptoms": [
    "OOM_KILL_OR_MEMORY_EXHAUSTION"
  ],
  "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": "2224f607d4d96f40b4ddbc964111dc6b143ec0a26d906bb3c43b0b30e7fb4a9d",
    "verified_classes": [
      "PruneViolation",
      "SegmentType",
      "Segment",
      "WorkingMemory"
    ],
    "verified_functions": [
      "score_and_prune",
      "demonstrate_boundary_failure"
    ],
    "verified_functions_count": 2,
    "defensive_guards_count": 4,
    "raised_exceptions": [
      "PruneViolation"
    ],
    "sample_fail_closed_invariants": [
      "prune pass would empty working memory; no frozen spec or pinned segment remains to anchor the task representation",
      "schema constraint was evicted by relevance score; the agent will now confabulate a repair for the orphaned 413",
      "confabulated repair survived a second prune cycle and now anchors the task model"
    ],
    "stdlib_dependencies": [
      "dataclasses",
      "enum"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
