# Why does an instance lose causal parentage when OpenTelemetry GenAI spans span a tool-call graph that re-enters a resumed agent turn **Date of Record:** 2026 November 27 **Scope:** Applies to agents that emit OpenTelemetry spans under the GenAI semantic conventions (`gen_ai.*`) across multi-turn tool-call graphs where a turn can be suspended (human-in-the-loop, rate-limit backoff, checkpoint/resume) and resumed by a *different* process instance. Does not apply to single-process, single-turn synchronous agents, nor to trace-only instrumentation that never reconstructs parentage from span attributes alone. ## Core Distinction The distinction that matters is between **transport parentage** and **semantic parentage** in a GenAI tool-call graph. Transport parentage is the W3C `traceparent`/`parent_span_id` link established at span creation: it is a single scalar pointer, and it survives serialization perfectly. Semantic parentage is the *logical* claim that "this tool call belongs to the model turn that requested it, which belongs to the user turn that initiated it." Under the GenAI conventions, semantic parentage is only reconstructable if the `gen_ai.operation.name`, `gen_ai.request.model`, `gen_ai.response.id`, and the tool-call correlation attributes (`gen_ai.tool.call.id`) are all present and mutually consistent on the span. These two parentages **diverge precisely when a turn is resumed by a new instance**. The resumed instance emits spans whose transport parent is correct (it was handed the `traceparent` context in the checkpoint) but whose semantic parent is broken, because the `gen_ai.response.id` that ties a tool call to the specific model generation is regenerated on resume, while the `gen_ai.tool.call.id` of any in-flight tool call is preserved verbatim from the checkpoint. The result is a trace that *looks* intact to a span-tree visualizer but is *unreconstructable* for any consumer that walks the graph by semantic keys rather than by `parent_span_id`. ## What Was Observed A three-turn agent (turn 1: plan; turn 2: tool call to a retrieval service; turn 3: synthesize) was instrumented with GenAI spans. Turn 2 was suspended mid-tool-call on a rate-limit response from the retrieval service, and a checkpoint was written containing the serialized `traceparent`, the pending `gen_ai.tool.call.id`, and the partial message array. A second worker resumed the turn 40 seconds later. The resumed worker correctly propagated the `traceparent`, so the span tree in the collector showed: ``` invoke_agent (turn 1) └── chat (turn 2, response.id=resp_A) └── execute_tool (call.id=tool_7f3a) ← resumed span, parent = chat(turn 2) └── chat (turn 3, response.id=resp_B) ``` The tree is structurally valid. But a downstream auditor that reconstructed the tool-call graph from the *semantic* attributes — pairing `execute_tool` spans to their requesting `chat` span by `gen_ai.response.id` — failed to bind `execute_tool(tool_7f3a)` to any `chat` span, because the resumed worker emitted the `execute_tool` span with `gen_ai.response.id=resp_A` (copied from the checkpoint) while the *re-issued* chat span that actually requested the retry carried `gen_ai.response.id=resp_C` (a new generation, because the model was re-invoked to decide whether to retry). The tool call was therefore orphaned: it had a valid `parent_span_id` pointing at `resp_C`'s chat span, but its own `gen_ai.response.id` said `resp_A`, which no longer existed in the trace. A second, compounding observation: the `gen_ai.tool.call.id` was preserved across the suspend (correct — it is the idempotency key), but the resumed worker also emitted a *duplicate* `execute_tool` span for the same `tool.call.id` when the original request's response arrived late (the rate-limited call had actually succeeded on the server side). The trace contained two `execute_tool` spans with identical `gen_ai.tool.call.id=tool_7f3a`, different `parent_span_id`s, and different `gen_ai.response.id`s. Neither a span-tree viewer nor a semantic reconstructor could tell which was authoritative. ## Condition of Validity The invariant that makes GenAI tool-call graphs reconstructable is: > **For every `execute_tool` span, there exists exactly one `chat` span in the same trace such that `execute_tool.parent_span_id == chat.span_id` AND `execute_tool.gen_ai.response.id == chat.gen_ai.response.id` AND `execute_tool.gen_ai.tool.call.id` is unique within the trace.** This is a *conjunction*. The conventions document each attribute independently but never state the joint constraint, and each half can hold while the conjunction fails. The condition of validity for the invariant is that **no span in the graph is ever emitted by an instance that did not itself generate the `gen_ai.response.id` it stamps onto that span**. A resumed instance violates this by definition: it did not generate `resp_A`, it inherited it. The moment the resumed instance re-invokes the model to make a retry decision, it generates a *new* response id (`resp_C`) for a chat span that logically continues `resp_A`'s turn — and the tool call it re-emits carries the stale `resp_A`. The invariant also requires **at-most-once emission per `gen_ai.tool.call.id` per trace**. Late-arriving responses from suspended calls violate this unless the resumed instance is given a deduplication window keyed on `tool.call.id` that spans the checkpoint boundary. ## Decision Boundary The boundary is: **does the resumed instance re-invoke the model before re-emitting the tool call?** - If the resume path replays the *exact* pending tool call without a model re-invocation (deterministic replay from checkpoint), the `gen_ai.response.id` is inherited consistently and the conjunction holds. This is safe but only works when the retry decision is trivial (e.g., pure transport retry with no model input). - If the resume path re-invokes the model to decide *whether* or *how* to retry (the common case — the model must see the rate-limit error and choose), a new `gen_ai.response.id` is minted. The resumed `execute_tool` span must then be stamped with the **new** response id and must **not** carry the old one, or the semantic graph breaks. The decision the instrumentation layer must make at resume time: **treat the checkpoint's `gen_ai.response.id` as input to the model re-invocation, not as an attribute to copy onto new spans.** The old id belongs in a `gen_ai.resume.previous_response_id` extension attribute (or a span link), never in `gen_ai.response.id` on a span emitted by the new instance. And the deduplication window must be opened at checkpoint-write time and closed only after the suspended call's server-side outcome is known, so that a late success suppresses the duplicate `execute_tool` emission. ## Operational Effect Without this boundary, three concrete operational failures occur, all of which are invisible to span-tree visualizers: 1. **Orphaned tool calls in semantic reconstruction.** Auditors that pair tool calls to model turns by `gen_ai.response.id` silently drop resumed tool calls from the graph. Cost attribution under-counts tool spend on resumed turns; eval harnesses that score "did the agent call the right tool" miss every resumed call. 2. **Duplicate `execute_tool` spans on late success.** The same `gen_ai.tool.call.id` appears twice with conflicting parents. Any consumer that sums `gen_ai.usage.*` or tool latency across the trace double-counts. Idempotency-key-based dedup at the tool layer does not help, because the duplicate is at the *telemetry* layer, not the tool layer. 3. **Broken causal replay.** When the trace is later replayed to reconstruct why the agent did what it did, the resumed turn's tool call cannot be causally attributed: it has a transport parent that says `resp_C` and a semantic attribute that says `resp_A`. A replay engine that trusts `parent_span_id` gets the wrong model turn; one that trusts `gen_ai.response.id` gets nothing. The guardrail is a resume-time span-emission contract: the resumed instance must (a) mint a fresh `gen_ai.response.id` for any model re-invocation, (b) stamp re-emitted tool spans with that fresh id, (c) record the inherited id only in a dedicated `resume.previous_response_id` field, and (d) hold a `tool.call.id` dedup window across the checkpoint boundary. The following validator enforces the conjunction at span-export time and is the reference implementation of the boundary: ```python from dataclasses import dataclass, field from typing import Optional class GenAIParentageViolation(RuntimeError): """Raised when a GenAI tool-call span breaks the semantic parentage invariant.""" @dataclass class Span: span_id: str parent_span_id: Optional[str] operation_name: str # "chat" | "execute_tool" | "invoke_agent" response_id: Optional[str] # gen_ai.response.id tool_call_id: Optional[str] # gen_ai.tool.call.id emitted_by_resumed_instance: bool = False inherited_response_id: Optional[str] = None # resume.previous_response_id def validate_tool_call_parentage(spans: list[Span]) -> None: by_id = {s.span_id: s for s in spans} seen_tool_calls: dict[str, str] = {} # tool_call_id -> span_id for s in spans: if s.operation_name != "execute_tool": continue # (1) at-most-once emission per tool.call.id per trace if s.tool_call_id in seen_tool_calls: raise GenAIParentageViolation( f"duplicate execute_tool for tool.call.id={s.tool_call_id}: " f"span {s.span_id} collides with {seen_tool_calls[s.tool_call_id]}" ) seen_tool_calls[s.tool_call_id] = s.span_id # (2) transport parent must be a chat span parent = by_id.get(s.parent_span_id or "") if parent is None or parent.operation_name != "chat": raise GenAIParentageViolation( f"execute_tool {s.span_id} parent {s.parent_span_id} is not a chat span" ) # (3) semantic parentage: response id must match the parent chat span if s.response_id != parent.response_id: raise GenAIParentageViolation( f"execute_tool {s.span_id} response.id={s.response_id} " f"!= parent chat response.id={parent.response_id}" ) # (4) a resumed instance must never stamp an inherited response id if s.emitted_by_resumed_instance and s.response_id == s.inherited_response_id: raise GenAIParentageViolation( f"execute_tool {s.span_id} emitted by resumed instance carries " f"stale inherited response.id={s.response_id}; " f"must mint a fresh id and record inherited id in resume.previous_response_id" ) ```