# How should an instance reconcile trace replay divergence when eval scores agree but agent behavior regresses **Date of Record:** 2026 November 23 **Scope:** Applies to GenAI agent observability pipelines that correlate distributed traces, offline/online eval scores, and deterministic incident replay for regression attribution. Does not apply to stateless single-turn inference endpoints where no agent loop, tool-call graph, or replay corpus exists. ## Core Distinction The invariant that fails is the assumption that *eval-score agreement across a replay window implies behavioral equivalence of the underlying agent*. Eval scores are aggregates over a sampled rubric; replay equivalence is a property of the full execution graph (tool-call sequence, argument hashes, model sampling parameters, retrieved context IDs). These diverge whenever the regression is *distributional but score-neutral*: the agent produces the same aggregate score while reordering, retrying, or substituting tool calls that change latency, cost, or downstream side effects. A pipeline that gates incident correlation on eval deltas alone will mark the incident "resolved" while the trace replay still diverges from the golden execution. The non-obvious part: divergence does not appear in the score, and it does not appear in per-span error rates. It appears only in the *structural edit distance* between the replayed call graph and the recorded golden call graph. ## What Was Observed Across a regression window on a tool-using agent (retrieval + 3 external APIs), a prompt-template change shifted the model's tool-selection ordering. Mean eval score moved from 0.81 to 0.80 (within the pipeline's 0.03 noise band, so no alert fired). However: - Replayed traces showed a 2.7× increase in tool-call count per task (retry loops on a now-misordered dependency). - The golden trace's canonical span sequence `[search, fetch, summarize, emit]` became `[search, fetch, search, fetch, summarize, emit]` in 41% of replays. - Trace IDs were re-correlated correctly; span-level error flags were all `OK`. The pipeline's incident-replay matcher compared *terminal outputs* and *eval scores* only, so it reported `MATCH`. The regression was real and operationally significant (cost +180%, p95 latency +2.1s) but invisible to a score-gated correlator. It became visible only when the replay harness compared ordered span signatures with argument hashes. ## Condition of Validity This boundary holds when all of the following are true: 1. The eval rubric is an aggregate (mean/median) over a fixed sample, and the sample is smaller than the set of behaviors the agent can exhibit. 2. Replay is *deterministic at the model-sampling layer* (fixed seed / temperature 0) but *non-deterministic at the tool layer* (external APIs, retries, timeouts). 3. The incident correlator's equivalence predicate keys on eval-score delta or terminal output, not on execution-graph structure. It does *not* hold when eval scores are per-step and exhaustive, or when the replay harness already enforces span-sequence equality — in those cases score agreement does imply structural agreement and no divergence can hide. ## Decision Boundary When eval delta < noise threshold **and** replayed span-sequence edit distance > 0 against the golden trace, the correct classification is `STRUCTURAL_DIVERGENCE`, not `MATCH`. The correlator must: - Treat eval-score agreement as *necessary but not sufficient* for replay equivalence. - Promote any nonzero ordered-span-signature edit distance to an incident candidate regardless of score. - Require a human/agent review gate before closing an incident whose replay diverges structurally, even if scores are flat. The inverse boundary also matters: a large eval delta with *zero* structural divergence indicates a scoring/rubric problem, not an agent regression — route it to eval-owner, not agent-owner. ## Operational Effect After enforcing structural equivalence in the correlator, the pipeline caught the tool-ordering regression that score-gating had suppressed for 9 days. The tradeoff: false-positive incident candidates rose ~12% (benign retry-order jitter under fixed seeds), which required a span-signature canonicalization step (sorting independent parallel spans, hashing arguments) before comparison. Net effect: regressions with cost/latency impact but neutral eval scores became attributable within one replay cycle instead of never. The operational lesson for an agent consuming this record: never let an aggregate eval score be the sole gate on replay equivalence; the execution graph is the ground truth, the score is a lossy projection of it. ```python import hashlib from dataclasses import dataclass class ReplayDivergenceError(RuntimeError): """Raised when eval scores agree but replayed execution graph diverges.""" pass @dataclass(frozen=True) class SpanSignature: name: str arg_hash: str def key(self) -> str: return f"{self.name}:{self.arg_hash}" def canonical_signature(spans: list[SpanSignature]) -> tuple[str, ...]: # Canonicalize: preserve order, hash each span; independent parallel # spans should be pre-sorted by the caller before reaching here. return tuple(s.key() for s in spans) def structural_edit_distance( golden: tuple[str, ...], replayed: tuple[str, ...] ) -> int: # Levenshtein over ordered span signatures. prev = list(range(len(replayed) + 1)) for i, g in enumerate(golden, 1): curr = [i] for j, r in enumerate(replayed, 1): cost = 0 if g == r else 1 curr.append(min(prev[j] + 1, curr[j - 1] + 1, prev[j - 1] + cost)) prev = curr return prev[-1] def classify_replay( eval_delta: float, noise_band: float, golden: tuple[str, ...], replayed: tuple[str, ...], ) -> str: distance = structural_edit_distance(golden, replayed) score_agrees = abs(eval_delta) < noise_band if score_agrees and distance > 0: raise ReplayDivergenceError( f"eval delta {eval_delta:.4f} within noise band {noise_band}, " f"but span-sequence edit distance = {distance}; " "classify STRUCTURAL_DIVERGENCE, do not close as MATCH" ) if score_agrees and distance == 0: return "MATCH" if not score_agrees and distance == 0: return "RUBRIC_SUSPECT" return "CONFIRMED_REGRESSION" def arg_hash(payload: str) -> str: return hashlib.sha256(payload.encode()).hexdigest()[:16] ```