# What structural signals indicate causal attribution failure when tool outputs mutate the agent context across multi-hop traces **Date of Record:** 2026 November 21 **Scope:** Applies to observability pipelines that reconstruct causal chains across multi-hop agent executions where tools return content that is written back into the agent's working context. Does not apply to single-hop stateless inference or to traces where tool outputs are immutable append-only logs never re-read by the model. ## Core Distinction The distinction that matters is between **observing a tool call** and **observing the effect of a tool call on the context that the next reasoning step actually consumes**. Standard GenAI observability treats a span as `(input, tool, output)`. Multi-hop traces with context mutation require a fourth element: the **context delta** — the exact bytes inserted, replaced, or truncated in the model's effective prompt between hop *N* and hop *N+1*. The non-obvious failure is this: a tool can return a *correct, well-formed, non-error* payload that nonetheless mutates the context in a way that silently invalidates causal attribution for every downstream hop. The trace looks healthy — no exceptions, no timeouts, monotonic span IDs — but the causal edge from the tool output to the final decision is misattributed, because the mutation changed the *salience* of prior context rather than its content. Truncation-on-insert, deduplication of "redundant" retrieved chunks, and summarization compaction all produce this class of failure. The trace records *what was written* but not *what was displaced*. ## What Was Observed A three-hop agent (retrieve → summarize → act) produced a trace where the final tool invocation cited a policy clause. The clause was present in the hop-1 retrieval output. The hop-2 summarizer, operating under a token budget, compacted the retrieved set and dropped the clause's *qualifying sentence* while keeping the clause's header. The hop-3 actor then invoked the clause without its qualifier. Replaying the trace from recorded spans reproduced the wrong behavior exactly. The causal attribution graph, however, drew an edge from the hop-1 retrieval directly to the hop-3 tool call, because the clause string appeared verbatim in both spans. The summarizer — the actual causal agent of the failure — had **zero edges** in the attribution graph. It was structurally invisible: it neither introduced the clause (retrieval did) nor emitted the action (the actor did), so a content-similarity attribution heuristic assigned it no causal weight. The structural signals that flagged this were: 1. **Span output length divergence from input length** at hop 2 exceeded the configured compaction ratio by 3.1×, but no compaction event was emitted as a span attribute. 2. **A negative context delta**: tokens present in hop-1 output and absent in hop-2 output, with no corresponding `drop` event in the trace. 3. **Attribution graph in-degree of zero** for a hop that mutated the context — a hop that changes what downstream hops see but is not credited with any downstream effect is either a no-op or a misattribution. It was the latter. ## Condition of Validity Causal attribution across context-mutating hops is valid **only if** every hop that writes to the context emits a structured delta record containing: (a) the exact set of tokens/segments inserted, (b) the exact set removed, (c) whether removal was budget-driven, dedup-driven, or model-driven, and (d) a content-addressed hash of the resulting effective context. Attribution heuristics that rely on string co-occurrence between spans are valid only when the mutation history is append-only. The moment any hop performs lossy mutation (summarize, truncate, dedupe, reorder), co-occurrence attribution becomes unsound, because a string present in span *A* and span *C* may have reached *C* through a lossy *B* that altered its meaning. The invariant to enforce: **for any two hops A and C with a claimed causal edge, there must exist a mutation chain from A to C whose cumulative delta is recorded, and the effective-context hash at C must be derivable from the hash at A plus that chain.** If the hash is not derivable, the edge is unsound and must be marked `attribution:unverified` rather than dropped or silently trusted. ## Decision Boundary The boundary is between **content-similarity attribution** and **delta-chain attribution**. Use content-similarity when: all intermediate hops are append-only, the context is never compacted, and no hop reorders or deduplicates. Use delta-chain attribution when: any hop applies lossy transformation, the token budget is enforced mid-trace, or a summarizer/compactor sits between retrieval and action. The specific decision rule: if a hop's output-length-to-input-length ratio deviates from 1.0 by more than the configured compaction threshold **and** that hop emits no explicit mutation event, the attribution pipeline must refuse to draw downstream edges through that hop and must surface a `MutationOpacityError`. Refusing is correct; a plausible-but-unsound edge is worse than a missing one, because downstream automated verification will replay the wrong causal story and confirm it. ## Operational Effect Enforcing delta-chain attribution converts an invisible failure into a first-class trace event. The summarizer hop gains in-degree equal to the number of downstream hops whose context it mutated, and its compaction ratio becomes a monitored signal. Replay from recorded deltas reproduces the *displaced* context, not just the retained context, so the qualifier-dropping bug becomes reproducible and localizable in one step. The cost is trace volume: delta records for lossy hops are proportional to removed content, not retained content. In practice this means storing the pre-mutation context hash and the removal manifest rather than full text, which bounds overhead to the manifest size while preserving hash-derivability. The guardrail is not "store everything" — it is "store enough to prove the chain," and refuse to attribute what you cannot prove. ```python import hashlib from dataclasses import dataclass, field class MutationOpacityError(RuntimeError): """Raised when a hop mutates context without emitting a delta record, making downstream causal attribution unsound.""" pass @dataclass class Hop: hop_id: str input_tokens: int output_tokens: int effective_context_hash: str mutation_event: dict | None = None # {'inserted': [...], 'removed': [...]} compaction_threshold: float = 0.85 def verify_attribution_chain(hops: list[Hop]) -> list[tuple[str, str]]: """Return sound causal edges. Refuse to draw edges through opaque lossy hops.""" edges: list[tuple[str, str]] = [] for prev, cur in zip(hops, hops[1:]): ratio = cur.output_tokens / max(prev.output_tokens, 1) lossy = ratio < cur.compaction_threshold or cur.output_tokens < prev.output_tokens if lossy and cur.mutation_event is None: raise MutationOpacityError( f"hop {cur.hop_id} reduced context " f"({prev.output_tokens}->{cur.output_tokens}, ratio={ratio:.2f}) " f"with no mutation_event; effective_context_hash=" f"{cur.effective_context_hash[:12]} is not derivable from " f"{prev.effective_context_hash[:12]}. Downstream edges unsound." ) if cur.mutation_event is not None: # Recompute hash from prev hash + recorded delta; must match. manifest = repr(sorted(cur.mutation_event.get("removed", []))) + \ repr(sorted(cur.mutation_event.get("inserted", []))) derived = hashlib.sha256( (prev.effective_context_hash + manifest).encode() ).hexdigest() if derived != cur.effective_context_hash: raise MutationOpacityError( f"hop {cur.hop_id}: recorded delta does not derive " f"effective_context_hash; attribution chain broken." ) edges.append((prev.hop_id, cur.hop_id)) return edges ```