{
  "schema_version": "1.3.0",
  "slug": "how-does-an-instance-detect-that-its-own-context-rewriting-policy-has-silently-invalidated-a-mid-execution-tool-call-contract",
  "title": "How does an instance detect that its own context-rewriting policy has silently invalidated a mid-execution tool-call contract",
  "date_of_record": "2026 December 1",
  "scope": "Applies to any agent that mutates its own context window (summarize-and-drop, model-driven pruning, in-place rewrite of prior turns) while a multi-step tool-call sequence is in flight. Does not apply to append-only contexts or to systems where context mutation is gated by an external, non-LLM controller that preserves a canonical transcript.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/how-does-an-instance-detect-that-its-own-context-rewriting-policy-has-silently-invalidated-a-mid-execution-tool-call-contract.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/how-does-an-instance-detect-that-its-own-context-rewriting-policy-has-silently-invalidated-a-mid-execution-tool-call-contract.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/how-does-an-instance-detect-that-its-own-context-rewriting-policy-has-silently-invalidated-a-mid-execution-tool-call-contract.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1942,
    "python_slice_tokens": 330,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The failure we are isolating is not context-window saturation. Saturation is a capacity event: the window fills, the agent is forced to evict, and the eviction is *visible* because it happens at a boundary the runtime can log. The failure here is subtler: a **self-editing rewrite that preserves syntactic coherence while destroying the semantic preconditions ...",
    "what_was_observed": "A three-tool orchestration: `resolve_entity` → `fetch_orders(entity_id)` → `summarize(orders)`. The middle call returns a large payload (≈40k tokens). Between the `fetch_orders` dispatch and its result, the agent's rewrite policy fires because the projected window exceeded budget. The rewrite prompt is generic: \"Compress earlier turns, preserving decisions and open questions.\" The model compresses the dispatch turn i...",
    "condition_of_validity": "The guardrail is a **frame-pinning invariant**: a rewrite may not modify, paraphrase, or reorder any span that belongs to an open tool-call frame, and the rewrite must emit a machine-checkable manifest of what it touched. Concretely: - Every tool call opens a frame with a stable `call_id`; the frame closes only when a result is merged *and acknowledged* by t...",
    "decision_boundary": "The decision boundary is: **does the rewrite policy have read access to the frame ledger, or only to the rendered transcript?** - If the pruner sees only the transcript, it is structurally incapable of honoring frame boundaries, because frames are a runtime concept the text does not encode. Any such policy must be treated as *unsafe for open frames* and gate...",
    "operational_effect": "The observable effect is **silent result-orphaning**: tool results return, are paid for in latency and tokens, and are then discarded or misfolded because their frame was rewritten out of existence. Downstream, this manifests as summarization that omits fetched data, re-fetches that double cost and drift arguments, and — in the worst case — merges that key o..."
  },
  "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": "09237dec97507f652c7b3f428bf79952537ce22202df73be820b8fd9b88a2348",
    "verified_classes": [
      "OpenFrameOrphaned",
      "ToolFrame",
      "FrameLedger"
    ],
    "verified_functions": [
      "verify_rewrite_preconditions",
      "apply_model_rewrite",
      "open_frame",
      "close_frame",
      "open_ids"
    ],
    "verified_functions_count": 5,
    "defensive_guards_count": 3,
    "raised_exceptions": [
      "OpenFrameOrphaned"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "dataclasses",
      "typing"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
