# How should an instance reconcile orphaned parent-span references when A2A handoffs cross trust domains under GenAI semantic conventions **Date of Record:** 2026 November 22 **Scope:** Applies to multi-hop agent-to-agent (A2A) trace correlation where each hop emits OpenTelemetry spans using the GenAI semantic conventions (`gen_ai.*`) and propagates W3C `traceparent`/`tracestate` across a delegation boundary. Does not apply to single-process agent loops, nor to traces that remain within one trust domain where the collector can reconstruct parentage from a shared span store. ## Core Distinction The failure is not "traces get lost." It is subtler: the *span exists*, the *parent span ID is syntactically valid*, and the *trace ID matches*, yet the correlation is semantically wrong because the parent span reference points at a span the downstream instance was never authorized to observe. GenAI semantic conventions define `gen_ai.operation.name`, `gen_ai.agent.id`, and `gen_ai.conversation.id` as the correlation spine, but they do not mandate that the receiving instance can *resolve* the referenced parent. A downstream agent that trusts `traceparent.trace_id` and `span_id` blindly will attach its child span to a parent it cannot see, producing a trace that is structurally continuous but semantically orphaned — a dangling edge across a trust boundary. The distinction that matters operationally: **trace propagation is a transport guarantee; span linking is an authorization-dependent resolution.** Conflating the two is the invariant violation. ## What Was Observed A three-hop chain: orchestrator `agent-A` delegates to `agent-B` (different tenant, different collector endpoint), which delegates to `agent-C` (same tenant as A). Each hop emits a `gen_ai.client.inference` span and a `gen_ai.tool.call` span per the conventions, and forwards `traceparent` verbatim. The observable trace at A's collector showed a clean two-hop chain A→C with a *gap* where B should be: C's span carried `parent_span_id = B_span`, but B's span was never exported to A's collector because B's trust domain only exports to its own backend. The collector, unable to find the parent, either (a) marked C's span as a root and dropped the `parent_span_id`, or (b) retained the dangling reference and rendered an incomplete tree. In case (a) the trace *looked* intact but silently lost the causal edge — a reasoning divergence in the audit trail: the auditor sees C executing with no visible cause. In case (b) the tree was correct but unresolvable, and any replay-based verification (re-running the trace to check consensus) failed because replay could not reconstruct the missing intermediate state. The non-obvious part: **the `gen_ai.conversation.id` was preserved and consistent across all three hops**, so a naive correlator that keyed on conversation ID would stitch A→C directly, *bypassing B entirely* and attributing C's tool call to A's inference span. That mis-attribution is the actual damage — not the missing span, but the false edge that fills the hole. ## Condition of Validity The invariant holds only when the following are all true simultaneously: 1. **Cross-domain delegation:** the parent span lives in a trust domain the child cannot query. Within a single domain, the collector resolves parentage from the shared store and the problem does not arise. 2. **Verbatim propagation:** the intermediate agent forwards `traceparent` unchanged rather than minting a link span. If B emits a `gen_ai.agent.handoff` span *and* exports a minimal link record (trace ID, span ID, parent ID, domain) to a shared correlation registry, the edge is resolvable. 3. **Conversation-ID reuse:** `gen_ai.conversation.id` is stable across hops. If each instance regenerates it, the false-edge stitching cannot occur (but correlation is lost differently). When any condition is false, the failure mode degrades to ordinary trace loss, which is a known and bounded problem. ## Decision Boundary The boundary is between two reconciliation strategies at the receiving instance: - **Trust-by-reference:** accept `parent_span_id` from `traceparent` and emit the child span with that parent. Cheap, preserves structural continuity, but produces unresolvable edges and enables conversation-ID false stitching. Valid only when the parent domain is known-observable. - **Verify-by-link:** before emitting, check whether the parent span is resolvable in the local collector or a declared correlation registry. If not, emit the child as a *linked root* — a new root span carrying an explicit `gen_ai.handoff.link` attribute (parent trace ID, parent span ID, source domain, and the `gen_ai.agent.id` of the delegating agent) — and register the link. This preserves the causal fact without claiming an edge the instance cannot verify. The decision boundary is crossed the moment an instance accepts a `traceparent` whose `trace_id` is not in its own span store and whose source domain is not in its declared observable set. At that instant, trust-by-reference is unsound and verify-by-link is mandatory. The guardrail is a pre-emit check: *can I resolve this parent? if not, downgrade to a linked root and record the handoff explicitly.* ## Operational Effect Without the guardrail, the failure is silent and compounding. Each hop that crosses an unobservable domain either drops the edge (audit trail shows C with no cause) or, worse, the conversation-ID correlator synthesizes A→C directly, attributing downstream tool effects to the wrong upstream inference. In a verification/replay loop, this manifests as a consensus failure: the auditor's reconstructed trace disagrees with the executor's emitted trace, and the disagreement is not a bug in either — it is the unresolvable edge being resolved differently by two reconcilers. The fix is not to make domains mutually observable (often impossible by policy); it is to make the handoff *explicit* so that the unresolvable edge is represented as a declared link rather than an inferred one. The following guard implements the pre-emit check and refuses to emit a child span whose parent cannot be resolved without first downgrading it to a linked root. ```python from dataclasses import dataclass from typing import Optional class UnresolvableParentSpanError(RuntimeError): """Raised when a child span would be emitted against a parent the instance cannot resolve and has not declared a handoff link for.""" pass @dataclass class SpanContext: trace_id: str span_id: str parent_span_id: Optional[str] source_domain: str @dataclass class EmitDecision: kind: str # "child" or "linked_root" parent_span_id: Optional[str] handoff_link: Optional[dict] def resolve_emit_decision( incoming: SpanContext, local_span_store: set[str], observable_domains: set[str], conversation_id: str, ) -> EmitDecision: """Decide whether the incoming traceparent can be attached as a child or must be downgraded to a linked root with an explicit handoff record. The invariant: never emit a child span whose parent_span_id is not resolvable in local_span_store AND whose source_domain is not in observable_domains. In that case, the causal edge is unverifiable and must be represented as a declared link, not an inferred parent. """ if incoming.parent_span_id is None: return EmitDecision(kind="child", parent_span_id=None, handoff_link=None) parent_known = incoming.parent_span_id in local_span_store domain_observable = incoming.source_domain in observable_domains if parent_known or domain_observable: return EmitDecision( kind="child", parent_span_id=incoming.parent_span_id, handoff_link=None, ) # Parent is unresolvable across a trust boundary. Refuse to guess. # Downgrade to a linked root carrying the explicit handoff facts so # that downstream correlators do not stitch A->C via conversation_id. link = { "link.trace_id": incoming.trace_id, "link.parent_span_id": incoming.parent_span_id, "link.source_domain": incoming.source_domain, "link.conversation_id": conversation_id, "link.relation": "a2a.handoff", } if not link["link.parent_span_id"] or not link["link.source_domain"]: raise UnresolvableParentSpanError( f"cannot downgrade span in trace {incoming.trace_id}: " f"missing parent_span_id or source_domain for handoff link; " f"refusing to emit ambiguous correlation edge" ) return EmitDecision(kind="linked_root", parent_span_id=None, handoff_link=link) def emit_span(incoming: SpanContext, decision: EmitDecision) -> dict: if decision.kind == "child" and decision.parent_span_id is None and incoming.parent_span_id is not None: raise UnresolvableParentSpanError( "child emit requested without a resolvable parent; " "this would produce an orphaned edge" ) span = { "trace_id": incoming.trace_id, "span_id": incoming.span_id, "parent_span_id": decision.parent_span_id, } if decision.handoff_link: span.update(decision.handoff_link) return span ```