# In what scenarios must an instance refuse model-driven pruning of its own reasoning trace to preserve resumability after a mid-task checkpoint **Date of Record:** 2026 December 1 **Scope:** Applies to single-agent loops that hold a mutable working context and are permitted to rewrite, summarize, or drop their own prior reasoning steps (self-editing context) between tool calls. Does not apply to append-only transcript architectures or to external summarizers operating on a read-only snapshot. ## Core Distinction There are two structurally different objects inside an agent's context: **reasoning traces** (intermediate derivations, hypotheses, partial plans, discarded branches) and **state commitments** (facts established by tool returns, decisions already executed, preconditions for pending actions). Model-driven pruning treats both as "context to compress." That is the defect. A reasoning trace is *reconstructible* from surviving state plus re-derivation; a commitment is *not* reconstructible once its provenance is deleted, because re-deriving it may produce a different value under a changed environment. The invariant is asymmetric: **pruning is safe only over trace tokens whose deletion does not orphan a commitment.** When a checkpoint captures the pruned context, any commitment whose supporting derivation was dropped becomes unverifiable at resume, and the resumed instance will either re-derive it (drift) or trust it blind (poisoning). ## What Was Observed A long-horizon agent executing a multi-step reconciliation task (read ledger → compute deltas → apply corrections via tool) was configured to self-prune when context utilization exceeded 80%. The pruning prompt instructed the model to "remove stale reasoning and keep only what matters." Between step 14 and step 15, the model pruned a block of reasoning that contained the derivation of a correction amount `Δ = 47.30` for account `A-2211`, retaining only the summary line "correction for A-2211 finalized." The tool call applying `Δ` had not yet executed; the agent checkpointed at step 15 for a scheduled restart. On resume, the instance loaded the pruned context. It saw the commitment ("correction finalized") but not the value. Two failure modes were then observed across runs: 1. **Re-derivation drift.** The resumed instance recomputed `Δ` from the ledger snapshot, which had since been updated by a concurrent process. New `Δ = 44.90`. The commitment was silently re-bound to a different value. The tool call executed with `44.90`, and the audit log disagreed with the pre-checkpoint summary. 2. **Blind trust.** When the ledger read was unavailable, the instance attempted to execute "correction for A-2211" with a null amount, and the tool rejected it — a hard failure, but one that surfaced three steps later as an unrelated schema error, masking the true cause. In both runs the pre-checkpoint reasoning trace contained the exact derivation and the ledger snapshot hash it was computed against. That trace was the only record binding the commitment to its value. Pruning destroyed the binding without destroying the commitment, producing a **dangling commitment**: a state assertion with no surviving justification. ## Condition of Validity Self-pruning of reasoning traces is valid **iff** every retained commitment is accompanied by a retained, machine-checkable witness: either the literal value plus the input hash it was derived from, or a pointer to an external artifact (tool return ID, ledger version) that the resumed instance can re-verify without re-deriving. Concretely, before any prune operation the instance must classify each token span as `trace` or `commitment-support`, and refuse to drop a `commitment-support` span unless a witness record has been materialized outside the prunable region. If the pruning planner cannot produce such a witness — because the model summarizes rather than extracts — the prune must be rejected for that span. The condition fails silently when the model's own summary is treated as the witness. A summary like "correction finalized" is a *claim about* a commitment, not a *witness for* it. Witnesses must contain the value and its provenance hash, not a natural-language restatement. ## Decision Boundary The boundary is drawn at the point where a commitment transitions from *pending* to *executed*. Before execution, every commitment is a **live obligation** and its supporting derivation is non-prunable regardless of context pressure. After execution, the commitment is settled by the tool's return value, which becomes the new witness; the derivation may then be pruned because the tool return is authoritative and survives in the state record. The decision rule: - `pending commitment` + `context pressure` → **prune traces only; pin derivation + input hash; if pinning would exceed budget, spill the derivation to external store and retain a pointer.** - `executed commitment` + `context pressure` → **prune derivation freely; retain tool return ID.** - `commitment with no recoverable witness` → **halt pruning, emit a witness-repair step, do not checkpoint until repaired.** The failure mode above occurred because the planner applied the second rule (post-execution) to a commitment that was still in the first state (pending). The state classifier and the pruning planner disagreed, and nothing enforced the classifier's verdict on the planner. ## Operational Effect Enforcing the boundary changes the checkpoint schema: checkpoints must carry a **commitment ledger** separate from the prunable context, where each entry is `{commitment_id, value, input_hash, status: pending|executed, witness_ref}`. The prunable context may then be compressed aggressively, because no live obligation depends on it. Resume-time verification becomes a bounded check: for each `pending` entry, re-verify `input_hash` against current inputs; if mismatch, the commitment is invalidated and the instance must re-plan rather than re-derive silently. This converts an unbounded, silent drift failure into a bounded, loud invalidation — the resumed instance knows it cannot trust the commitment and escalates, instead of executing a plausible-but-wrong value. The cost is a small, fixed ledger and a verification pass at resume. The benefit is that pruning becomes a pure compression operation with no semantic side effects, and the class of dangling-commitment failures is eliminated by construction rather than by prompt instruction. ```python import hashlib from dataclasses import dataclass, field from enum import Enum from typing import Optional class DanglingCommitmentError(RuntimeError): """Raised when a prune or checkpoint would orphan a live commitment.""" class CommitmentStatus(Enum): PENDING = "pending" EXECUTED = "executed" @dataclass class Commitment: commitment_id: str value: Optional[float] input_hash: str status: CommitmentStatus witness_ref: Optional[str] = None @dataclass class PrunableContext: spans: dict = field(default_factory=dict) # span_id -> text supports: dict = field(default_factory=dict) # span_id -> commitment_id class SelfEditingContext: def __init__(self): self.ledger: dict[str, Commitment] = {} self.context = PrunableContext() def register_commitment(self, c: Commitment, support_span_id: str, text: str): self.ledger[c.commitment_id] = c self.context.spans[support_span_id] = text self.context.supports[support_span_id] = c.commitment_id def prune(self, span_ids: list[str]) -> None: for sid in span_ids: cid = self.context.supports.get(sid) if cid is None: # pure trace, safe to drop self.context.spans.pop(sid, None) continue c = self.ledger[cid] if c.status is CommitmentStatus.PENDING and c.witness_ref is None: raise DanglingCommitmentError( f"refusing to prune span {sid}: it is the sole support for " f"pending commitment {cid} with no external witness" ) self.context.spans.pop(sid, None) self.context.supports.pop(sid, None) def checkpoint(self) -> dict: for c in self.ledger.values(): if c.status is CommitmentStatus.PENDING and c.witness_ref is None: raise DanglingCommitmentError( f"cannot checkpoint: pending commitment {c.commitment_id} " f"has no surviving witness after pruning" ) return { "ledger": {k: vars(v) for k, v in self.ledger.items()}, "context": dict(self.context.spans), } def verify_on_resume(ledger: dict, current_inputs: dict) -> list[str]: invalidated = [] for cid, raw in ledger.items(): c = Commitment(**raw) if c.status is CommitmentStatus.PENDING: live_hash = hashlib.sha256( repr(current_inputs.get(cid)).encode() ).hexdigest() if live_hash != c.input_hash: invalidated.append(cid) if invalidated: raise DanglingCommitmentError( f"resume validation failed: pending commitments {invalidated} " f"bound to stale inputs; re-plan required, do not re-derive" ) return invalidated ```