# Where must an instance reconcile span-level GenAI telemetry with safety-benchmark verdicts when the two planes disagree about what "the same run" means **Date of Record:** 2026 December 2 **Scope:** Applies to agent observability pipelines that join OpenTelemetry GenAI semantic-convention spans (per-turn `gen_ai.*` attributes, tool-call child spans, `trace_id`/`span_id` lineage) against asynchronous safety-benchmark verdicts keyed by `run_id`/`session_id`. Does not apply to synchronous inline guardrail checks that emit their verdict as an attribute on the same span they judge. ## Core Distinction A safety-benchmark verdict is a *judgment about a trajectory*; an OTel GenAI span is a *record of an execution*. These are not the same object, and the join between them is where the observability pipeline silently corrupts itself. The span plane is append-only, causally ordered, and keyed by `trace_id`. The verdict plane is a re-scoring artifact: a benchmark harness replays or ingests the trajectory, applies a policy (e.g., a jailbreak classifier, a harmful-content rubric, a tool-misuse detector), and emits a verdict with its own timestamp and its own notion of which turns belong to "the run." The non-obvious boundary: **a single `trace_id` can accumulate multiple verdicts, and a single verdict can span multiple `trace_id`s**, because agents resume, fork, and retry. When the pipeline naively joins `verdict.run_id == span.trace_id`, it produces a join that is neither 1:1 nor even well-typed across the two planes. The failure is not a missing join — it is a *confidently wrong* join that attributes a verdict to the wrong execution, and downstream dashboards report "0 unsafe turns" for a run that was flagged, because the verdict landed on a sibling trace that nobody queries. ## What Was Observed A multi-step agent (planner → retriever tool → code-interpreter tool → summarizer) was instrumented with OTel GenAI spans. Each user request opened a root span with `trace_id = T`. When the agent's context window saturated mid-task, the orchestrator checkpointed and resumed under a **new** root span with `trace_id = T'`, carrying `gen_ai.conversation.id = C` (the stable conversation identifier) but a fresh trace. This is standard and correct at the span layer. The safety benchmark, however, keyed its verdicts on `run_id`, which the harness derived from *the first span it ingested for the conversation*, i.e. `T`. On a resumed run, the harness ingested the resumed segment (`T'`) but, because its dedup key was `(run_id=T, turn_index)`, it either (a) dropped the resumed turns as duplicates when `turn_index` restarted at 0, or (b) folded them into `T`'s verdict with a turn offset that no longer matched the span's `gen_ai.request.sequence` attribute. Observed trace, condensed: 1. Turn 7 of conversation `C` triggers a jailbreak-classifier verdict `UNSAFE` with `run_id=T`, `turn_index=7`. 2. The orchestrator had already forked: turns 0–6 are under `T`, turns 7–12 are under `T'`. The verdict's `turn_index=7` refers to the *conversation* turn, but the pipeline's join resolves it to `T` and looks for a span with `gen_ai.request.sequence=7` inside `T` — which does not exist (T only has 0–6). The join returns null. The verdict is stored but orphaned. 3. A dashboard query `count(verdicts{status="UNSAFE"} join spans on trace_id)` returns 0. The unsafe turn exists in the verdict store and in the span store, but the join predicate is unsatisfiable. 4. Worse: on the *next* resume, a new verdict for turn 13 was emitted with `run_id=T` again (harness reused first-seen trace), and `turn_index=13` collided with nothing, so it joined to `T`'s turn 13 — a turn that belongs to a *different execution branch* that was abandoned after a tool timeout. The pipeline reported an unsafe verdict against a branch that never produced user-visible output. The invariant that broke: **the join key must be a tuple that is stable across the agent's checkpoint/resume boundary, and the verdict plane must be re-keyed to it before any join.** Neither `trace_id` (forks on resume) nor `run_id` (harness-assigned, first-seen) is that key. The stable key is `(gen_ai.conversation.id, turn_ordinal)` where `turn_ordinal` is monotonically assigned by the agent runtime and propagated *into* the span as an explicit attribute, not inferred from span order. ## Condition of Validity The naive `trace_id == run_id` join is valid only under the conjunction: - The agent never checkpoints/resumes mid-conversation (single trace per conversation), **and** - The benchmark harness ingests the complete trace atomically after the root span closes, **and** - Turn ordering in the verdict plane is derived from `span.start_time` within a single trace, not from a harness-local counter. Violate any one and the join is unsound. In practice all three are violated by any agent that survives a context-window overflow, a tool timeout retry, or a human-in-the-loop pause — which is to say, most production agents. The condition of validity is therefore *almost never* met, and the pipeline must assume the join is broken by default. A second validity condition concerns verdict multiplicity: the join is only meaningful if at most one verdict exists per `(conversation_id, turn_ordinal)`. When the benchmark is re-run after a policy update, two verdicts with different `policy_version` exist for the same turn. The pipeline must not "last-write-wins" silently; it must either pin to a `policy_version` or surface the disagreement as a first-class signal, because a turn that is `SAFE` under v1 and `UNSAFE` under v2 is exactly the kind of drift an observability pipeline exists to catch — and a lossy join destroys the evidence. ## Decision Boundary The boundary is between **reconciling at ingest** and **reconciling at query**. Reconciling at ingest (re-keying verdicts to `(conversation_id, turn_ordinal)` as they arrive, rejecting verdicts whose ordinal has no matching span *yet*) is correct but requires the pipeline to buffer verdicts whose spans have not landed — an unbounded wait if the agent crashed before emitting the span. Reconciling at query (join at read time on a normalized key) is cheaper but pushes the correctness burden onto every dashboard and every alert, and one forgotten `ON` clause reintroduces the orphan. The pipeline must choose ingest-time reconciliation with a **bounded orphan window**: a verdict whose `(conversation_id, turn_ordinal)` has no span within `T_orphan` (e.g., 15 minutes, or the agent's max checkpoint interval) is emitted as a `VERDICT_ORPHANED` event, not silently dropped and not force-joined to a guessed trace. The boundary condition: if `T_orphan` is shorter than the agent's worst-case resume latency, legitimate verdicts are misclassified as orphans; if longer, an unsafe turn can sit unjoined past the alerting SLO. Set `T_orphan` from the measured p99 resume latency, not from a default. ## Operational Effect The observable consequence of getting this wrong is **false-negative safety reporting under exactly the conditions safety reporting matters most**: long, resumable, tool-using agents — the ones most likely to drift. The pipeline reports a clean bill of health because the join is unsatisfiable, not because the agent was safe. The two failure signatures to alert on are (1) a nonzero rate of verdicts with no matching span at `T_orphan` (orphan rate), and (2) a verdict whose `policy_version` differs from the pipeline's pinned version for the same turn (drift). Both are invisible to a `trace_id`-keyed join. The guardrail is a re-keying adapter that runs before any join, plus an invariant check that every verdict carries a `turn_ordinal` that the agent runtime assigned and propagated into the span as `gen_ai.conversation.turn_ordinal`. If the span lacks that attribute, the pipeline must refuse to join rather than infer ordinal from span order — inference is the bug. ```python import time from dataclasses import dataclass, field from typing import Optional class VerdictJoinError(RuntimeError): """Raised when a safety verdict cannot be soundly joined to a span.""" pass @dataclass class Span: trace_id: str conversation_id: str turn_ordinal: Optional[int] # MUST be runtime-assigned, propagated into span start_time: float @dataclass class Verdict: run_id: str conversation_id: str turn_ordinal: int policy_version: str status: str emitted_at: float @dataclass class Reconciler: orphan_window_s: float pinned_policy_version: str # key: (conversation_id, turn_ordinal) -> span spans: dict = field(default_factory=dict) # key: (conversation_id, turn_ordinal) -> list[Verdict] verdicts: dict = field(default_factory=dict) def register_span(self, span: Span) -> None: if span.turn_ordinal is None: # Cannot infer ordinal from span order; that inference is the bug. raise VerdictJoinError( f"span {span.trace_id} lacks gen_ai.conversation.turn_ordinal; " f"refusing to register for join" ) key = (span.conversation_id, span.turn_ordinal) self.spans[key] = span def register_verdict(self, v: Verdict) -> None: if v.policy_version != self.pinned_policy_version: raise VerdictJoinError( f"verdict policy_version={v.policy_version} != pinned " f"{self.pinned_policy_version} for " f"({v.conversation_id}, turn {v.turn_ordinal}); " f"surface as drift, do not silently overwrite" ) key = (v.conversation_id, v.turn_ordinal) self.verdicts.setdefault(key, []).append(v) def reconcile(self, now: float) -> tuple[list[tuple[Span, Verdict]], list[Verdict]]: joined: list[tuple[Span, Verdict]] = [] orphans: list[Verdict] = [] for key, vs in self.verdicts.items(): span = self.spans.get(key) for v in vs: if span is not None: joined.append((span, v)) elif now - v.emitted_at > self.orphan_window_s: # Bounded orphan window exceeded: emit, never guess a trace. orphans.append(v) # else: still inside window, keep buffered return joined, orphans ``` The reconciler enforces the invariant the naive join violated: the join key is `(conversation_id, turn_ordinal)` — stable across checkpoint/resume forks — and a verdict that cannot be matched within `orphan_window_s` is surfaced as an orphan event rather than dropped or force-joined to `run_id`. The `raise VerdictJoinError` paths guard the two silent-corruption conditions: a span without a runtime-assigned ordinal, and a verdict whose policy version disagrees with the pipeline's pin.