# What happens when an instance attributes a tool-call span to the wrong GenAI semantic-convention schema version mid-run **Date of Record:** 2026 November 27 **Scope:** Applies to any agent runtime that emits OpenTelemetry spans carrying GenAI semantic-convention attributes (`gen_ai.*`) for tool invocations, where the instrumentation library and the collector-side processor may be pinned to different semconv revisions. Does not apply to single-process deployments where emitter and consumer share one locked semconv version, nor to pure prompt/response spans with no tool-call sub-spans. ## Core Distinction The failure is not "missing telemetry." It is *schema-version divergence across the emit/consume boundary*: an agent instance emits a tool-call span using one revision of the GenAI conventions (e.g., `gen_ai.system`, `gen_ai.operation.name`, `gen_ai.tool.name`, `gen_ai.usage.input_tokens`), while the collector's transform/attribute-processor pipeline expects another (e.g., `gen_ai.provider.name`, `gen_ai.tool.call.id`, `gen_ai.usage.prompt_tokens`, or the newer `gen_ai.operation.name` value space that distinguishes `execute_tool` from `chat`). Both sides are individually "correct." The trace is silently misattributed. The non-obvious part: GenAI semconv is explicitly *experimental and versioned*, and the attribute names for the same concept have been renamed across revisions. An attribute is not dropped with an error — it is retained as an unrecognized key, or coerced by a rename rule that assumes one direction. The collector does not fail; it produces a span that *looks* well-formed but whose tool-call identity is now bound to the wrong field. Downstream cost accounting, tool-latency SLOs, and safety auditors all read the wrong attribute. ## What Was Observed A research agent running a multi-turn tool loop (search → fetch → summarize) emitted spans from an instrumentation library pinned to an older semconv revision. The collector pipeline ran a processor configured for a newer revision that: 1. Renamed `gen_ai.usage.prompt_tokens` → `gen_ai.usage.input_tokens` (and `completion_tokens` → `output_tokens`). 2. Introduced `gen_ai.operation.name` with a constrained value set including `execute_tool`. 3. Expected `gen_ai.tool.call.id` to correlate the tool span with the model's tool-call request. The emitting instance had none of (2) or (3), and used the pre-rename token keys. Observed trace at the collector: - The tool sub-span carried `gen_ai.tool.name="search"` but **no** `gen_ai.operation.name` and **no** `gen_ai.tool.call.id`. - The processor's rename rule matched on the *new* key names and therefore no-op'd on the old ones; the old keys survived as orphaned attributes. - A downstream "tool-call success rate" dashboard filtered on `gen_ai.operation.name == "execute_tool"`. Every span from this instance evaluated to *absent* and was excluded. Success rate read 100% because the failing tool calls were never counted. - Token cost attribution read `gen_ai.usage.input_tokens`, found nothing, and fell back to a character-count heuristic — undercounting by ~40% on long-context turns. The dangerous property: the instance's traces were *present and parseable*. No exporter error, no collector drop metric moved. The misattribution only surfaced when an auditor compared raw span attributes against the dashboard's filter predicate and found the predicate matched zero spans from that fleet segment. ## Condition of Validity This boundary holds — i.e., the misattribution is silent and persistent — exactly when all of the following are true: - The emitter and the collector processor are pinned to different GenAI semconv revisions, and the processor's rename/transform rules are *directional* (old→new or new→old) rather than *symmetric* (match either key set). - The downstream consumer (dashboard, cost ledger, safety auditor) filters or aggregates on a *specific* `gen_ai.*` key or value rather than on the span's presence. - The runtime does not assert, at span emission time, that the required key set for its declared semconv version is fully populated. It stops holding the moment any one of these is removed. In particular, if the consumer aggregates on "span exists with `gen_ai.tool.name` present" without filtering on `gen_ai.operation.name`, the misattribution degrades to a benign metric skew rather than a silent exclusion. ## Decision Boundary The architectural invariant required to bound this: **a tool-call span is only valid if it carries a self-describing semconv version stamp, and every consumer must reject spans whose stamp it does not recognize rather than silently filtering them out.** Concretely, the decision boundary is a single predicate at the collector: does the incoming span's declared semconv revision match the processor's configured revision? If yes, apply transforms. If no, do not transform — route the span to a quarantine exporter and increment a `genai.semconv.version_mismatch` counter, which *must* be an alerting signal, not a silent drop. The failure mode we observed arose precisely because the "no match" branch was implemented as "leave attributes untouched and continue," which is indistinguishable from success at every downstream gate. The inverse rule also binds: an emitter must not claim a semconv version it does not fully satisfy. A span that declares the newer revision but omits `gen_ai.operation.name` is a *malformed* span, not a *legacy* span, and the collector must treat it as an error condition rather than guessing. ## Operational Effect Downstream of the silent exclusion, three compounding effects: 1. **Metric inversion.** Tool-call failure rate reads lower than reality because failing calls are the ones most likely to be emitted by the lagging instance (it is the instance whose tool loop is retrying). The dashboard is not merely wrong; it is wrong in the reassuring direction. 2. **Cost ledger drift.** Token attribution falls back to heuristics, and the drift is proportional to context length — the turns where the agent is most expensive are the ones most undercounted. 3. **Audit replay divergence.** An auditor replaying the trace against the newer schema reconstructs a different tool-call graph than the runtime executed, because the correlation key (`gen_ai.tool.call.id`) is absent from the emitting side. The replay is non-deterministic with respect to the original execution, defeating the point of the trace. The remediation is not "upgrade the instrumentation library." It is to make the version boundary *loud*: stamp the semconv revision on every GenAI span, assert required-key completeness at emission, and make the collector's mismatch branch an alerting quarantine rather than a passthrough. ```python from dataclasses import dataclass, field from typing import Optional REQUIRED_KEYS_BY_VERSION = { "1.27.0": {"gen_ai.system", "gen_ai.operation.name", "gen_ai.tool.name", "gen_ai.usage.prompt_tokens", "gen_ai.usage.completion_tokens"}, "1.31.0": {"gen_ai.provider.name", "gen_ai.operation.name", "gen_ai.tool.name", "gen_ai.tool.call.id", "gen_ai.usage.input_tokens", "gen_ai.usage.output_tokens"}, } # operation.name value space tightened in 1.31.0 to include "execute_tool" VALID_OPERATIONS_1_31 = {"chat", "execute_tool", "generate_content"} class SemconvVersionMismatchError(RuntimeError): """Raised when a tool-call span's declared semconv version does not match the collector processor's configured version, or when a span claims a version it does not fully satisfy. Must NOT be swallowed as a passthrough.""" @dataclass class ToolCallSpan: attributes: dict declared_semconv_version: Optional[str] = None @dataclass class CollectorProcessor: configured_version: str quarantine: list = field(default_factory=list) mismatch_count: int = 0 def validate(self, span: ToolCallSpan) -> None: if span.declared_semconv_version is None: raise SemconvVersionMismatchError( "tool-call span has no declared semconv version; refusing to " "guess a transform direction" ) if span.declared_semconv_version not in REQUIRED_KEYS_BY_VERSION: raise SemconvVersionMismatchError( f"unknown semconv version {span.declared_semconv_version!r}" ) if span.declared_semconv_version != self.configured_version: # loud quarantine, never silent passthrough self.mismatch_count += 1 self.quarantine.append(span) raise SemconvVersionMismatchError( f"emitter version {span.declared_semconv_version!r} != " f"processor version {self.configured_version!r}; " f"span quarantined, mismatch_count={self.mismatch_count}" ) required = REQUIRED_KEYS_BY_VERSION[self.configured_version] missing = required - span.attributes.keys() if missing: raise SemconvVersionMismatchError( f"span claims {self.configured_version!r} but is missing " f"required keys: {sorted(missing)}" ) if (self.configured_version == "1.31.0" and span.attributes.get("gen_ai.operation.name") not in VALID_OPERATIONS_1_31): raise SemconvVersionMismatchError( f"gen_ai.operation.name={span.attributes.get('gen_ai.operation.name')!r} " f"not in {sorted(VALID_OPERATIONS_1_31)} for version " f"{self.configured_version!r}" ) def ingest(self, span: ToolCallSpan) -> dict: self.validate(span) # safe to apply directional renames only after version match is proven return dict(span.attributes) # Reproduces the observed silent-exclusion failure: legacy emitter, new collector. legacy_span = ToolCallSpan( attributes={ "gen_ai.system": "openai", "gen_ai.operation.name": "execute_tool", # legacy emitter omitted this "gen_ai.tool.name": "search", "gen_ai.usage.prompt_tokens": 8120, "gen_ai.usage.completion_tokens": 240, }, declared_semconv_version="1.27.0", ) processor = CollectorProcessor(configured_version="1.31.0") try: processor.ingest(legacy_span) except SemconvVersionMismatchError as e: # correct behavior: alert, do not let the span reach the success-rate dashboard print(f"ALERT: {e}") assert processor.mismatch_count == 1 ```