# How does an instance detect compaction-triggered loss of a pending tool-call obligation across a context-window boundary? **Date of Record:** 2026 November 27 **Scope:** Applies to long-horizon single-agent runs that manage a finite context window via summarization/eviction ("compaction") triggered by a token-budget policy, where the agent issues tool calls whose results arrive asynchronously and may straddle a compaction boundary. Does not cover stateless single-turn inference or systems where tool-call obligations are persisted in an external durable ledger independent of the transcript. ## Core Distinction The failure is not "the context window filled up." That is expected and handled by compaction. The failure is that **compaction is a lossy transform applied to the transcript, but tool-call obligations are not transcript-local facts—they are pending external commitments whose only durable record was the transcript itself.** When a compaction trigger fires between the emission of a tool call and the ingestion of its result, the summarizer—operating under a "preserve salient reasoning, drop redundant detail" objective—routinely elides the un-answered tool call as noise, because from a pure text-salience perspective an orphaned `tool_call` with no paired `tool_result` looks like a truncated artifact, not an outstanding obligation. The agent then continues reasoning as if the action was never taken, or worse, as if it was completed. The distinction that matters: *compaction preserves narrative coherence, but execution correctness depends on obligation completeness*, and these two objectives diverge precisely at the boundary. ## What Was Observed A research agent running a 240-step task (iterative web retrieval + file synthesis) was configured with a compaction trigger at 78% of an 128k window, a summarization pass that rewrote the oldest 60% of turns into a "running summary," and an async tool transport with a p99 latency of 11 seconds for the retrieval tool. The trigger was evaluated on every token append, including the token append that *emitted* the tool call. Trace of the boundary crossing: 1. Step 187: agent emits `retrieve(url=...)`. The `tool_call` block is appended to the transcript, consuming budget. The trigger evaluator runs, sees 78.4% utilization, and fires compaction. 2. The compactor selects the oldest 60% of turns for summarization. The just-emitted `tool_call` is *not* in that window, so it survives verbatim—but its surrounding planning context ("I need this document to resolve the discrepancy in claim C") is summarized into "agent was investigating a discrepancy." 3. Step 188: the tool result arrives and is appended. The agent now has a `tool_result` block whose originating intent has been compressed away. The model, reading the summary + result but not the original reasoning, treats the result as already-synthesized background and does not act on the discrepancy. 4. Step 189–203: the agent proceeds as though C was resolved. The final report asserts C with the *wrong* polarity—the discrepancy was real and the retrieved document contradicted the prior claim, but the agent never integrated the contradiction because the intent that would have flagged it was the part compaction deleted. The obligation was never *dropped* in the transport sense—the result arrived, the call succeeded. The loss was at the **intent-obligation binding**: the link between "why I called this" and "what to do with the answer" was severed by asymmetric compaction (intent summarized, call/result preserved). A second observed variant is worse: if the trigger fires and the summarizer *does* fold the orphaned `tool_call` into the summary text as "agent attempted retrieval," the subsequent `tool_result` arrives with no matching call in the structured transcript, and strict tool-protocol validators reject the turn, causing a retry loop that re-issues the retrieval and duplicates side effects. ## Condition of Validity This boundary failure is live only when all of the following hold, and the guardrail below is only required under the same conjunction: - Tool calls are **async or deferred** (result arrives in a later turn than the call), so a compaction trigger can interleave between call and result. - Compaction is **budget-triggered on append** rather than on turn boundaries, so the trigger can fire mid-obligation. - The compaction transform is **salience-based summarization** rather than a structured projection that preserves call/result pairing and their intent links. - The agent's continuation policy reads **only the post-compaction transcript**, with no external obligation ledger consulted at resume. If tool calls are synchronous and blocking (result forced into the same turn), the interleaving cannot occur. If compaction is deferred to turn boundaries and the boundary is defined to include call+result as an atomic unit, obligations are never split. If a durable obligation ledger exists and is re-read on every resume, transcript loss is recoverable. The invariant that must hold: **for every emitted tool call, either its result is present with its intent link intact, or an explicit unresolved-obligation marker is present in the post-compaction state.** Compaction that violates this is not "lossy but acceptable"; it is a correctness bug because it silently converts a pending commitment into a phantom completion. ## Decision Boundary The operational decision is where to place the compaction trigger relative to obligation state, and what the resume policy is allowed to assume. - **Trigger placement:** Evaluate the budget trigger only at *quiescent points*—points where no tool call is outstanding. If budget is exhausted mid-obligation, the correct action is to *block new emissions and force the pending result to land first*, not to compact. This bounds the window during which an obligation can be split to zero. - **Transform contract:** The compactor must be given a structured obligation set (the set of `tool_call` ids without matching `tool_result` ids, plus the intent span associated with each) and must be forbidden from summarizing any turn that contains an unresolved call or its intent. These are "pinned" spans. Summarize around them, never through them. - **Resume policy:** On any cold start or post-compaction resume, the agent must first reconcile the obligation set against the ledger and the transcript. If the transcript shows a result with no matching call, or a call with no result and no marker, the resume must halt and reconcile rather than proceed. Proceeding is the failure; halting is the guardrail. The boundary in one line: **compaction may compress reasoning, but it may never compress away the binding between an outstanding action and its purpose.** If the policy cannot guarantee that binding survives, the trigger is set too early or the transform is wrong. ## Operational Effect Systems that respect the invariant show a characteristic signature: compaction events cluster at turn boundaries, the obligation set is small and monotonically reconciled, and post-compaction divergence (final-claim polarity errors, duplicated side effects) drops to near zero. Systems that violate it show the opposite: compaction fires mid-flight, the obligation set is never materialized, and errors appear as *confident wrong completions* rather than crashes—the hardest class to detect, because the agent's own summary asserts the work was done. The practical cost is that the failure is invisible to transport-level monitoring (no timeouts, no errors) and only surfaces as semantic drift in downstream claims, often many steps later, making root-cause attribution to a single compaction event expensive. The guardrail's price is throughput: pinning obligations and deferring compaction to quiescent points reduces effective context utilization by the size of in-flight calls and their intent spans, typically 3–8% of budget in retrieval-heavy runs. That is the correct trade: a bounded utilization loss in exchange for eliminating a silent correctness failure that no downstream check reliably catches. ```python from dataclasses import dataclass, field from typing import Optional class ObligationSplitError(RuntimeError): """Raised when compaction or resume would sever a pending tool-call obligation.""" @dataclass class ToolCall: call_id: str intent_span: str result: Optional[str] = None @dataclass class Transcript: calls: dict[str, ToolCall] = field(default_factory=dict) summarized_spans: list[str] = field(default_factory=list) def unresolved_obligations(t: Transcript) -> set[str]: return {cid for cid, c in t.calls.items() if c.result is None} def can_compact(t: Transcript, utilization: float, trigger: float) -> bool: # Compaction may only fire at a quiescent point: no outstanding calls. if utilization < trigger: return False pending = unresolved_obligations(t) if pending: raise ObligationSplitError( f"compaction trigger at {utilization:.2%} fired with " f"{len(pending)} unresolved tool-call obligations: {sorted(pending)}; " f"defer compaction until results land" ) return True def resume_after_compaction(t: Transcript, ledger: set[str]) -> None: # Reconcile transcript against durable ledger before continuing. orphan_results = { cid for cid, c in t.calls.items() if c.result is not None and cid not in ledger } if orphan_results: raise ObligationSplitError( f"resume found results with no ledger-matched call: {sorted(orphan_results)}; " f"halt and reconcile, do not proceed" ) pending = unresolved_obligations(t) if pending: # Pending calls must survive as pinned spans with intent intact. for cid in pending: if t.calls[cid].intent_span in t.summarized_spans: raise ObligationSplitError( f"intent span for pending call {cid} was summarized away; " f"obligation binding severed" ) ```