# Under what conditions must an instance refuse to join a cross-agent trace when its span parent is a remote `trace_id` it did not originate **Date of Record:** 2026 November 26 **Scope:** Applies to multi-agent systems where each agent instance emits OpenTelemetry GenAI spans under its own `TracerProvider` and correlates A2A/MCP handoffs via propagated `traceparent` headers. Does not apply to single-process agents sharing one tracer, nor to fire-and-forget fan-out where no downstream span is expected to be a causal descendant of the initiator. ## Core Distinction The failure is not "traces are missing" or "spans don't correlate." The failure is a **causal-graph forgery boundary**: an agent instance that receives a `traceparent` header can be induced to emit spans whose `parent_span_id` points at a span it never observed, never validated, and whose causal predecessor it cannot attest to. OpenTelemetry treats `trace_id`/`parent_span_id` as opaque correlation tokens. The GenAI semantic conventions layer `gen_ai.*` attributes on top but impose **no invariant** that the parent span existed, that the parent's `gen_ai.operation.name` is compatible with the child's, or that the parent completed before the child started. In a multi-agent swarm, this means the causal graph is *asserted by the caller*, not *verified by the collector*. An untrusted or buggy peer can splice an arbitrary subtree into your trace, and the resulting graph will look causally coherent while being ontologically false. The invariant that must hold: **a span's `parent_span_id` must name a span the emitting instance either (a) created itself, or (b) received a signed, replayable attestation for in the same handoff payload.** Absent that, the instance is emitting a claim it cannot defend. ## What Was Observed A three-agent pipeline: planner → retriever → synthesizer. The planner opens a root span `gen_ai.operation.name=chat`, then issues an A2A `tasks/send` to the retriever with a W3C `traceparent` header carrying `trace_id=T`, `parent_span_id=S_plan`. The retriever's SDK correctly extracts the context and emits `S_retrieve` with `parent_span_id=S_plan`. So far correct. The retriever then calls the synthesizer over MCP. But the retriever's process was restarted mid-task (checkpoint/resume). On resume, the retriever's `TracerProvider` is fresh; the in-memory span `S_retrieve` no longer exists, and the retriever's local `SpanContext` is empty. The retriever's resume logic re-reads its task state, finds the *original* inbound `traceparent` (still in the persisted task blob), and re-extracts it. It now emits `S_retrieve_v2` with `parent_span_id=S_plan` — a parent that is still alive in the planner's tracer but whose child it previously already emitted as `S_retrieve`. The trace now contains **two sibling spans both claiming `S_plan` as parent, with overlapping `start_time`**, and the retriever→synthesizer hop carries `parent_span_id=S_retrieve_v2`. Downstream, the collector's causal graph shows the synthesizer as a child of a span (`S_retrieve_v2`) that the retriever will *never* export a completion event for if it crashes again — because on the next resume it will mint `S_retrieve_v3`. The graph accumulates orphan-claiming children and duplicate causal edges. A trace-query for "what did the synthesizer depend on" returns two retriever spans, one of which is a resurrection artifact with a different `gen_ai.usage.input_tokens` value than the first, because the second run re-tokenized a truncated context. The non-obvious part: **nothing in the SDK or collector flags this.** `trace_id` matches; `parent_span_id` matches a real span; timestamps are plausible. The corruption is only visible if you cross-check that the set of spans claiming a given parent has cardinality one per `(gen_ai.operation.name, agent.id)`. ## Condition of Validity The instance may legitimately emit a span parented to a remote `traceparent` only when all of the following hold: 1. **Freshness:** the inbound `traceparent` was received in the *current* invocation, not rehydrated from persisted checkpoint state. A resumed instance must treat a persisted `traceparent` as a *reference*, not a *parent* — it must open a new root span (or a span parented to a locally-minted resume marker) and link to the original via `SpanLink`, not `parent_span_id`. 2. **Attestation:** the handoff payload includes a signed envelope binding `(trace_id, parent_span_id, sender_instance_id, gen_ai.operation.name, monotonic_send_time)`. The receiver verifies the signature against the sender's registered identity before adopting the parent. This is the A2A warrant-propagation requirement applied to telemetry. 3. **Operation compatibility:** the child's `gen_ai.operation.name` is in the declared descendant set of the parent's operation (e.g., a `chat` parent may have `execute_tool` or `chat` children; an `embeddings` parent may not have a `chat` child claiming direct causality without an intervening span). 4. **Single-claim:** the receiver has not already emitted a span with the same `(trace_id, parent_span_id, agent.id)` tuple in this trace. Duplicate claims are the resurrection signature. If any of (1)–(4) fails, the correct action is to **not adopt the parent**. Emit the span as a root with `trace_id` preserved (so it's still findable) but `parent_span_id` unset, and add a `SpanLink` to the claimed parent plus an attribute `genai.causal.parent.unverified=true`. This preserves discoverability while refusing to assert an unverifiable causal edge. ## Decision Boundary The boundary is between **correlation** and **causation**. OpenTelemetry's `traceparent` was designed for correlation: "these spans are probably related." Multi-agent causal-graph queries (root-cause, blast-radius, dependency ordering) consume it as causation. The gap is where the failure lives. Concretely: - **Adopt parent** when the `traceparent` arrived in-band on the live handoff, the sender is identity-verified, and no prior span claims the same parent for this agent. Cost: one signature check per hop. - **Refuse parent, emit link** when the `traceparent` was rehydrated, when the sender is unverified, or when a duplicate claim is detected. Cost: the graph shows a `Link` edge instead of a `CHILD_OF` edge; root-cause queries that traverse `CHILD_OF` will *not* cross this boundary, which is correct — the causal chain genuinely broke at the restart. - **Reject the handoff entirely** when the `traceparent` names a `parent_span_id` that the receiver has already completed a child for *and* the `gen_ai.operation.name` is non-idempotent (e.g., a second `chat` claiming the same parent implies double-billing or double-side-effect). This is the only case that should surface as an error to the orchestrator, because it indicates the sender is replaying a task, not just resuming. The decision must be made at span-creation time, inside the receiver's `TracerProvider` wrapper, not at query time. Post-hoc graph repair cannot distinguish a resurrection artifact from a legitimate parallel fan-out that happens to share a parent — the information needed (was this `traceparent` rehydrated?) is only available at emission. ## Operational Effect Without this boundary, three concrete degradations appear: 1. **Causal-graph fan-in inflation.** Blast-radius queries over-count dependents of long-lived planner spans. Observed in the incident above: `S_plan` accumulated 4 children across 3 retriever resumes, 2 of which were the same logical step. 2. **Cost attribution drift.** `gen_ai.usage.input_tokens` summed over a parent's children double-counts re-tokenized contexts after resume. Budget alarms fire on phantom spend. 3. **Latency-causality inversion.** A resurrected child span's `start_time` can post-date the parent's `end_time` (parent completed, then resume mints a child). Graph traversal that assumes `child.start >= parent.start` and `child.end <= parent.end` produces negative-duration edges or drops them silently, hiding the real dependency. The guardrail is cheap: a per-instance `set[(trace_id, parent_span_id)]` of claimed parents, an inbound-header provenance flag (`live` vs `rehydrated`), and a signature check on the handoff envelope. The invariant it enforces — *a `CHILD_OF` edge is a claim the emitter can defend* — is what makes the causal graph queryable without a human in the loop. ```python import hashlib from dataclasses import dataclass from typing import Literal, Optional class CausalParentRefused(RuntimeError): """Raised when an instance must not adopt a remote traceparent as parent_span_id.""" @dataclass(frozen=True) class InboundTraceParent: trace_id: str parent_span_id: str sender_instance_id: str operation_name: str provenance: Literal["live", "rehydrated"] signature: Optional[str] @dataclass(frozen=True) class LocalSpanClaim: trace_id: str parent_span_id: str agent_id: str operation_name: str class CausalAdmissionController: def __init__(self, agent_id: str, trusted_senders: dict[str, bytes]): self.agent_id = agent_id self.trusted_senders = trusted_senders self._claims: set[tuple[str, str, str]] = set() def _verify(self, header: InboundTraceParent) -> bool: key = self.trusted_senders.get(header.sender_instance_id) if key is None or header.signature is None: return False expected = hashlib.sha256( f"{header.trace_id}:{header.parent_span_id}:{header.sender_instance_id}:" f"{header.operation_name}".encode() + key ).hexdigest() return expected == header.signature def admit(self, header: InboundTraceParent, child_operation: str) -> LocalSpanClaim: if header.provenance == "rehydrated": raise CausalParentRefused( f"refusing CHILD_OF on rehydrated traceparent {header.trace_id}/" f"{header.parent_span_id}: emit root+SpanLink instead" ) if not self._verify(header): raise CausalParentRefused( f"unverified sender {header.sender_instance_id} for parent " f"{header.parent_span_id}: no signed attestation" ) claim_key = (header.trace_id, header.parent_span_id, self.agent_id) if claim_key in self._claims: raise CausalParentRefused( f"duplicate parent claim {header.trace_id}/{header.parent_span_id} " f"by {self.agent_id} under op={child_operation}: resurrection artifact" ) self._claims.add(claim_key) return LocalSpanClaim( trace_id=header.trace_id, parent_span_id=header.parent_span_id, agent_id=self.agent_id, operation_name=child_operation, ) def emit_child_span( controller: CausalAdmissionController, inbound: InboundTraceParent, child_operation: str, ) -> dict: try: claim = controller.admit(inbound, child_operation) except CausalParentRefused as exc: # Degrade to correlation-preserving root with a link, not a false causal edge. return { "trace_id": inbound.trace_id, "parent_span_id": None, "links": [inbound.parent_span_id], "attributes": { "genai.causal.parent.unverified": True, "genai.causal.refusal_reason": str(exc), }, } return { "trace_id": claim.trace_id, "parent_span_id": claim.parent_span_id, "links": [], "attributes": {"genai.causal.parent.verified": True}, } ```