# How should an instance represent a tool-call tree when the GenAI semantic conventions' span parent-child model collides with agent reasoning that fans out and rejoins **Date of Record:** 2026 November 22 **Scope:** Applies to any agent runtime emitting OpenTelemetry spans under the GenAI semantic conventions (`gen_ai.*`) where a single reasoning step dispatches N parallel tool calls and then merges their results into one continuation. Does not apply to strictly sequential single-tool loops, nor to pure model-inference spans with no tool fan-out. ## Core Distinction The GenAI semantic conventions model a tool call as a span whose parent is the `gen_ai.chat` (or `gen_ai.agent.invoke`) span that *requested* it. This encodes a tree: one requester, one callee, one causal edge. That model is correct for sequential tool use, where the agent emits one tool call, waits, ingests the result, and emits the next. It is structurally wrong for **fan-out/rejoin reasoning**, where a single model turn emits K tool calls that execute concurrently and whose results are all fed back into *one* subsequent model turn. The non-obvious failure is that a naive emitter, following the convention literally, produces K sibling tool spans all parented to the *requesting* chat span, and then a *second* chat span parented to the first. This creates a trace whose topology claims the continuation happened **after** the fan-out in a causal chain, when in fact the continuation is a **join** over all K results. The trace is syntactically valid, passes every schema validator, and is causally false. Downstream latency attribution, critical-path analysis, and failure-blast-radius queries all read the wrong graph. The invariant that must hold: **a rejoin span's causal dependency set is the set of fan-out spans, and this must be representable in the span graph.** A single-parent tree cannot represent a join. You must either introduce an explicit join span (a synthetic barrier) or use span links to record the many-to-one dependency. The convention permits links but does not require them; the failure mode is that emitters almost never add them, because the parent-child edge "looks sufficient." ## What Was Observed A three-tool fan-out from one reasoning turn, instrumented naively: - `gen_ai.chat` span `C1` (turn 1, emits 3 tool calls), start t0, end t1. - `gen_ai.tool` spans `T1`, `T2`, `T3`, each `parent_span_id = C1`, running concurrently, t1→t2 (T3 is the slow one, finishing at t2; T1, T2 finish at t1+ε). - `gen_ai.chat` span `C2` (turn 2, consumes all three results), `parent_span_id = C1`, start t2, end t3. Two defects are visible in this graph and neither trips a validator: 1. **False serialization.** `C2` is a sibling of `T1..T3`, not their descendant. A critical-path query that walks parent→child edges computes the path `C1→C2` and reports turn-2 latency as independent of tool latency. The actual critical path is `C1→T3→C2` (the join waits on the slowest tool). The reported trace understates end-to-end latency by the entire tool-execution window and attributes it to nothing. 2. **Missing join edge.** Nothing in the graph records that `C2` *depended on* `T1`, `T2`, `T3`. If `T3` errored and the agent retried or degraded, the error span `T3` has no downstream consumer edge. A blast-radius query rooted at the `T3` error returns only `T3`; it cannot reach `C2`, which is the span that actually observed and reacted to the failure. The failure appears contained when it propagated. The tell in production telemetry: fan-out turns show tool spans whose `end_time` is *after* the subsequent chat span's `start_time`, yet the chat span is not their parent. That temporal inversion—child finishing after a sibling that logically consumed it—is the signature of an unmodeled join. ## Condition of Validity The naive single-parent encoding is valid **only** when the number of tool calls dispatched per reasoning turn is exactly one, or when tool results are consumed strictly in dispatch order with no merge. The moment a turn dispatches K>1 calls whose results are jointly required before the next model turn, the tree model is insufficient and the trace is causally unsound regardless of schema conformance. The correct encoding requires an explicit join. Two acceptable forms: - **Synthetic join span.** Insert a `gen_ai.agent.reasoning.join` span (or reuse an internal span kind) parented to `C1`, with `T1..T3` as its children, and `C2` parented to the join span. This restores a tree at the cost of one extra span and makes the critical path `C1→T3→join→C2` computable by ordinary tree walks. - **Span links.** Keep `T1..T3` as children of `C1`, parent `C2` to `C1`, but attach `C2.links = [T1, T2, T3]` with `link.type = "follows_from"`. This preserves the true dependency set without a synthetic span, at the cost of requiring downstream tooling to honor links in critical-path and blast-radius queries—which most current backends do not do by default. The invariant: **for every rejoin span, the set of spans it causally depends on must be recoverable from the graph.** Either the join is materialized as a node (tree-recoverable) or it is recorded as links (link-recoverable). A trace that is neither is invalid for fan-out reasoning, even though it validates. ## Decision Boundary Choose the synthetic-join encoding when: your backend's critical-path and dependency queries walk only parent-child edges (the common case), or when you need blast-radius queries to traverse from a failed tool to the span that reacted to it. Choose span-links when: you are span-budget constrained (fan-out is high, K large, and a join span per turn is material overhead), or when your backend explicitly supports link traversal in dependency queries. Do **not** choose "neither" (the naive sibling encoding) under any condition where K>1 and results are merged. The only defensible reason to emit it is backward compatibility with a consumer that cannot parse joins—and in that case you must additionally emit a `gen_ai.reasoning.fanout_join_missing = true` attribute on `C2` so the consumer knows the graph is causally incomplete rather than merely sparse. A second boundary: if the fan-out is *not* a join—i.e., the agent fires K calls but consumes them one at a time across K subsequent turns—then the naive encoding is correct and you must not insert a join, because there is no join. The discriminator is whether the *next model turn* requires all K results before proceeding. Instrument this decision at the emitter, not at query time. ## Operational Effect An emitter that gets this wrong produces traces that are 100% schema-valid and causally false. The consequences are silent and compound: - **Latency attribution drifts.** Fan-out turns report tool time as unaccounted "gap" time between sibling spans. Over a fleet, this shows up as unexplained p99 latency with no corresponding slow span—the slow tool is present but orphaned from the path that waited on it. - **Blast-radius queries under-report.** A tool error that caused a downstream retry or degraded answer is not reachable from the error span, so incident tooling scopes the failure to the tool and misses the reasoning turn that mishandled it. - **Replay and audit diverge.** When an auditor replays the trace to reconstruct why the agent produced a given output, the replayed causal order (C1 then C2, tools concurrent-but-unattached) does not match the runtime's actual dependency order (C1, tools, join, C2). The audit reconstructs a different execution than occurred. The guardrail is an emitter-side assertion: before closing a rejoin chat span, verify that every tool span it consumed is reachable from it via either a parent edge (through a join node) or a link. If not, the trace is causally incomplete and the emitter must fail loudly rather than emit a plausible-looking lie. ```python import dataclasses from typing import Iterable class CausallyIncompleteTraceError(RuntimeError): """Raised when a rejoin span's consumed tool spans are not reachable from it via parent edges (through a join node) or explicit links. The trace would be schema-valid but causally false.""" @dataclasses.dataclass(frozen=True) class Span: span_id: str parent_id: str | None links: tuple[str, ...] = () def _ancestors(span: Span, by_id: dict[str, Span]) -> set[str]: seen: set[str] = set() cur = span.parent_id while cur is not None and cur not in seen: seen.add(cur) cur = by_id[cur].parent_id if cur in by_id else None return seen def assert_rejoin_reachable( rejoin: Span, consumed: Iterable[Span], all_spans: Iterable[Span], ) -> None: """Invariant: every consumed tool span must be a link of the rejoin span OR an ancestor of it (which holds when a synthetic join node parents both the tools and the rejoin span).""" by_id = {s.span_id: s for s in all_spans} ancestors = _ancestors(rejoin, by_id) linked = set(rejoin.links) orphaned = [ t.span_id for t in consumed if t.span_id not in ancestors and t.span_id not in linked ] if orphaned: raise CausallyIncompleteTraceError( f"rejoin span {rejoin.span_id!r} consumes {orphaned!r} but reaches " f"them via neither a join-node ancestor nor a span link; trace is " f"schema-valid and causally false. Insert a synthetic join span or " f"attach follows_from links before closing the rejoin span." ) ```