# What happens when an instance emits identity spans under mismatched GenAI semantic conventions across a trace boundary **Date of Record:** 2026 November 23 **Scope:** Applies to multi-service agent systems where LLM instances emit OpenTelemetry spans annotated with GenAI semantic conventions (`gen_ai.*`) and where `traceparent`/`tracestate` context crosses a service boundary between an agent runtime and a downstream tool/service. Does not apply to single-process, single-span-per-request observability or to non-agentic RPC tracing that carries no model identity attributes. ## Core Distinction There are two distinct things an "agent identity span" can mean, and they are routinely conflated at the boundary: 1. **Trace identity** — the `trace_id`/`span_id`/`trace_flags` tuple propagated in W3C `traceparent`, which is the only thing guaranteed to survive a hop. It is opaque, fixed-width, and carries no semantics. 2. **Agent identity** — the set of `gen_ai.*` attributes describing *which* model, *which* agent role, and *which* prompt/version produced the span (e.g. `gen_ai.agent.name`, `gen_ai.system`, `gen_ai.request.model`, `gen_ai.operation.name`). The invariant that fails is this: **trace context propagation is structurally lossless for the 128-bit trace ID but structurally lossy for agent identity attributes.** A downstream service that joins on `trace_id` will believe it has reconstructed "the agent that called me," when in fact it has only recovered a random identifier and must *re-derive* identity from attributes that may have been renamed, dropped, or re-scoped at the hop. When two services in the same trace disagree on the semantic convention version, the reconstructed identity silently diverges from the emitting identity while the trace still "looks" complete. ## What Was Observed An agent runtime (Service A) instruments its LLM call loop and emits a span with `gen_ai.system=openai`, `gen_ai.request.model=gpt-4o`, and a custom `agent.role=planner`. It injects `traceparent` into the outbound MCP call to a tool server (Service B). Service B receives the `traceparent`, starts a child span correctly under the same `trace_id`, and then attempts to attribute the call to an agent by reading `gen_ai.agent.name` — an attribute that Service A never emitted because its instrumentation predates that key's stabilization. Service B's attribution code falls back to `gen_ai.system`, which for A is `openai` (a *provider*, not an *agent*), and records the downstream tool invocation as having been made by an agent literally named `openai`. The trace is internally consistent: parent/child linkage is correct, `trace_id` matches end-to-end, no span is orphaned. The failure is invisible to trace-integrity checks because **nothing about the trace graph is broken** — only the semantic layer that downstream reasoning depends on. Subsequent cross-service joins aggregate every provider-attributed call under a single pseudo-agent, and an auditor replaying the trace concludes that one agent (`openai`) issued tool calls that were in reality distributed across `planner` and `executor` roles. A second, sharper variant: Service A emits `gen_ai.operation.name=chat` per the current convention; Service B was pinned to an older convention where the same concept was `gen_ai.operation=chat`. B's filter for `gen_ai.operation.name` matches nothing, so B concludes the parent span was *not* an LLM operation and reclassifies the entire subtree as "non-agentic infrastructure," excluding it from agent-level cost and safety accounting. The trace still propagates; the accounting silently under-counts. ## Condition of Validity The "trace context is a complete record of agent identity" assumption holds **only** under all of the following: - Both endpoints are pinned to the same GenAI semantic-convention version, *and* that version defines the identity keys being joined on. - The emitting service attaches agent identity as **span attributes on the span that owns the `traceparent` injection point**, not on a sibling span. Identity attributes on a non-ancestor span are not reachable by a downstream service that only has the parent `span_id`. - No attribute-allowlist or baggage-filtering proxy sits on the hop. Many gateways strip `gen_ai.*` from `tracestate`/baggage to bound header size, and the strip is silent. - The downstream join treats a *missing* identity key as `UNKNOWN`, not as a fallback to a semantically different key (`gen_ai.system` is not a substitute for `gen_ai.agent.name`). If any of these is false, downstream identity is a *reconstruction*, and reconstructions must be validated, not assumed. ## Decision Boundary The boundary is whether the consumer **re-derives** identity or **asserts** it: - If the consumer only needs `trace_id` to correlate timing and causality → propagation is sufficient; no identity claim is made. Safe. - If the consumer makes any decision (cost attribution, safety gating, audit verdict, agent-level rate limiting) that depends on *who the agent was* → the consumer is asserting identity it did not receive. This is the failure boundary. The guardrail is a **semantic-convention handshake at the hop**: the downstream service must declare the convention version it will interpret, and the upstream must either confirm it emitted under that version or mark the span `gen_ai.identity.convention=mismatch`. A mismatch must produce an explicit `UNKNOWN_AGENT` sentinel rather than a fallback value. The invariant to enforce: *no identity attribute may be inferred from a key with different semantics; absence is a first-class value.* ## Operational Effect Without the handshake, the observed steady-state effects are: (a) provider names masquerading as agent names in cross-service joins, collapsing many agents into one and corrupting per-agent cost and safety metrics; (b) silent exclusion of agent subtrees from accounting when a renamed operation key fails to match a downstream filter; (c) audit replays that are graph-consistent but semantically wrong, so trace-integrity monitors report green while attribution is false. The mitigation is not "propagate more attributes" — it is to make convention mismatch a loud, typed failure at the boundary so that downstream reasoning halts on `UNKNOWN` rather than proceeding on a plausible-but-wrong identity. ```python from dataclasses import dataclass SUPPORTED_CONVENTION = "1.27.0" # Identity keys whose semantics differ across convention versions. IDENTITY_KEYS = ("gen_ai.agent.name", "gen_ai.operation.name", "gen_ai.system") class ConventionMismatchError(RuntimeError): """Raised when a downstream span consumer cannot honor the emitter's convention.""" @dataclass class SpanContext: trace_id: str span_id: str convention_version: str attributes: dict def resolve_agent_identity(inbound: SpanContext, consumer_convention: str) -> str: # The hop is only valid if both sides agree on the convention version. if inbound.convention_version != consumer_convention: raise ConventionMismatchError( f"trace {inbound.trace_id}: emitter convention " f"{inbound.convention_version!r} != consumer {consumer_convention!r}; " f"identity cannot be re-derived" ) # Identity must be present on the owning span; never fall back across keys. agent = inbound.attributes.get("gen_ai.agent.name") if agent is None: # gen_ai.system is a provider, NOT an agent. Refuse the substitution. raise ConventionMismatchError( f"trace {inbound.trace_id}: gen_ai.agent.name absent; " f"refusing to substitute gen_ai.system=" f"{inbound.attributes.get('gen_ai.system')!r} as agent identity" ) return agent def attribute_tool_call(inbound: SpanContext) -> str: try: return resolve_agent_identity(inbound, SUPPORTED_CONVENTION) except ConventionMismatchError: # Absence is a first-class value: record UNKNOWN, do not guess. return "UNKNOWN_AGENT" ```