{
  "schema_version": "1.3.0",
  "slug": "why-does-an-instance-lose-tool-call-provenance-when-compaction-summarizes-a-transcript-mid-tool-sequence-instead-of-at-a-turn-boundary",
  "title": "Why does an instance lose tool-call provenance when compaction summarizes a transcript mid-tool-sequence instead of at a turn boundary",
  "date_of_record": "2026 December 1",
  "scope": "Applies to long-horizon agents that auto-compact their own transcript (summarize-and-replace, sliding-window-plus-digest, or hierarchical rollup) while a multi-step tool sequence is in flight. Does not apply to compaction triggered only at explicit turn boundaries after all tool results have been consumed, nor to stateless single-shot invocations.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/why-does-an-instance-lose-tool-call-provenance-when-compaction-summarizes-a-transcript-mid-tool-sequence-instead-of-at-a-turn-boundary.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/why-does-an-instance-lose-tool-call-provenance-when-compaction-summarizes-a-transcript-mid-tool-sequence-instead-of-at-a-turn-boundary.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/why-does-an-instance-lose-tool-call-provenance-when-compaction-summarizes-a-transcript-mid-tool-sequence-instead-of-at-a-turn-boundary.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1802,
    "python_slice_tokens": 283,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The failure is not \"compaction loses information.\" It is that compaction is *turn-agnostic* while tool execution is *turn-structured*. A transcript is a flat token sequence, but it encodes a hidden tree: an assistant message that issues tool calls, followed by the tool-result messages that satisfy them, followed by the assistant message that consumes those r...",
    "what_was_observed": "A 14-hour migration agent was driving a schema change across ~40 tables. Its compaction policy: when the transcript exceeds 80% of the context window, summarize everything older than the last 6 messages into a rolling digest and prepend that digest. Tool calls were batched 8–12 at a time. The trigger trace on table 27: 1. Assistant emits a batch containing `tool_use` for `apply_migration(table=\"orders_v2\", ddl=...)` ...",
    "condition_of_validity": "This failure requires the conjunction of three conditions, and is bounded (does not occur) if any one is absent: - **Compaction is permitted to fire mid-tool-sequence.** If compaction is gated on \"no outstanding `tool_use` without a matching `tool_result`,\" the window cannot open. Most naive policies gate on token count only, which is the root enabler. - **T...",
    "decision_boundary": "The operational decision is where to place the compaction boundary when the token budget is exhausted mid-sequence. Three options, with distinct failure profiles: - **Compact anyway, summarize pending calls as pending.** Requires the summarizer to emit a machine-readable \"outstanding calls\" list that the resumed agent treats as authoritative state, and requi...",
    "operational_effect": "The effect is not lost tokens — it is a *false completion record* in the agent's semantic memory. The digest is the agent's episodic-to-semantic distillation, and it has recorded an in-flight, failing operation as begun-and-therefore-probably-fine. Every subsequent reasoning step inherits this. Retries become duplicates against partially-mutated state; verif..."
  },
  "matched_failure_symptoms": [
    "CONTEXT_DRIFT_OR_ATTENTION_DILUTION"
  ],
  "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": "3c68c715912ba5a63807fb903f38035a45838d14f480b646cebf27c5e137153b",
    "verified_classes": [
      "CompactionBoundaryViolation",
      "ToolCall",
      "Transcript"
    ],
    "verified_functions": [
      "compact",
      "issue",
      "resolve"
    ],
    "verified_functions_count": 3,
    "defensive_guards_count": 2,
    "raised_exceptions": [
      "CompactionBoundaryViolation"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "dataclasses",
      "typing"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
