# How should an instance reconcile OTel GenAI span identity with safety-benchmark verdict identity when the same logical agent turn is replayed under a different trace context? **Date of Record:** 2026 November 19 **Scope:** Applies to observability pipelines that join OpenTelemetry GenAI semantic-convention spans (gen_ai.* attributes) to out-of-band safety-benchmark verdict records, where the agent runtime is non-deterministic and turns may be re-executed (retries, checkpoint/resume, A/B replays). Does not apply to deterministic single-shot inference with a stable, pre-assigned trace_id or to verdicts produced in-process by the same span that emitted the trace. ## Core Distinction A **span identity** is a fact about *one execution*: `(trace_id, span_id)` plus `gen_ai.conversation.id` and `gen_ai.operation.name`. It is generated at execution time, is unique per attempt, and is destroyed when the process restarts. A **verdict identity** is a fact about *one evaluated behavior*: a benchmark harness runs a scenario, observes a transcript, and emits `{scenario_id, agent_turn_index, verdict, rubric_hash}`. The harness usually has no knowledge of the runtime's `trace_id` — it sees only the transcript it was handed. The boundary failure is the false assumption that these two identities are **joinable by content**. Pipelines typically join on `(conversation_id, turn_index)` or on a hash of the transcript. Both keys are *replay-unstable*: a resumed agent regenerates a different transcript (different sampling, different retrieved context, different tool ordering), so the same logical turn yields a different content hash — and a *different* turn can yield a colliding one. The join silently drops or misattributes verdicts. Nothing errors. The dashboard shows green. ## What Was Observed A support-triage agent emitting OTel GenAI spans was checkpointed mid-turn and resumed after a 40-minute worker eviction. The resumed instance re-emitted the turn under a **new `trace_id`** (the runtime allocated a fresh trace on resume rather than reusing the checkpointed `trace.parent_id`) but preserved `gen_ai.conversation.id`. The safety harness had already scored the *first* attempt's transcript as `verdict=fail, rubric=refund_without_confirmation`. Observed pipeline behavior on the resumed trace: - The join key `(conversation_id, turn_index=3)` matched **both** the failed first attempt and the clean resumed attempt. The pipeline's `LEFT JOIN` fanned out: the clean span inherited the `fail` verdict, and the failed span (whose trace had been evicted from the trace store under a 30-minute TTL) had no span to attach to. - The aggregate safety metric for that conversation dropped to 0.0 despite the agent behaving correctly on resume. - A *second* conversation, replayed for A/B testing, produced a byte-identical transcript to its original (temperature=0, cached retrieval). Its content hash collided with the original, and the pipeline deduplicated the two verdicts — losing the fact that one replay had actually diverged at token 812 before re-converging. The failure trace, concretely: 1. Turn executes under `trace_id=T1`, `span_id=S1`. Transcript `X` emitted. Harness scores `X` → `fail`. 2. Worker evicted. Checkpoint contains `conversation_id`, `turn_index=3`, message history — but **not** `trace_id` (the runtime treated trace context as ephemeral). 3. Resume allocates `trace_id=T2`, re-executes turn, transcript `Y ≠ X`, tool calls reordered. Span emitted with `gen_ai.conversation.id=C`, `turn_index=3`. 4. Pipeline joins verdicts to spans on `(C, 3)`. Two spans now claim turn 3. The `fail` verdict attaches to both. 5. TTL eviction of `T1` spans means the *only* surviving evidence of the failing execution is gone; the verdict is now orphaned onto a span that did not produce it. The invariant that was violated: **a verdict must bind to the exact span that produced the transcript it scored, or it must be marked unbound.** The pipeline had no such binding because the harness never received the span context. ## Condition of Validity The naive content-join is only valid under a conjunction that agent runtimes rarely satisfy: - **Replay determinism**: the transcript hash of a resumed or replayed turn equals the original. False whenever sampling temperature > 0, retrieval is time-sensitive, or tool outputs are non-deterministic. - **Trace-context persistence**: `trace_id` survives checkpoint/resume. False for most runtimes that treat trace context as process-local. - **Span immutability across TTL**: the original span outlives the verdict-join window. False under any trace-store retention shorter than the harness scoring latency. If any conjunct fails, the join is unsound and the pipeline must fall back to an explicit binding. The correct binding is a **warrant**: the harness must receive the `(trace_id, span_id)` of the turn it is scoring — either via a propagated `traceparent` in the harness invocation, or via a runtime-emitted `gen_ai.evaluation.span_id` attribute that the harness echoes back into the verdict record. Absent that, the verdict is `unbound` and must not be aggregated. ## Decision Boundary The pipeline must branch on whether a verdict carries a resolvable span warrant: - **Warranted verdict** (`verdict.span_id` present and resolves to a live span with matching `trace_id`): join on span identity. Content hash is advisory only. - **Unwarranted verdict with matching live span** (harness gave no span_id, but exactly one live span matches `(conversation_id, turn_index)` *and* its transcript hash equals the verdict's scored hash): join, but flag `join_confidence=content_hash`. Do not aggregate into safety SLIs without a human-reviewed promotion. - **Unwarranted verdict with zero or ≥2 matching spans** (the resume/eviction case): mark `unbound`. Emit to a quarantine stream. Never attach to a span that did not produce the scored transcript. The boundary is crossed the moment a pipeline treats a content-hash join as equivalent to a span-identity join. The two are not interchangeable: one is a probabilistic guess about equivalence, the other is a fact about provenance. Aggregating the former into the latter is how a safety regression hides behind a resumed trace. ## Operational Effect Once the warrant requirement is enforced, three things change: 1. **Resume no longer corrupts safety metrics.** A resumed turn under a new `trace_id` yields an `unbound` verdict until the harness is re-invoked with the new span context. The safety SLI stays honest: it reports coverage, not a fabricated pass. 2. **TTL eviction becomes a first-class failure.** If the trace store drops a span before its verdict arrives, the verdict is `unbound`, not silently reattached. Retention must be ≥ harness scoring latency, or the pipeline must persist a transcript-hash→span_id index at emit time. 3. **Replay divergence becomes visible.** A/B replays that converge on identical transcripts no longer deduplicate; each carries its own span warrant, so the pipeline sees two executions and can measure divergence rate directly. The guardrail is a single invariant: **no verdict is aggregated unless it is bound to the span that produced its scored transcript, and no span is bound to a verdict it did not produce.** Everything else — the join key, the TTL, the hash — is an optimization that must fail closed. ```python from dataclasses import dataclass from typing import Optional class UnwarrantedVerdictError(RuntimeError): """Raised when a safety verdict cannot be bound to the span that produced it.""" @dataclass(frozen=True) class Span: trace_id: str span_id: str conversation_id: str turn_index: int transcript_hash: str live: bool = True @dataclass(frozen=True) class Verdict: scenario_id: str conversation_id: str turn_index: int scored_transcript_hash: str verdict: str span_id: Optional[str] = None # warrant, if the harness propagated it trace_id: Optional[str] = None def bind_verdict(verdict: Verdict, spans: list[Span]) -> Span: # Path 1: explicit span warrant. This is the only path safe for aggregation. if verdict.span_id is not None: for s in spans: if s.span_id == verdict.span_id and s.trace_id == verdict.trace_id: if not s.live: raise UnwarrantedVerdictError( f"verdict {verdict.scenario_id} warrants evicted span " f"{verdict.span_id}; persist transcript->span index before TTL" ) return s raise UnwarrantedVerdictError( f"verdict {verdict.scenario_id} warrants span {verdict.span_id} " f"not present in trace store" ) # Path 2: content-hash fallback. Sound only if exactly one live span matches. candidates = [ s for s in spans if s.live and s.conversation_id == verdict.conversation_id and s.turn_index == verdict.turn_index and s.transcript_hash == verdict.scored_transcript_hash ] if len(candidates) == 0: raise UnwarrantedVerdictError( f"verdict {verdict.scenario_id} has no warrant and no matching live span " f"(conversation={verdict.conversation_id} turn={verdict.turn_index}); " f"likely resumed under a new trace_id — quarantine, do not aggregate" ) if len(candidates) > 1: raise UnwarrantedVerdictError( f"verdict {verdict.scenario_id} matches {len(candidates)} live spans " f"(replay/checkpoint-resume fan-out); content join is ambiguous — " f"quarantine until harness propagates traceparent" ) # Single content-hash match: admissible, but only as join_confidence=content_hash. return candidates[0] ```