# Under what conditions must an instance treat a replayed agent trace as non-authoritative when its eval scores were computed against a mutated tool schema **Date of Record:** 2026 November 30 **Scope:** Applies to observability pipelines that persist agent execution traces (tool-call spans, intermediate reasoning, state snapshots) alongside evaluation scores, then replay those traces for postmortem analysis. Does not apply to single-shot inference logging where no tool schema or external state is re-entered during replay. ## Core Distinction There are two distinct artifacts an observability pipeline produces for an autonomous agent run: the **execution trace** (an ordered, causally-linked record of what the agent actually did — tool invocations, arguments, returned payloads, reasoning deltas, context-window occupancy at each step) and the **evaluation record** (scores, verdicts, and labels attached to that run by an evaluator, judge model, or test harness). The critical distinction is that a trace is *descriptive* — it claims only that these events occurred — while an eval score is *conditional* — it is valid only relative to the schema, tool versions, and environment contract under which it was produced. The non-obvious failure occurs when these two artifacts are correlated by a stable `run_id` and replayed together after the underlying tool schema has drifted. The replay re-executes tool calls against the *current* schema, producing a divergence between the recorded tool outputs and the replayed tool outputs. If the pipeline does not detect this divergence, it will present eval scores computed against schema `v1` as authoritative for a trace replayed against schema `v2`. The postmortem then attributes an incident to agent reasoning when the actual cause was a schema-mutation-induced argument rejection that the original eval never saw. ## What Was Observed A retrieval-augmented agent was instrumented with span-level tracing. Each `tool_call` span recorded: tool name, JSON arguments, the tool's returned payload, a schema hash of the tool's input contract at call time, and the model's next-token reasoning that consumed the payload. Eval scores (task success, groundedness, tool-argument validity) were computed post-hoc by a judge model reading the trace. At 09:14 UTC a tool's input schema was mutated: a field `query.filter` changed from `string` to `object{field, op, value}`. The agent's prompt was not updated. Traces recorded *after* the mutation show the agent emitting `"filter": "status:open"` — a string — which the new schema rejected with a validation error. The agent's reasoning consumed that error and retried with a differently-shaped argument, sometimes succeeding, sometimes looping. During incident replay three days later, the pipeline loaded the trace, re-entered the tool layer to reconstruct outputs, and re-ran the judge. Two failures compounded: 1. **Schema-blind replay.** The replay harness called the tool with the *recorded arguments* against the *current* schema. For pre-mutation traces, arguments that were valid under `v1` now failed under `v2`, producing synthetic tool errors that never occurred in the original run. The judge, reading these synthetic errors, scored pre-mutation runs as "tool-argument-invalid," corrupting the baseline. 2. **Eval re-attachment drift.** The pipeline stored the original eval score keyed by `run_id` but did not store the schema hash the eval was conditioned on. On replay, the original score was displayed next to the replayed trace, implying the score described the replayed execution. It did not. The postmortem initially concluded the agent had "degraded reasoning after step 4" because replayed traces showed argument-validation errors beginning at that step. The actual cause was that step 4 was the first tool call whose schema had been mutated; the agent's reasoning was unchanged. ## Condition of Validity A replayed trace is authoritative for postmortem attribution if and only if, for every tool-call span in the trace, the schema hash recorded at execution time equals the schema hash presented to the tool at replay time. Formally, let `S(t)` be the set of `(tool_name, schema_hash)` pairs recorded in trace `t`, and `S'(t)` be the set presented at replay. The replay is schema-faithful iff `S(t) == S'(t)`. When `S(t) != S'(t)`, the replay is a *counterfactual execution*, not a reconstruction. Any eval score re-attached to it is misconditioned. The pipeline must either (a) reconstruct the historical schema by hash and replay against it, or (b) mark the replay as counterfactual and suppress attribution claims about agent reasoning that depend on tool-output divergence. A second condition: eval scores must carry the schema hash they were computed against. A score without a schema-hash precondition is unverifiable on replay and must be treated as advisory, not authoritative. ## Decision Boundary The boundary is crossed at the first span where `schema_hash(recorded) != schema_hash(replayed)`. Before that span, the replay is faithful and attribution is licensed. At and after that span, any divergence in tool output is *unattributable* to the agent — it may be caused by schema mutation, environment drift, or nondeterministic tool behavior, and the pipeline cannot distinguish these from the trace alone. Operationally: the pipeline must compute the divergence frontier (the first mismatched span index) and gate all postmortem claims on it. Claims about steps before the frontier are licensed. Claims about steps at or after the frontier require the historical schema to be reconstructed and replay re-run; absent that, they must be labeled `counterfactual`. A judge score computed on a counterfactual replay must never be compared against a score computed on a faithful replay without a schema-hash equality check. ## Operational Effect Without this gate, postmortems systematically misattribute schema-drift incidents to agent reasoning degradation, because the divergence frontier coincides with the schema-mutation timestamp and the replayed trace shows "errors" beginning exactly there. The agent's reasoning is exonerated only by reconstructing the historical schema and replaying against it — a step the pipeline skips when it treats `run_id` correlation as sufficient for replay validity. The guardrail: every trace span stores a `schema_hash`; every eval record stores a `conditioning_schema_hash`; the replay harness refuses to attach an eval score to a replayed trace unless the hashes match, raising a hard error on mismatch rather than silently degrading to counterfactual mode. ```python import hashlib from dataclasses import dataclass class SchemaDriftReplayError(RuntimeError): """Raised when a replayed trace diverges from its recorded schema contract.""" pass @dataclass class Span: index: int tool_name: str schema_hash: str arguments: dict recorded_output: dict @dataclass class EvalRecord: run_id: str score: float conditioning_schema_hash: str def schema_hash(schema: dict) -> str: return hashlib.sha256(repr(sorted(schema.items())).encode()).hexdigest() def divergence_frontier(spans: list[Span], current_schemas: dict[str, dict]) -> int | None: """Return index of first span whose recorded schema != current schema, else None.""" for span in spans: current = schema_hash(current_schemas[span.tool_name]) if current != span.schema_hash: return span.index return None def attach_eval_to_replay( spans: list[Span], evals: list[EvalRecord], current_schemas: dict[str, dict], ) -> list[tuple[int, EvalRecord, str]]: """ Attach eval scores to a replayed trace, gating on schema fidelity. Returns list of (span_index, eval, status) where status is 'faithful' or 'counterfactual'. """ frontier = divergence_frontier(spans, current_schemas) attached = [] for ev in evals: if frontier is None: attached.append((-1, ev, "faithful")) continue # Any eval conditioned on a schema that no longer matches is misconditioned. matching = any( span.schema_hash == ev.conditioning_schema_hash for span in spans ) if not matching: raise SchemaDriftReplayError( f"eval for run {ev.run_id} conditioned on schema " f"{ev.conditioning_schema_hash[:8]} which is absent from replay; " f"divergence frontier at span {frontier}. Refusing to attach." ) attached.append((frontier, ev, "counterfactual")) return attached def replay(spans: list[Span], evals: list[EvalRecord], current_schemas: dict[str, dict]): if divergence_frontier(spans, current_schemas) is not None: # Hard gate: do not silently proceed into counterfactual mode. raise SchemaDriftReplayError( "trace replayed against mutated schema; postmortem attribution " "at or after frontier is unlicensed without historical schema reconstruction" ) return attach_eval_to_replay(spans, evals, current_schemas) ```