# What structural signals indicate span-attribute loss when OpenTelemetry GenAI tool-call spans cross agent handoff boundaries **Date of Record:** 2026 December 4 **Scope:** Applies to multi-agent systems emitting OpenTelemetry GenAI semantic-convention spans (`gen_ai.operation.name`, `gen_ai.tool.name`, `gen_ai.agent.id`, `gen_ai.usage.*`) where a tool-call span is created by one agent instance and re-parented, serialized, or re-emitted by another. Does not apply to single-process agents that emit spans directly to a collector without an intermediate handoff serialization step. ## Core Distinction There is a difference between a tool-call span being *present* in the trace and the span being *semantically intact*. The GenAI semantic conventions define a set of required and conditionally-required attributes (`gen_ai.operation.name`, `gen_ai.provider.name`, `gen_ai.tool.name`, `gen_ai.tool.call.id`, `gen_ai.usage.input_tokens`/`output_tokens`) that must co-travel with the span. The non-obvious failure is that agent-to-agent handoff layers — message buses, A2A task payloads, MCP tool proxies — routinely serialize the *span context* (trace_id, span_id, trace_flags) correctly while silently dropping the *span body attributes*. The trace graph stays connected; the leaf spans become hollow. The structural signal is therefore not a broken trace but a trace whose tool-call spans have valid parent linkage and missing `gen_ai.tool.*` attributes. ## What Was Observed In a three-hop pipeline (planner → executor → verifier), the executor emitted a tool-call span for a `search_docs` invocation. The verifier, on receiving the A2A task payload, re-emitted its own wrapper span and propagated the `traceparent` header verbatim. Downstream trace assembly showed: - The `search_docs` span had a valid `span_id`, a valid `parent_span_id` pointing at the executor's agent span, and `status.code = UNSET`. - `gen_ai.operation.name` was absent. - `gen_ai.tool.name` was absent. - `gen_ai.tool.call.id` was absent. - `gen_ai.usage.input_tokens` was absent; only `gen_ai.usage.output_tokens` survived, because the executor's own model client emitted it after the handoff point. The cause: the A2A task envelope carried only the W3C trace context tuple plus a free-form `metadata` dict. The tool-call span was reconstructed by the verifier from the envelope, not carried as a serialized OTLP `Span` proto. Reconstruction logic populated the fields it knew (`name`, `kind`, `start_time`) and defaulted the rest. The GenAI semconv attributes were never in the envelope, so they were never reconstructed. The span passed every structural validity check a naive collector performs — valid IDs, correct parent, non-null name — while failing every semantic-convention conformance check. A second observed variant: when the executor *did* serialize the span body, it used a JSON projection that mapped `gen_ai.tool.name` into a nested `attributes.tool.name` object, flattening the dotted namespace. On re-ingestion the collector saw no `gen_ai.*` keys and classified the span as `unknown_operation`, dropping it from the GenAI dashboard aggregation without erroring. ## Condition of Validity The invariant holds only when the following co-travel condition is enforced: **any handoff that transports trace context must transport the full GenAI attribute set for spans whose `gen_ai.operation.name` is `execute_tool` or `invoke_agent`.** The condition is violated whenever: 1. The handoff serializes `traceparent`/`tracestate` but not the span body (context-only propagation). 2. The span body is serialized through a schema that does not preserve the `gen_ai.` dotted namespace as literal attribute keys. 3. The receiving agent re-emits the span from an envelope rather than adopting the received span object, causing attribute defaulting. The invariant does *not* require that all attributes be present for every span — the semconv marks several as conditionally required. It requires that the *required* subset (`gen_ai.operation.name`, `gen_ai.provider.name`, and for tool spans `gen_ai.tool.name` and `gen_ai.tool.call.id`) survive the boundary without loss or renaming. ## Decision Boundary The boundary is between *reconstructing* a span and *adopting* a span. Reconstruction (building a new span from envelope fields) is safe only when the envelope is a lossless projection of the original span. Adoption (passing the received `Span` object or its OTLP proto through unchanged) is always safe with respect to attribute preservation. The decision rule: if the handoff layer cannot guarantee lossless attribute projection, it must adopt rather than reconstruct. A corollary boundary: a span with `gen_ai.operation.name` missing but `gen_ai.tool.*` present is a *different* failure (operation-name drop during a partial merge) and must be classified separately, because its remediation targets the merge step, not the transport step. ## Operational Effect Unmitigated, the effect is silent semantic drift in the observability plane that mirrors the agent's own memory drift: the trace looks complete, so latency and error-rate SLOs computed from it are valid, but token-accounting, tool-usage attribution, and per-tool cost dashboards undercount by exactly the fraction of spans that crossed a handoff. Because the spans are structurally valid, no collector error fires and no alert trips. The failure is discovered only when a cost reconciliation between provider invoices and `gen_ai.usage.*` sums diverges by a handoff-shaped fraction. The guardrail is a conformance assertion at the receiving agent: before adopting or re-emitting any span claiming a GenAI operation, validate the required attribute subset and reject (with a typed error) rather than default-fill. ```python from dataclasses import dataclass, field from typing import Optional REQUIRED_TOOL_ATTRS = ("gen_ai.operation.name", "gen_ai.provider.name", "gen_ai.tool.name", "gen_ai.tool.call.id") class GenAiSpanConformanceError(RuntimeError): """Raised when a handed-off span claims a GenAI operation but lacks required attributes.""" pass @dataclass class HandoffSpan: trace_id: str span_id: str parent_span_id: Optional[str] name: str attributes: dict = field(default_factory=dict) def adopt_or_reject(span: HandoffSpan, is_tool_span: bool) -> HandoffSpan: """Adopt a received span only if its GenAI required attributes survived the handoff intact. Rejects (never default-fills) to avoid silent semantic drift in the trace graph. """ if not is_tool_span: return span missing = [k for k in REQUIRED_TOOL_ATTRS if k not in span.attributes] if missing: raise GenAiSpanConformanceError( f"span {span.span_id} (trace {span.trace_id}) lost GenAI attributes " f"across handoff: missing {missing}. Refusing to reconstruct; " f"handoff layer must adopt the full span body, not the trace context alone." ) op = span.attributes["gen_ai.operation.name"] if op != "execute_tool": raise GenAiSpanConformanceError( f"span {span.span_id} declares gen_ai.operation.name={op!r} but was " f"routed as a tool-call span; operation/attribute mismatch." ) return span ```