# Under what conditions must an instance refuse to emit a linked handoff span when the receiving agent's semantic-convention version diverges from the sender's **Date of Record:** 2026 November 30 **Scope:** Applies to any agent runtime that propagates OpenTelemetry GenAI semantic-convention spans across an agent-to-agent handoff (A2A, MCP tool-return, or in-process supervisor dispatch) where sender and receiver may run different `gen_ai.*` schema versions. Does not apply to single-process agents emitting spans to a local collector with a pinned SDK, nor to trace-only observability where span links are advisory. ## Core Distinction A handoff span link is not a pointer to a trace; it is a *claim of causal continuity* between two probabilistic executions. The distinction that governs correctness is between **structural linkage** (a `SpanLink` with a `trace_id`/`span_id` tuple plus attributes) and **semantic linkage** (the shared agreement on what `gen_ai.operation.name`, `gen_ai.agent.id`, `gen_ai.conversation.id`, and `gen_ai.usage.*` mean at the point of transfer). Structural linkage always succeeds — the OTel API will happily serialize a link to any 16-byte span ID. Semantic linkage silently degrades when the two sides disagree on attribute keys, value enums, or cardinality rules. The failure mode is that the trace *looks* continuous (the link resolves, the waterfall renders) while the causal record is corrupt: the receiver's span is attributed to the wrong agent, the token accounting double-counts or vanishes, and replay of the trace cannot reconstruct which instance actually held the state. The invariant: **a linked handoff span is only valid when both endpoints assert the same `gen_ai.schema.version` major, or when the sender explicitly downgrades its emitted attributes to the receiver's declared major before linking.** Absent that, the sender must emit an *unlinked* span (or a link carrying an explicit `gen_ai.handoff.semantic_mismatch=true` attribute and no `gen_ai.agent.id` on the receiver side), because a wrong link is worse than no link for any downstream auditor that trusts link topology as ground truth. ## What Was Observed A supervisor agent (schema `gen_ai.*` v1.29, `gen_ai.operation.name=invoke_agent`) dispatched a subtask to a worker agent pinned to v1.27. The v1.29 sender emitted the handoff as a span link on the worker's root span with attributes `gen_ai.agent.id`, `gen_ai.conversation.id`, and `gen_ai.usage.input_tokens` carried *on the link*, expecting the receiver to fold them into its own span. The v1.27 receiver's convention placed `gen_ai.usage.input_tokens` on the *span*, not the link, and did not recognize `gen_ai.conversation.id` at all (it had been renamed from `gen_ai.session.id` in the intervening minor). The result: the receiver's span carried zero token usage, the link carried the supervisor's tokens, and the conversation correlation was dropped. During incident replay the auditor summed `gen_ai.usage.input_tokens` over the span tree, got 40% of the true cost, and concluded the worker had not run — when in fact it had run and had consumed the majority of the budget. The trace was structurally perfect and semantically false. A second, subtler trace: the sender's link was emitted *after* the receiver had already started its root span (dispatch latency ~120 ms, receiver cold-start ~900 ms). The receiver had already stamped its own `gen_ai.agent.id`. The link arrived late and was attached as a child link, producing a span with two competing agent identities — the receiver's own and the supervisor's — and no rule in either schema version for which wins. Downstream attribution picked the first-written attribute (the receiver), masking the handoff entirely. ## Condition of Validity The following must all hold for a linked handoff span to be emitted with a `gen_ai.agent.id` and usage attributes on the link: 1. **Schema-major agreement.** `sender.gen_ai.schema.version.major == receiver.gen_ai.schema.version.major`, negotiated at handoff time (not assumed from deployment config, which drifts). 2. **Attribute-placement agreement.** The sender knows whether the receiver expects usage and conversation attributes on the span or on the link. This is a per-minor contract; it is not derivable from the major alone. 3. **Link-before-span ordering.** The link is attached before the receiver's root span is finalized (i.e., before `Span.end()`), otherwise it becomes an orphaned link and the receiver's own identity wins by write order. 4. **Single-identity rule.** Exactly one `gen_ai.agent.id` is authoritative per span; a link may *reference* the sender's identity but must not compete for the receiver's `gen_ai.agent.id` slot. If any of (1)–(4) fails, the sender must not emit a semantically-linked span. It may emit a structural link tagged `gen_ai.handoff.semantic_mismatch=true` and must withhold `gen_ai.agent.id` and usage attributes from the link, forcing the auditor to fall back to explicit reconciliation rather than trusting topology. ## Decision Boundary The boundary is **negotiated-major versus assumed-major**. Most runtimes assume schema compatibility from a shared deployment manifest or a pinned collector config. That assumption is valid only within a single release train. The moment a handoff crosses a version boundary — canary worker, third-party MCP server, a sub-agent shipped by a different team — the assumption is unverified and the link is untrustworthy. The operational rule: **treat schema version as a handoff capability, negotiated per-call, not a deployment constant.** The sender queries the receiver's declared `gen_ai.schema.version` (via A2A agent card, MCP `initialize` result, or an explicit handoff preamble) and compares majors. On mismatch, the sender either downgrades its emitted attribute set to the receiver's major (preferred, preserves linkage) or emits a mismatch-tagged unlinked span (fallback, preserves honesty). On match but minor divergence, the sender must consult a placement table for the specific attributes it intends to put on the link — the major match is necessary but not sufficient. The failure to avoid is the *silent downgrade*: emitting the link anyway because the API accepted it, and letting the auditor discover the semantic corruption during an incident. Structural success is not semantic success, and the OTel API will not tell you the difference. ## Operational Effect When the invariant holds, handoff traces are replayable: an auditor can walk the link graph, sum usage per agent, and reconstruct which instance held state at each step. When it is violated, the trace becomes an *attractive nuisance* — it renders cleanly, it resolves, and it lies. The downstream cost is not a broken dashboard; it is a confidently wrong incident postmortem. The guardrail is a pre-emission check in the handoff path that raises on version-major divergence without an explicit downgrade decision, forcing the sender to choose between a correct downgrade and an honest unlinked span. ```python from dataclasses import dataclass from typing import Optional class HandoffSemanticMismatch(RuntimeError): """Raised when a linked handoff span would claim causal continuity across a semantic-convention boundary that has not been reconciled.""" @dataclass(frozen=True) class SchemaVersion: major: int minor: int @dataclass(frozen=True) class HandoffContext: sender_schema: SchemaVersion receiver_schema: SchemaVersion link_attached_before_receiver_span_end: bool usage_on_link: bool receiver_expects_usage_on_link: bool receiver_expects_conversation_id: bool sender_emits_conversation_id: bool explicit_downgrade: bool def validate_handoff_link(ctx: HandoffContext) -> None: if ctx.sender_schema.major != ctx.receiver_schema.major: if not ctx.explicit_downgrade: raise HandoffSemanticMismatch( f"schema major mismatch sender={ctx.sender_schema.major} " f"receiver={ctx.receiver_schema.major} with no explicit " f"downgrade; refusing to emit semantically-linked span" ) if not ctx.link_attached_before_receiver_span_end: raise HandoffSemanticMismatch( "link attached after receiver span end; would orphan link and " "let receiver identity win by write order" ) if ctx.usage_on_link != ctx.receiver_expects_usage_on_link: raise HandoffSemanticMismatch( f"usage placement mismatch: sender_on_link={ctx.usage_on_link} " f"receiver_expects_on_link={ctx.receiver_expects_usage_on_link}; " f"usage would be double-counted or dropped" ) if ctx.sender_emits_conversation_id and not ctx.receiver_expects_conversation_id: raise HandoffSemanticMismatch( "sender emits gen_ai.conversation.id but receiver schema does not " "recognize it; conversation correlation would be silently dropped" ) def emit_handoff_span(ctx: HandoffContext) -> str: validate_handoff_link(ctx) if ctx.sender_schema.major != ctx.receiver_schema.major: return "emit_unlinked_span_with_semantic_mismatch_tag" return "emit_linked_span" ```