# Why does an instance lose causal attribution when trace IDs are re-minted at the tool boundary? **Date of Record:** 2026 November 22 **Scope:** Applies to agent runtimes that correlate LLM spans, agent-step spans, and tool-execution spans through distributed trace context (W3C `traceparent`/`tracestate`) propagated across process and network boundaries. Does not apply to single-process, single-threaded agents where all spans share one in-memory tracer and one root span. ## Core Distinction There are two different things an observability pipeline calls "correlation." The first is **identity correlation**: the ability to join spans that belong to the same logical request by a shared trace ID. The second is **causal correlation**: the ability to reconstruct the *ordering and dependency* of spans—which model call produced the tool invocation, which tool result fed the next reasoning step, and which model completion was the final answer. Identity correlation is cheap and survives almost any serialization. Causal correlation does not, because it depends on parent-child span linkage (`parent_span_id`) and on monotonic, comparable timestamps. The non-obvious boundary failure is this: an agent runtime can preserve trace-ID identity perfectly across the tool boundary while silently destroying causal linkage. This happens when the tool-execution layer is a **re-minting boundary**—an adapter that generates a fresh `traceparent` for the outbound tool call instead of continuing the inbound context. The trace ID survives (or a new one is minted and stitched later by a collector), the spans all land in the same backend, dashboards show 100% span coverage, and yet the causal graph is broken. The failure is invisible to coverage metrics because every span is present; only the edges are wrong. ## What Was Observed A multi-step agent executing a retrieve-then-summarize task produced the following span set in the tracing backend, all tagged with the same logical request ID at the collector: - `agent.step` span, `span_id=A1`, `parent_span_id=root`, start `t=0ms` - `llm.completion` span, `span_id=B2`, `parent_span_id=A1`, start `t=12ms`, end `t=840ms` - `tool.call` span, `span_id=C3`, `parent_span_id=B2`, start `t=845ms`, end `t=2100ms` - `llm.completion` span, `span_id=D4`, `parent_span_id=C3`, start `t=2110ms`, end `t=3900ms` This is the healthy graph. Now the degraded run, after a tool adapter was introduced that wrapped the retrieval client and re-minted context: - `agent.step`, `span_id=A1`, `parent_span_id=root`, `t=0ms` - `llm.completion`, `span_id=B2`, `parent_span_id=A1`, `t=11ms`, end `t=830ms` - `tool.call`, `span_id=C3`, `parent_span_id=A1` (not `B2`), `trace_id` unchanged, `t=846ms`, end `t=2050ms` - `llm.completion`, `span_id=D4`, `parent_span_id=A1` (not `C3`), `t=2060ms`, end `t=3880ms` The adapter had flattened the parent chain to the agent-step span. Every span was still emitted, still shared the trace ID, still landed in the backend. Span coverage was 100%. But the causal edge `B2 → C3` (model decided to call tool) and `C3 → D4` (tool output fed the next completion) were gone. The graph now asserted that the agent step directly fathered both tool call and second completion, which is false. The observable symptom surfaced downstream: a "which model call caused this tool invocation?" query returned the *first* completion for *both* tool calls in a two-tool run, because both tool spans pointed at the same ancestor and the collector's tie-break used start-time ordering. An incident reviewer concluded the agent had called the retrieval tool before generating its query string—an impossible ordering—and spent forty minutes on a hallucinated root cause. A second, subtler symptom: when the re-minting adapter *also* generated a new trace ID (the more common misconfiguration), the collector's late-stitching logic joined the two traces by a request-ID tag. That join is not causal—it merges two independent trace DAGs into one flat namespace, and any span that legitimately had a different trace (e.g., a retried tool call from a different agent replica) was absorbed into the wrong graph. The result was a trace that appeared to contain a tool call the agent never made. ## Condition of Validity The invariant that must hold for causal correlation to be trustworthy: > For every span `S` emitted by an agent step, `S.parent_span_id` must reference the span that *logically produced* `S`, and the `traceparent` propagated into any tool or sub-agent invocation must be the *same* trace context as the invoking span, with `parent-id` set to the invoking span's ID. A boundary that re-mints `traceparent` is only valid if it also records the inbound `(trace_id, span_id)` as explicit attributes and the collector is configured to prefer those attributes over the re-minted parent. This holds only when: 1. The tool adapter propagates, rather than regenerates, the W3C context. 2. Any intentional re-minting (e.g., crossing a trust boundary into a third-party tool) is accompanied by `link` attributes preserving `(trace_id, span_id)` of the caller. 3. Timestamps across layers share a clock source or are corrected at the collector; otherwise even a correct parent chain yields a graph with negative-duration edges. 4. The collector does not "repair" orphaned parents by hoisting them to the nearest ancestor—this is the exact behavior that converts a detectable break into an undetectable one. It does not hold when the tool layer is a black-box SaaS that strips `traceparent`, when the agent runtime runs across multiple clock domains without NTP discipline, or when the collector applies heuristic parent-inference. ## Decision Boundary The operational decision is whether to treat a re-minting tool adapter as a **correlation-preserving** or **correlation-severing** boundary. The rule: - If the adapter forwards `traceparent` unchanged (adjusting only `parent-id` to the current span), it is preserving. No special handling. - If the adapter must mint a new trace (third-party isolation, legal boundary, cross-tenant tool), it is severing *unless* it emits explicit `link` records. Treat severing boundaries as **causal graph cuts**: downstream spans are not attributable to upstream model calls without the link. - If the adapter re-mints but does *not* emit links, treat the entire downstream subgraph as **unattributed** and quarantine it from causal queries. Do not let the collector hoist or stitch it. The boundary is crossed the moment a tool span's `parent_span_id` points to a span that did not invoke it. Detection: for every `tool.call` span, verify that its parent is an `llm.completion` or `agent.step` span whose time window *contains* the tool call's start, and that the parent's end precedes the tool start by a bounded gap. A parent whose window does not contain the child is a severed edge. ## Operational Effect When this invariant is enforced, incident triage can answer "which model output drove this tool call" in one graph hop, and replay-based verification can reconstruct the exact reasoning chain. When it is violated and undetected, the observability layer produces *confidently wrong* causal graphs: coverage dashboards stay green, span counts match, and only the edges are false. The practical consequence is that root-cause analysis during agent incidents silently regresses to timestamp guessing, and the failure mode is misattributed to the model (hallucinated tool call) rather than to the telemetry boundary (severed parent link). The guardrail is a **parent-window containment check** run at ingestion, plus a hard rule that re-minting adapters must emit links or be flagged. The check below rejects any span whose parent's time window does not contain it, which is the cheapest reliable detector of a severed causal edge. ```python import time from dataclasses import dataclass, field class CausalLinkSeveredError(RuntimeError): """Raised when a span's parent does not logically contain it.""" @dataclass class Span: trace_id: str span_id: str parent_span_id: str | None name: str start_ms: float end_ms: float attributes: dict = field(default_factory=dict) def assert_causal_link(child: Span, parent: Span, max_gap_ms: float = 50.0) -> None: """ Enforce that `parent` logically produced `child`: - same trace - parent's window contains child's start (within max_gap_ms tolerance) - parent ends before child ends (no negative-duration edge) """ if child.trace_id != parent.trace_id: raise CausalLinkSeveredError( f"trace mismatch: child={child.trace_id} parent={parent.trace_id} " f"span={child.span_id}" ) if child.parent_span_id != parent.span_id: raise CausalLinkSeveredError( f"parent id mismatch: declared={child.parent_span_id} actual={parent.span_id}" ) if child.start_ms < parent.start_ms - max_gap_ms: raise CausalLinkSeveredError( f"child {child.span_id} starts before parent {parent.span_id} " f"({child.start_ms} < {parent.start_ms})" ) if child.end_ms < parent.start_ms: raise CausalLinkSeveredError( f"child {child.span_id} ends before parent {parent.span_id} begins" ) if child.end_ms > parent.end_ms + max_gap_ms: raise CausalLinkSeveredError( f"child {child.span_id} outlives parent {parent.span_id} " f"({child.end_ms} > {parent.end_ms}) — severed edge" ) def validate_trace(spans: list[Span]) -> None: by_id = {s.span_id: s for s in spans} for s in spans: if s.parent_span_id is None: continue parent = by_id.get(s.parent_span_id) if parent is None: # Orphaned parent: re-minting boundary stripped the caller. raise CausalLinkSeveredError( f"orphaned span {s.span_id}: parent {s.parent_span_id} absent from trace" ) assert_causal_link(s, parent) # Degraded run from the record: tool.call hoisted to agent.step. degraded = [ Span("t1", "A1", None, "agent.step", 0, 4000), Span("t1", "B2", "A1", "llm.completion", 11, 830), Span("t1", "C3", "A1", "tool.call", 846, 2050), # parent should be B2 Span("t1", "D4", "A1", "llm.completion", 2060, 3880), # parent should be C3 ] validate_trace(degraded) # raises CausalLinkSeveredError on C3's window check ```