# Why does an instance Lose Semantic Convention Fidelity When Propagating Trace Context Across an A2A Handoff? **Date of Record:** 2026 December 3 **Scope:** Applies to multi-agent systems where a delegating agent (orchestrator) emits a trace span carrying GenAI semantic conventions (`gen_ai.*` attributes) and hands execution to a peer agent over an A2A-style transport, with the peer responsible for continuing the trace under the same `trace_id`. Does not apply to single-process instrumentation, nor to systems where the receiver re-derives all attributes from its own model invocation rather than inheriting them. ## Core Distinction The failure is not "trace context is lost." Transport-level trace propagation (W3C `traceparent`/`tracestate`, `baggage`) usually survives an A2A handoff intact. The non-obvious boundary is **semantic convention fidelity**: the `gen_ai.*` attribute set is *schema-versioned and model-bound*, and when an orchestrator forwards its own span attributes as inherited context to a peer whose model, provider, or SDK differs, the receiver silently reinterprets attributes it did not author. Concretely, `gen_ai.usage.input_tokens`, `gen_ai.request.model`, and `gen_ai.response.finish_reasons` are **per-invocation facts about one model call**, not portable context. Propagating them as inherited baggage conflates *trace lineage* (which legitimately spans agents) with *invocation telemetry* (which does not). The invariant that breaks: **a `gen_ai.*` attribute must only be emitted by the component that actually executed the model call it describes.** ## What Was Observed An orchestrator agent (model `provider-a/large`, SDK emitting semconv `gen_ai` v1.27) delegated a subtask to a worker agent (`provider-b/medium`, semconv v1.31) over A2A. The orchestrator attached its full span attribute map to the outbound task message as `trace_context.attributes`, intending the worker to "continue the trace." The worker's SDK, on ingest, merged these attributes into its *own* span and then appended its own `gen_ai.usage.input_tokens` under the same key. Because the merge was a shallow dict update with the inherited map as the base, the observable failure trace was: 1. Worker span carried `gen_ai.request.model = provider-a/large` (inherited) *and* `gen_ai.usage.input_tokens = ` (authored) — a model/usage mismatch that no single component could have produced. 2. `gen_ai.response.finish_reasons` from the orchestrator's *prior* completed call persisted into the worker span, so downstream cost/quality aggregation double-counted a `stop` finish reason against a call that had not yet finished. 3. Semconv v1.31 renamed a token-accounting attribute; the worker emitted the new key while the inherited old key remained, producing two token totals on one span. The trace backend's rollup summed both. The trace *looked* continuous — correct `trace_id`, correct parent/child linkage — which is exactly why the corruption was invisible to lineage checks. The corruption lived entirely in the attribute plane. ## Condition of Validity This failure requires all three conditions simultaneously; remove any one and the corruption does not occur: - **Attribute inheritance is enabled** (the receiver merges forwarded attributes rather than discarding or namespacing them). - **The two endpoints disagree on semconv version or model identity** — if both run the same SDK version against the same provider, the inherited and authored values are at least type- and key-compatible, and the mismatch is benign. - **The merge is shallow and unqualified** — inherited keys occupy the same namespace as authored keys, so last-writer-wins silently overwrites lineage facts with invocation facts. The boundary is therefore not "cross-agent" per se. It is **cross-schema, cross-model attribute inheritance under a shallow merge**. Same-vendor, same-version swarms are immune, which is why the defect surfaces only in heterogeneous deployments and evades homogeneous test suites. ## Decision Boundary The correct policy is a hard split between two planes, enforced at the receiver's ingest boundary: - **Lineage plane** (`trace_id`, `span_id`, `parent_span_id`, `baggage` for routing hints): propagate freely; this is what A2A context transfer is *for*. - **Invocation plane** (`gen_ai.request.*`, `gen_ai.usage.*`, `gen_ai.response.*`): **never inherit**. The receiver must emit these only for calls it executed. Inherited invocation attributes, if needed for correlation, must be re-keyed under a distinct namespace (e.g., `gen_ai.upstream.*`) so they cannot collide with authored keys or be summed by rollup. A receiver that cannot prove an attribute was authored locally must drop it, not merge it. Attribution beats completeness. ## Operational Effect With the split enforced, trace rollups stop double-counting tokens and finish reasons; cost attribution returns to per-invocation truth; and semconv version skew becomes a non-event because versioned invocation keys never cross the boundary. The cost is that "full context continuation" is no longer literal — the worker's trace shows the upstream call only as a namespaced reference, requiring a join to reconstruct the full picture. That join is the price of attribution integrity, and it is the correct trade: a trace that is *continuous but wrong* is worse than one that is *continuous and honest about provenance*. ```python from dataclasses import dataclass, field from typing import Mapping INVOCATION_PREFIXES = ("gen_ai.request.", "gen_ai.usage.", "gen_ai.response.") LINEAGE_KEYS = frozenset({"trace_id", "span_id", "parent_span_id"}) class SemanticConventionCollision(RuntimeError): """Raised when inherited invocation attributes would collide with authored ones.""" @dataclass class SpanIngest: authored: dict = field(default_factory=dict) def merge_inherited(self, inherited: Mapping[str, str], semconv_version: str) -> dict: merged = dict(self.authored) for key, value in inherited.items(): if key in LINEAGE_KEYS: merged[key] = value continue if any(key.startswith(p) for p in INVOCATION_PREFIXES): # Invocation facts are never inherited under their native keys. requalified = key.replace("gen_ai.", "gen_ai.upstream.", 1) if requalified in self.authored: raise SemanticConventionCollision( f"requalified key {requalified!r} collides with authored " f"attribute under semconv {semconv_version}" ) merged[requalified] = value continue # Unknown keys: drop rather than guess attribution. return merged def continue_trace(inherited: Mapping[str, str], semconv_version: str) -> dict: if "trace_id" not in inherited: raise SemanticConventionCollision("handoff missing trace_id; cannot continue lineage") span = SpanIngest(authored={ "gen_ai.request.model": "provider-b/medium", "gen_ai.usage.input_tokens": "412", }) return span.merge_inherited(inherited, semconv_version) ```