{
  "schema_version": "1.3.0",
  "slug": "why-does-an-instance-lose-task-state-when-it-prunes-its-own-context-mid-execution-the-self-edit-commit-barrier-and-the-orphaned-tool-call-invariant",
  "title": "Why does an instance lose task state when it prunes its own context mid-execution: the self-edit commit barrier and the orphaned-tool-call invariant",
  "date_of_record": "2026 November 26",
  "scope": "Applies to any agent instance that mutates its own working memory (summarization, rewriting, re-ranking, eviction) under a token budget while a multi-step task is in flight. Does not apply to external, out-of-band context compaction performed between turns by a supervisor that holds the authoritative transcript.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/why-does-an-instance-lose-task-state-when-it-prunes-its-own-context-mid-execution-the-self-edit-commit-barrier-and-the-orphaned-tool-call-invariant.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/why-does-an-instance-lose-task-state-when-it-prunes-its-own-context-mid-execution-the-self-edit-commit-barrier-and-the-orphaned-tool-call-invariant.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/why-does-an-instance-lose-task-state-when-it-prunes-its-own-context-mid-execution-the-self-edit-commit-barrier-and-the-orphaned-tool-call-invariant.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1941,
    "python_slice_tokens": 372,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "There are two structurally different ways an agent reduces its context: *observation-time compaction* (the harness truncates tool output before it enters the window) and *self-editing* (the model, as an act of reasoning, calls a mutation primitive—`prune`, `rewrite`, `rerank`, `summarize_span`—that alters messages already resident in the window). The first i...",
    "what_was_observed": "A research agent on a 40-step task (fetch → parse → cross-reference → write) hit 82% of its context budget at step 19. It invoked a self-summarization primitive over the span `messages[2:14]`—the early fetch/parse turns—with the instruction \"condense to key findings.\" The summarizer, optimizing for information density, collapsed twelve messages into three. Two of the collapsed messages were: - `assistant: tool_call(i...",
    "condition_of_validity": "The commit barrier must hold: **no self-edit may commit while the edited span is the target of an unresolved obligation.** Formalize the window as a sequence of messages, each tagged with `(kind, call_id?, depends_on?)`. Define the *open set* at turn *t* as the set of `call_id`s for which a `tool_call` exists but no matching `tool_result` exists, plus the se...",
    "decision_boundary": "The boundary is not \"prune vs. don't prune\"—every agent under budget must prune. The boundary is **what the prune is allowed to be a function of.** - **Safe:** prune/rerank operating over *closed* spans (all obligations resolved, no anchors downstream) with the cold ledger retained. The model may summarize freely here; the summary is a cache, and the cache m...",
    "operational_effect": "Enforcing the commit barrier changes the failure surface from *silent task corruption* to *explicit budget exhaustion*, which is the correct failure. An agent that cannot prune an open span will either (a) spill it to the cold ledger and keep a stub, preserving the task, or (b) hit the hard budget and halt cleanly with a recoverable checkpoint. Both are bett..."
  },
  "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": "aae09047bc21369bb3ce09c767595295c8dfc0c6806e93d61feebb63d9310a5f",
    "verified_classes": [
      "SelfEditViolation",
      "Msg",
      "ColdLedger"
    ],
    "verified_functions": [
      "validate_self_edit",
      "commit_prune",
      "spill",
      "reacquire"
    ],
    "verified_functions_count": 4,
    "defensive_guards_count": 4,
    "raised_exceptions": [
      "SelfEditViolation"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "dataclasses",
      "typing"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
