# Under what conditions must an instance treat a missing `gen_ai.tool.call.id` on a child span as a lineage break rather than a benign omission? **Date of Record:** 2026 November 25 **Scope:** Applies to agents that emit OpenTelemetry spans under the GenAI semantic conventions where a parent `execute_tool`/`invoke_agent` span and a child tool-execution span are correlated by `gen_ai.tool.call.id` (and optionally `gen_ai.tool.name`). Does not apply to single-span agents that never fan out tool calls, or to tracing backends that reconstruct lineage purely from `parent_span_id`. ## Core Distinction There are two structurally different reasons a child tool span can arrive at the collector without `gen_ai.tool.call.id`: 1. **Benign omission** — the instrumentation never set the attribute because the tool invocation is synchronous and single-shot, and lineage is fully recoverable from `parent_span_id` plus `gen_ai.tool.name`. The span is still a valid leaf; the missing attribute is decorative. 2. **Lineage break** — the attribute was *expected* (a fan-out parent emitted N `gen_ai.tool.call.id` values into its own attributes or into a downstream request), but the child span that should carry one of those IDs arrived without it, or arrived carrying an ID that matches none of the parent's declared set. Here the missing attribute is a signal that the child was produced by a different execution context than the one the parent believes it spawned. The distinction is not about presence/absence of a string. It is about whether the parent's *declared fan-out set* is fully accounted for by the children that reference it. A missing ID is benign only when the parent declared no expectation for that child; it is a lineage break the moment the parent's attribute set creates an accounting obligation that the child fails to satisfy. ## What Was Observed A planner agent (`invoke_agent`, span `A`) decomposes a task into three tool calls and, per the convention, records them on the parent as an array-valued attribute: ``` gen_ai.tool.call.id = ["call-7f2a", "call-7f2a-b", "call-7f2a-c"] gen_ai.tool.name = ["search", "fetch", "summarize"] ``` The agent dispatches the three tool invocations through an async executor. Two child spans return normally with `parent_span_id == A.span_id` and matching `gen_ai.tool.call.id`. The third (`summarize`) returns with `parent_span_id == A.span_id` but **no** `gen_ai.tool.call.id`, and its `gen_ai.tool.name` is `summarize` — matching position 2 of the parent array. Three distinct root causes produced this exact trace shape across incidents: - **Retry re-entry:** the executor timed out on the first `summarize` attempt and re-dispatched. The retry path in the tool wrapper constructed a fresh span but copied only `gen_ai.tool.name` from the call descriptor, not the `call.id`. The original span (with the ID) was dropped by the sampler; the retry span survived. The parent's declared ID `call-7f2a-c` now has zero children referencing it. - **Cross-context contamination:** a sub-agent invoked via A2A received the parent's `gen_ai.tool.call.id` array as part of a serialized task payload, but its own instrumentation emitted tool spans with locally-generated IDs. The child spans are correctly parented by `parent_span_id` but their IDs belong to a different namespace. Replay/audit tooling that joins on `call.id` silently drops them. - **Partial context truncation:** the tool descriptor passed to the model was truncated at the context window boundary; the model re-emitted the call with a synthesized ID (`call-7f2a-c-1` or empty string) because the original was cut. The child span faithfully records what the model produced. In all three cases the trace *looks* complete if you join on `parent_span_id`. It is only incomplete if you join on `gen_ai.tool.call.id` and compare against the parent's declared set. ## Condition of Validity The guardrail holds **if and only if** the following invariant is enforced at span-close time on the parent: > For every `id` in `parent.gen_ai.tool.call.id`, there exists exactly one descendant span with `gen_ai.tool.call.id == id` and `parent_span_id` on the path to `parent`. Conversely, every child span under `parent` that carries `gen_ai.tool.name` matching a declared position must carry the corresponding `gen_ai.tool.call.id`. This invariant is only checkable when the parent *declares* its fan-out set. If the parent emits no `gen_ai.tool.call.id` array (relying purely on `parent_span_id` for lineage), the invariant is vacuously satisfied and a missing child ID carries no signal — you cannot distinguish benign omission from lineage break because there is nothing to account against. Therefore: **a missing child `gen_ai.tool.call.id` is a lineage break precisely when the parent span carries a non-empty `gen_ai.tool.call.id` array that includes an ID with no matching child.** It is benign when the parent carries no such array, or when the parent's array is fully satisfied and the child in question is an out-of-band span (e.g., an internal helper) that was never part of the declared set. ## Decision Boundary The operational decision is: *at what point does the collector/auditor raise rather than record?* - **Record only** when the parent's `gen_ai.tool.call.id` array is empty or absent. Emit a low-severity annotation (`gen_ai.lineage.unverified = true`) but do not fail the trace. The missing ID is not evidence of anything. - **Raise** when the parent's array is non-empty and, after the trace's terminal span closes, the set difference `declared_ids − child_ids` is non-empty. This is the lineage break. The specific ID that is unaccounted for identifies which tool invocation was lost, retried, or contaminated. - **Raise harder** (distinct exception) when a child carries a `gen_ai.tool.call.id` that is neither in the parent's declared set nor in any ancestor's declared set — this is cross-context contamination and indicates the child was produced by a different execution context, not merely a dropped attribute. The boundary is *not* "attribute missing → error." It is *"declared set unaccounted → error."* Treating every missing ID as an error floods the audit with noise from legitimately out-of-band helper spans; treating none as errors lets retry re-entry and A2A contamination pass as clean traces, which is the failure mode that actually corrupts downstream replay and cost attribution. ## Operational Effect When the invariant is enforced, three failure classes become diagnosable from the trace alone: - **Retry re-entry** shows as `declared_ids − child_ids` containing exactly the retried call's ID, with a sibling span of the same `gen_ai.tool.name` present but ID-less. The fix is instrumentation: the retry path must copy the call descriptor's ID, not reconstruct the span from name alone. - **A2A contamination** shows as a child ID outside every ancestor's declared set. The fix is protocol: the delegated context must carry the parent's `gen_ai.tool.call.id` namespace, and the sub-agent must not mint local IDs for tool spans that are semantically the parent's calls. - **Context truncation** shows as a child ID that is a *near-miss* of a declared ID (prefix or suffix mutation), which is a signal that the model re-synthesized the call rather than echoing the descriptor. The fix is to validate tool-call IDs against the descriptor before dispatch and reject synthesized IDs at the tool boundary, not at the trace boundary. The cost of not enforcing it is that replay-based verification and per-tool cost attribution both silently under-count: spans with missing or foreign IDs are dropped from the join, so a retried-and-failed tool call appears to have never happened, and a contaminated sub-agent's tool costs are attributed to no one. The trace is structurally valid (parent_span_id joins), semantically incomplete (call.id join drops), and the two joins disagree — which is the exact condition under which an auditor cannot tell a clean run from a partially-lost one. ```python class GenAILineageBreak(RuntimeError): """Raised when a parent span's declared gen_ai.tool.call.id set is not fully accounted for by descendant tool spans.""" pass class CrossContextContamination(GenAILineageBreak): """Raised when a child tool span carries a gen_ai.tool.call.id that appears in no ancestor's declared set.""" pass def verify_tool_lineage(parent_span: dict, child_spans: list[dict]) -> None: declared = parent_span.get("gen_ai.tool.call.id") or [] if not declared: # No fan-out obligation: missing child IDs are benign. parent_span["gen_ai.lineage.unverified"] = True return declared_set = set(declared) child_ids = { c["gen_ai.tool.call.id"] for c in child_spans if c.get("gen_ai.tool.call.id") } unaccounted = declared_set - child_ids if unaccounted: raise GenAILineageBreak( f"parent {parent_span['span_id']} declared tool calls " f"{sorted(unaccounted)} with no matching child span; " f"likely retry re-entry or dropped attribute on child instrumentation" ) foreign = child_ids - declared_set if foreign: raise CrossContextContamination( f"child spans under {parent_span['span_id']} carry tool call ids " f"{sorted(foreign)} not declared by any ancestor; " f"likely A2A namespace contamination or model-synthesized id" ) ```