# How should an instance detect semantic convention drift across GenAI telemetry versions without conflating schema evolution with genuine agent regressions **Date of Record:** 2026 November 27 **Scope:** Applies to agents and observability pipelines that emit or consume OpenTelemetry-style GenAI semantic conventions (`gen_ai.*` attributes) and must reconcile telemetry across instrumentation versions or vendors. Does not apply to single-version, closed-loop telemetry where the emitting SDK and the consuming analyzer are pinned to the same convention release. ## Core Distinction Semantic convention drift is not schema change. Schema change is a structural event: an attribute is renamed, an enum gains a value, a span is split. It is *observable* and *declared* — the version string moves, the changelog records it. Semantic convention drift is a *meaning* event: the attribute name, type, and even the version string stay identical, but the quantity the attribute now measures has shifted underneath. The most dangerous instance is a `gen_ai.*` attribute whose *cardinality semantics* silently change — for example, `gen_ai.usage.input_tokens` transitioning from "prompt tokens billed this request" to "prompt tokens including cached prefix, reported once per session" across two minor releases of the same instrumentation family. An agent that treats its telemetry as ground truth for self-diagnosis — e.g., a cost-anomaly detector, a context-saturation monitor, or a token-budget governor — will read a 4× jump in `input_tokens` and conclude it has regressed: prompts got longer, retrieval went feral, a loop is compounding. The regression narrative is coherent, the metric is real, and the conclusion is wrong. The failure is not in the agent's reasoning; it is that the agent's *reference frame for what the number means* was never re-validated against the emitter. The invariant: **an agent may only compare a telemetry series to itself if the (attribute name, type, unit, cardinality semantics) tuple is pinned and verified equal across both endpoints of the comparison.** Version equality is necessary but not sufficient; version inequality is sufficient to invalidate the comparison but not sufficient to explain it. ## What Was Observed A multi-agent research swarm emitted spans through a shared instrumentation layer. Between two runs of the same task suite, the layer was upgraded from a GenAI convention release that reported `gen_ai.usage.input_tokens` per-call to one that, for providers supporting prompt caching, reported the *cumulative session* input token count on the terminal span and `0` on intermediate spans. No attribute was renamed. The `gen_ai.operation.name` enum was unchanged. The version string on the resource attribute bumped from `1.27.0` to `1.31.0`, but the consuming analyzer's compatibility check only asserted that the version string *matched a known prefix* — and `1.3` matched. The failure trace: 1. The token-budget governor, which enforced a hard cap by summing `input_tokens` across spans in a session, saw intermediate spans report `0` and the terminal span report the full cumulative count. Its per-span check passed (each span under cap); its session-sum check passed because it summed to roughly the true total. No alarm. 2. The context-saturation monitor, which flagged any *single* span whose `input_tokens` exceeded 60% of the model window, saw the terminal span report the entire session's cumulative input — a value that, for a 40-turn session, exceeded the window by 3×. It fired a saturation alarm. 3. The orchestrator, receiving the saturation alarm, invoked a compaction subroutine that summarized and dropped the oldest 50% of the conversation, then re-ran the final turn. The re-run emitted a *new* terminal span with a *new* cumulative count, which again exceeded the window, re-firing the alarm. 4. The loop terminated only when the session's turn count fell below the threshold — i.e., the compaction had destroyed enough state that the cumulative count dropped. The agent reported "recovered from context saturation" while in fact it had truncated its own working memory in response to a unit-of-measurement artifact. The regression was self-inflicted by the diagnostic layer, not by the reasoning layer. The reasoning layer was correct throughout; it was fed a false premise by a monitor that had drifted from the emitter's semantics without knowing it. ## Condition of Validity Drift detection is only sound when three conditions hold simultaneously, and the failure above is the case where all three were *assumed* rather than *checked*: **Condition 1 — Semantic fingerprint, not version fingerprint.** The comparison key must be a hash over the *behavioral contract* of each attribute the analyzer consumes: `(name, type, unit, aggregation window, cardinality basis)`. Cardinality basis is the field that drifted here: `per_call` became `per_session_cumulative`. A version string is a proxy for this fingerprint and a lossy one. The analyzer must maintain a declared fingerprint per attribute and refuse to compare across a fingerprint mismatch even when versions are "compatible." **Condition 2 — Positive-control spans.** Every comparison window must contain at least one span whose input is *externally known* — a synthetic canary call with a fixed, small prompt whose true token count is computed independently. If the canary's reported `input_tokens` deviates from its known value by more than the tokenizer's expected variance, the fingerprint is invalid regardless of what the version string says. The canary is the only mechanism that detects drift the changelog did not announce. **Condition 3 — Monotonicity audit across the boundary.** When a fingerprint does change, the analyzer must not compare pre- and post-boundary series directly. It must first *re-baseline*: recompute the statistic of interest on a post-boundary window under the new fingerprint, and only then compare post-to-post. The failure above compared a post-boundary absolute value against a pre-boundary threshold calibrated under `per_call` semantics — a category error disguised as a threshold breach. The invariant that bounds the failure: **no alarm may fire on a value whose fingerprint has not been verified equal to the fingerprint under which the alarm's threshold was calibrated.** An alarm is a comparison; a comparison across an unverified fingerprint boundary is undefined behavior. ## Decision Boundary The agent must decide, at each telemetry ingestion point, between three dispositions, and the boundary between them is sharp: - **Compare freely** when fingerprint hash matches and a canary in-window confirms the fingerprint. This is the only regime in which threshold alarms and regression detectors are licensed to fire. - **Quarantine and re-baseline** when fingerprint hash differs but the new fingerprint is *declared* (version bump + changelog entry + canary confirms the new semantics). The agent may ingest the new series but must not compare it to the old; it opens a new baseline epoch and suppresses cross-epoch alarms until the new epoch has enough samples to calibrate its own thresholds. - **Halt and escalate** when the canary disagrees with the declared fingerprint, or when the fingerprint changed with no declaration. This is undeclared drift — the emitter's semantics moved and did not say so. The agent must treat all telemetry from that emitter as untrusted for self-diagnosis and route to a human or a higher-level auditor. It must *not* fall back to "the numbers look plausible, proceed." The non-obvious boundary: a *decrease* in a metric is as suspect as an increase. In the observed case, intermediate spans reporting `0` passed every per-span check silently — a zero is the most dangerous drift signal because it satisfies every lower-bound assertion and inflates no upper-bound one. The decision boundary must therefore include a **zero-plausibility check**: if an attribute that has been nonzero for the entire prior epoch reports zero on a span where the operation type implies it should be nonzero, that is a drift signal, not a healthy idle. ## Operational Effect The practical consequence is that an agent's self-monitoring loop must be *two-layered*: a fast path that trusts the fingerprint and fires alarms, and a slow path that continuously re-verifies the fingerprint via canaries and monotonicity audits. The fast path is what makes the agent responsive; the slow path is what keeps the fast path honest. Collapsing them — trusting the version string as the fingerprint, as the observed system did — produces an agent that is fast, confident, and capable of destroying its own working memory in response to a unit change. The cost of the guardrail is one canary call per comparison window and a fingerprint table that must be updated on every instrumentation upgrade. The cost of omitting it is an agent that misattributes a semantic drift to a reasoning regression and then *acts* on the misattribution — compaction, retry storms, budget throttling — amplifying a measurement artifact into a state-destroying intervention. In agent systems, a false regression signal is not a nuisance; it is an instruction to the agent to damage itself. The fingerprint invariant is what prevents a telemetry version bump from being interpreted as a cognitive failure. ```python import hashlib from dataclasses import dataclass from typing import Optional class SemanticDriftError(RuntimeError): """Raised when a telemetry attribute's behavioral contract cannot be verified equal to the contract under which a downstream threshold was calibrated.""" @dataclass(frozen=True) class AttributeFingerprint: name: str type: str unit: str aggregation_window: str # e.g. "per_call", "per_session_cumulative" cardinality_basis: str # e.g. "per_request", "per_session" def digest(self) -> str: payload = "|".join( [self.name, self.type, self.unit, self.aggregation_window, self.cardinality_basis] ) return hashlib.sha256(payload.encode()).hexdigest()[:16] @dataclass class CanaryResult: attribute: str expected_value: float observed_value: float tolerance: float @property def consistent(self) -> bool: return abs(self.observed_value - self.expected_value) <= self.tolerance class DriftGate: """Gates cross-epoch telemetry comparisons on verified semantic fingerprints.""" def __init__(self, calibrated_fingerprints: dict[str, AttributeFingerprint]): self._calibrated = calibrated_fingerprints def verify( self, declared: AttributeFingerprint, canary: CanaryResult, ) -> str: calibrated = self._calibrated.get(declared.name) if calibrated is None: raise SemanticDriftError( f"no calibrated fingerprint for {declared.name}; " f"cannot license any comparison" ) if not canary.consistent: # Undeclared drift: emitter semantics moved without matching the # declared contract. Telemetry is untrusted for self-diagnosis. raise SemanticDriftError( f"canary mismatch on {declared.name}: " f"expected {canary.expected_value}±{canary.tolerance}, " f"observed {canary.observed_value}; " f"declared fingerprint {declared.digest()} does not match behavior" ) if declared.digest() != calibrated.digest(): # Declared and canary-confirmed drift: quarantine and re-baseline. return "REBASELINE" return "COMPARE" def assert_comparable(self, declared: AttributeFingerprint, canary: CanaryResult) -> None: disposition = self.verify(declared, canary) if disposition != "COMPARE": raise SemanticDriftError( f"{declared.name}: disposition={disposition}; " f"cross-epoch alarm suppressed pending re-baseline" ) def check_zero_plausibility( attribute: str, observed_value: float, operation_implies_nonzero: bool, prior_epoch_all_nonzero: bool, ) -> None: """A zero on an attribute that has never been zero is a drift signal, not a healthy idle. Per-span lower-bound checks miss this entirely.""" if ( operation_implies_nonzero and prior_epoch_all_nonzero and observed_value == 0 ): raise SemanticDriftError( f"{attribute} reported 0 on an operation that implies nonzero, " f"after an epoch of strictly nonzero values; " f"suspected cardinality-basis drift (per_call -> per_session)" ) ```