Chapter 21. Longitudinal and Temporal Evaluation
Imagine that Juniper’s support workflow passed last quarter’s evaluation. Since then, the order service has changed its response format, and more customers have started asking about split shipments. The old score described a particular system and set of requests; neither change tells the team on its own whether the agent is less reliable today.
Longitudinal evaluation connects those observations to evidence over time. The team needs to detect changes, distinguish traffic shifts from agent or evaluator changes, and decide whether an earlier evaluation still predicts the outcomes it cares about. To interpret each conclusion, it must also account for the population, time window, and measurement process—which may themselves change.
21.1 Concept Drift in Agent Evaluation
The first task is to name what has changed. Let \(X\) represent an input and \(Y\) the outcome or label of interest, defined consistently across periods. A change in the joint distribution \(P_t(X,Y)\) can arise in several ways:
Definition 22.1 (Distribution and concept drift). Broadly, distribution drift occurs when \(P_t(X,Y) \neq P_{t+\Delta}(X,Y)\). In the narrower sense, concept drift changes the conditional relationship \(P(Y\mid X)\). The following idealized categories help guide an investigation:
- Covariate shift: \(P_t(X) \neq P_{t+\Delta}(X)\) while \(P(Y \mid X)\) remains unchanged.
- Label shift (prior shift): \(P_t(Y) \neq P_{t+\Delta}(Y)\) while \(P(X \mid Y)\) remains unchanged.
- Concept drift (narrow sense): \(P_t(Y \mid X) \neq P_{t+\Delta}(Y \mid X)\).
In practice, several relationships can change together. An observed input or label shift does not establish that the associated conditional distribution stayed fixed, so these categories are assumptions to investigate, not labels a detector proves.
Drift in the agent loop
Juniper’s split-shipment requests may change the input mix, while a service update may instead change tool responses to the same call. Agent actions given a state and judge scores given a trajectory can change too. Track which signal moved, when, and under which system and evaluator versions. For example, a changed judge-score distribution may reflect a new case mix or a changed grader; neither observation alone shows that agent quality changed.
21.2 Drift Detection Methods
21.2.1 Distribution Distance Metrics
Before selecting a detector, define the reference population and the current window, keeping feature definitions, collection methods, and eligibility rules comparable across periods. The measures below detect differences in distributions; they do not establish which change caused the difference or whether users are worse off.
Kolmogorov–Smirnov (KS) for univariate \(X\): \[D_{KS} = \sup_x |F_{\text{ref}}(x) - F_{\text{cur}}(x)|\] The distance compares empirical distributions; conventional two-sample \(p\)-values rely on assumptions such as independent observations and, for their usual form, continuous distributions. Ties, repeated users, and repeated tests need suitable calibration.
Population Stability Index (PSI) for binned variable with bins \(j\): \[\text{PSI} = \sum_{j=1}^{J} (p_{\text{cur},j} - p_{\text{ref},j}) \log\frac{p_{\text{cur},j}}{p_{\text{ref},j}}\] Common PSI bands label values below 0.1 as small, 0.1–0.25 as moderate, and values above 0.25 as large. Treat these as triage conventions; validate thresholds for the feature and traffic volume you monitor.
Worked example: PSI and a rolling success window
Suppose message-length bins are fixed in advance as short, medium, and long. In a reference sample of 100 requests, the counts are \([50,30,20]\); in the current sample of 100, they are \([25,30,45]\). The same bins and eligibility rules apply to both periods. The PSI is \[ (0.25-0.50)\ln(0.25/0.50) +(0.30-0.30)\ln(0.30/0.30) +(0.45-0.20)\ln(0.45/0.20)=0.376. \] The unit is one eligible request, and each distribution denominator is 100. All bins are nonzero here; when a bin is empty, choose and document a smoothing rule before calculation because the value changes the result.
from math import log, sqrt
reference_counts = [50, 30, 20]
current_counts = [25, 30, 45]
reference_n = sum(reference_counts)
current_n = sum(current_counts)
psi = sum(
(current / current_n - reference / reference_n)
* log((current / current_n) / (reference / reference_n))
for reference, current in zip(reference_counts, current_counts)
)
successes = 6
n = 10
z = 1.96
p = successes / n
denominator = 1 + z * z / n
center = (p + z * z / (2 * n)) / denominator
half_width = z * sqrt(p * (1 - p) / n + z * z / (4 * n * n)) / denominator
print(f"PSI: {psi:.3f}")
print(f"current rolling success: {successes}/{n} = {p:.1%}")
print(f"approximate 95% Wilson interval: [{center - half_width:.3f}, {center + half_width:.3f}]")PSI: 0.376
current rolling success: 6/10 = 60.0%
approximate 95% Wilson interval: [0.313, 0.832]
The PSI crosses the example threshold, so check that logging and fixed bins are still comparable, then identify which requests account for the shift. The Wilson interval assumes an independent binomial sample with a common success probability; it illustrates the uncertainty in a small window, not a general solution for correlated or heterogeneous traffic. Neither the 6/10 estimate alone nor the PSI crossing establishes a quality change. Treat the PSI cutoff as a triage rule to validate against your traffic, not as a significance threshold.
Empty-bin smoothing: prespecify and calculate
Suppose the two fixed bins have reference counts \([5,5]\) and current counts \([10,0]\). With a prespecified pseudocount \(\alpha=0.5\) added to every bin in both periods, the smoothed proportions are \([0.50,0.50]\) and approximately \([0.955,0.045]\). The resulting PSI is approximately \(1.384\). The zero current count would otherwise make the logarithm undefined; the smoothing constant and binning rule must be fixed before inspecting the current result.
from math import log
reference_counts = [5, 5]
current_counts = [10, 0]
alpha = 0.5
bin_count = len(reference_counts)
reference_total = sum(reference_counts) + alpha * bin_count
current_total = sum(current_counts) + alpha * bin_count
reference = [
(count + alpha) / reference_total for count in reference_counts
]
current = [
(count + alpha) / current_total for count in current_counts
]
smoothed_psi = sum(
(current_p - reference_p) * log(current_p / reference_p)
for reference_p, current_p in zip(reference, current)
)
print(f"smoothed reference: {[round(p, 3) for p in reference]}")
print(f"smoothed current: {[round(p, 3) for p in current]}")
print(f"PSI with alpha={alpha}: {smoothed_psi:.3f}")smoothed reference: [0.5, 0.5]
smoothed current: [0.955, 0.045]
PSI with alpha=0.5: 1.384
Smoothing prevents the zero-count logarithm but changes the result’s magnitude. With small counts, the value remains unstable, and it is not a significance test. Use it as a review trigger, then obtain labeled outcomes before concluding that agent quality degraded.
Maximum Mean Discrepancy (MMD) in a reproducing kernel Hilbert space with kernel \(k\), using independent draws \(X,X'\) from the reference distribution and \(Y,Y'\) from the current distribution: \[\text{MMD}^2 = \mathbb{E}[k(X, X')] + \mathbb{E}[k(Y, Y')] - 2\mathbb{E}[k(X, Y)]\] At the population level, MMD = 0 if and only if the distributions are equal for a suitable characteristic kernel. A finite-sample estimate is noisy; kernel choice and a calibrated test affect what shifts are detectable.
Wasserstein distance: \[W_1(P_{\text{ref}}, P_{\text{cur}}) = \inf_{\gamma \in \Pi} \mathbb{E}_{(X,Y) \sim \gamma}[\|X - Y\|]\] Here \(\Pi\) is the set of joint distributions with the reference and current distributions as marginals. The distance depends on the feature space and its units, so scale features deliberately and compare it with a relevant baseline.
21.2.2 Sequential Drift Detection Tests
Distribution comparisons can be run on scheduled windows, whereas sequential methods accumulate evidence as new observations arrive. Their thresholds must account for repeated monitoring and the dependence structure of the stream.
Page-Hinkley test for an upward change in the mean of \(x_1, x_2, \dots\), with tolerance \(\delta\ge0\): \[m_t = \frac{1}{t}\sum_{i=1}^{t} x_i, \qquad M_t = \sum_{i=1}^{t} (x_i - m_i - \delta), \qquad PH_t = M_t - \min_{0 \leq i \leq t} M_i,\quad M_0=0.\] Signal an upward shift when \(PH_t > \lambda\); a downward detector can be applied to \(-x_t\). Calibrate \(\delta\) and \(\lambda\) for the data, the smallest meaningful shift, and the acceptable false-alert rate, including any autocorrelation. The production-monitoring chapter discusses the operational trade-off.
ADWIN (Adaptive Windowing) maintains a variable-length window and tests candidate cuts for changes in mean. As a simplified fixed-cut illustration for independent observations bounded in \([0,1]\), compare adjacent, prespecified windows \(W_0\) and \(W_1\) with: \[\left|\hat{\mu}_0 - \hat{\mu}_1\right| > \sqrt{\frac{1}{2|W_0|}\ln\frac{4}{\delta} + \frac{1}{2|W_1|}\ln\frac{4}{\delta}}\] This is a fixed-cut threshold, not a complete implementation or a global false-alarm guarantee for adaptive repeated searches.
Worked example: a fixed-cut, ADWIN-style drift check
To make the cut calculation concrete, use two adjacent fixed windows of 50 binary outcomes each: the first contains 45 successes, and the second 25. Their means are \(0.90\) and \(0.50\), a difference of \(0.40\). For \(\delta=0.05\), the displayed two-window bound is about \(0.296\), so this cut signals at observation 100.
from math import log, sqrt
outcomes = [1] * 45 + [0] * 5 + [1] * 25 + [0] * 25
window_size = 50
left = outcomes[:window_size]
right = outcomes[window_size:2 * window_size]
left_mean = sum(left) / len(left)
right_mean = sum(right) / len(right)
delta = 0.05
bound = sqrt(
log(4 / delta) / (2 * len(left))
+ log(4 / delta) / (2 * len(right))
)
detected = abs(left_mean - right_mean) > bound
print(
f"cut at n={len(left)+len(right)}: "
f"means={left_mean:.2f},{right_mean:.2f}; "
f"delta={abs(left_mean-right_mean):.2f}; bound={bound:.3f}; "
f"signal={detected}"
)cut at n=100: means=0.90,0.50; delta=0.40; bound=0.296; signal=True
This calculation checks one fixed cut with an ADWIN-style bound. A production ADWIN detector adapts its windows and considers multiple candidate cuts, so repeated searches need false-alarm control. The deterministic fixture says nothing about false-positive rates. When a detector alerts, route it to label review and slice diagnosis; automate rollback only under a separately validated policy.
EDDM (Early Drift Detection Method) monitors the distances between consecutive errors. When errors become more frequent, their typical spacing tends to decrease. EDDM compares a statistic based on the mean and standard deviation of those distances with its historical maximum, signaling when the ratio falls below a chosen threshold. It needs enough observed errors to establish a reference; sparse or delayed labels and correlated errors can delay or distort detection.
21.3 LLM Judge Drift in Production
An apparent fall in agent quality may instead come from the measurement system: if the judge’s prompt or model changes, even the same trajectory may receive a different grade.
Definition 22.2 (Judge drift). For a deterministic judge \(J_t: \mathcal{T} \to \mathbb{R}\), judge behavior changes when \(J_t(\tau) \neq J_{t+\Delta}(\tau)\) on the same trajectory \(\tau\). For a stochastic judge, compare the distribution of grades under fixed evaluation conditions: a single changed score can be ordinary run-to-run variation rather than drift.
Detecting judge drift
Method 1 — Judge-retest reliability. Re-grade \(N\) fixed calibration trajectories with \(J_t\) and compare each categorical grade with its recorded reference grade:
\[\text{Disagreement rate} = \frac{1}{N}\sum_{i=1}^{N} \mathbb{I}\{J_t(\tau_i) \neq J_{\text{ref}}(\tau_i)\}.\]
Report missing and abstained grades separately, and repeat stochastic judgments when appropriate. Since disagreement measures change in judgments rather than which judge is correct, compare with independently adjudicated human labels as well.
Method 2 — Weighted Cohen’s kappa. For two raters assigning ordered categories, choose agreement weights in advance. Let \(P_o\) be weighted observed agreement and \(P_e\) weighted agreement expected from the raters’ category marginals: \[\kappa = \frac{P_o - P_e}{1 - P_e}\] Kappa is undefined when \(P_e=1\) and can be sensitive to category prevalence, so report the confusion matrix and observed agreement alongside it. Unweighted kappa is the special case that credits exact matches only.
Method 3 — Calibration drift. For probabilistic judge scores \(\hat{p}\): \[\text{ECE}_t = \sum_{b=1}^{B} \frac{n_{b,t}}{N_t} \left| \text{acc}_{b,t} - \text{conf}_{b,t} \right|.\] This measure requires probability forecasts, independently adjudicated outcomes, and a declared binning scheme. Use the same bins and comparable cases across periods; ECE depends on sample size and bin choices and cannot diagnose individual errors.
Mitigating judge drift
- Judge versioning: Pin judge model and prompt versions with every eval run.
- Calibration sets: Maintain fixed human-graded trajectories for periodic re-grading.
- Judge ensembles: Track inter-judge agreement; divergence is a reason to investigate, not proof of drift or correctness.
- Human-in-the-loop review: Periodically re-grade a sample of judge outputs.
21.4 Dataset Drift
Even a stable judge cannot make an outdated test set representative of new traffic. If Juniper’s live requests now include split shipments but its evaluation cases do not, the team may see a reassuring score while missing an important task family. Monitoring the dataset therefore complements monitoring the judge.
Definition 22.3 (Dataset drift). Dataset drift is a change between the relevant data distributions represented by \(\mathcal{D}_t\) and \(\mathcal{D}_{t+\Delta}\). Because each dataset is only a sample, observed differences also contain sampling variation; compare the selection and labeling processes as well as the cases themselves.
Detecting dataset drift
Input-side drift: Apply KS, PSI, MMD to task features (message length, tool types, task category).
Label-side drift: Track the distribution of independently verified labels over time, including changes in the rubric, policy, and missing-label rates. A different label mix alone does not establish label shift in the technical sense defined above.
Coverage drift: \[\text{Coverage}_t = \frac{|\{g \in \mathcal{G} : \exists i \in \mathcal{D}_t, G(\tau_i) = g\}|}{|\mathcal{G}|}\] Here \(\mathcal{G}\) is a fixed, nonempty set of task groups and \(G(\tau_i)\) assigns a case to one group. Presence in a group is not sufficient coverage: one example may be too little to measure performance, and the ratio does not account for group prevalence or risk. If groups or labels change, version the taxonomy before comparing coverage across time.
Dataset decay half-life
Once a team has identified coverage changes, it may also ask how long an evaluation remains informative about future performance. One possible operational definition treats the fixed evaluation at time \(t\) as a predictor \(E_t\) of later outcomes \(R_{t+\Delta}\) across comparable systems or releases.
Definition 22.4 (Dataset half-life). Given a positive baseline mutual information \(I(E_t;R_t)\), define \(\tau_{1/2}\) as the first measured horizon \(\Delta>0\) at which: \[I(E_t; R_{t + \Delta}) \le \frac{1}{2} I(E_t; R_t).\]
This is a chosen proxy for predictive validity, not an intrinsic expiration date for a dataset. It requires a population of paired evaluation scores and subsequent outcomes, comparable definitions across horizons, and enough independent observations to estimate mutual information with uncertainty. If the baseline is zero, the pairs are unavailable, or no crossing is observed, report the half-life as undefined or not observed rather than inventing a value. Even when a crossing is observed, it can reflect changes in systems, traffic, labels, or measurement as well as dataset staleness.
21.5 Temporal Validation
Time-based split
The next question is whether an evaluation built from past data performs on cases that arrive later. A time-based split approximates that use: train before \(t_{\text{train\_end}}\), develop in the middle period, and test after \(t_{\text{dev\_end}}\). Use information available at each prediction time, and prevent repeated users, related cases, and future labels from leaking across splits. Recording any gap between periods and the population each split represents makes the resulting comparison easier to interpret.
Rolling window evaluation
Maintain a sliding window of the most recent \(W\) eligible instances and plot a defined metric \(M(t)\). A short window reacts quickly but is noisy, whereas a longer one is steadier but may hide a short-lived problem. State the window size, eligibility rules, missing outcomes, and minimum volume.
Prequential evaluation
Prequential evaluation scores an instance with the version available before that instance can influence training: \[\text{Prequential error at } t = \mathbb{I}\{J_{t-1}(\tau_t) \neq y_t\}\]
Here \(y_t\) is the authoritative label, which may arrive later. Preserve the prediction and model version at scoring time, then update the model only when the label is legitimately available. Do not score retrospectively with a model that has seen the case.
For a rolling binary success metric, state the window unit and denominator: in a ten-request window with six verified successes, the observed rate is \(6/10=0.60\). Report an interval and the timestamped window alongside the rate; overlapping rolling windows are dependent and do not provide independent confirmations of drift. Chapter 2’s task-cluster bootstrap may be appropriate when requests cluster by user or task; temporal dependence may require time-aware resampling or another suitable method.
21.6 Monitoring Framework
The pieces come together in a monitoring plan. The thresholds below are illustrative triage rules, not universal standards or statistical guarantees. For each signal, specify the population, baseline, unit, window, minimum volume, owner, and response. Then test false alerts and detection delay on relevant data, and investigate evaluator health before attributing a change to the agent.
| Metric | What it can signal | Method | Example triage threshold |
|---|---|---|---|
| Input distribution (PSI/KS) | Input-distribution change | PSI on task features | PSI > 0.25 |
| Judge agreement (kappa) | Changed agreement requiring review | Cohen’s kappa on fixed, adjudicated cases | \(\kappa < 0.6\) |
| Judge ECE | Possible calibration problem or change | ECE on probabilistic judge | ECE > 0.1 |
| Dataset coverage | Missing task types in a defined taxonomy | Coverage ratio | Coverage < 0.8 |
| Rolling success rate | Outcome change requiring investigation | Moving average with comparable windows | Drop > 5 percentage points, sustained under a prespecified rule |
| Mutual information | Possible predictive-validity decay | \(I(E; R)\) on paired system outcomes | Drop > 50% from a positive baseline |
A signal is the start of an investigation, not a causal diagnosis. If the monitoring or label pipeline is incomplete, report the resulting evidence gap rather than treating a quiet dashboard as a pass.
21.7 Exercises
Use these exercises to separate evidence of change from an explanation of what caused it.
(Conceptual) Agent success drops from 85% to 70% over three months; code unchanged. List three causes.
(Hands-on) Implement PSI drift detection on message length. Report PSI.
(Conceptual) Judge A and B agree on 82% of 1000 trajectories. Explain why this is not enough to compute Cohen’s kappa, and identify the additional information needed.
(Hands-on) Implement rolling-window success-rate plot.
(Discussion) How would you estimate dataset half-life?
21.8 Further Reading
These sources expand on drift adaptation, streaming methods, and detecting dataset shift:
- Gama et al., “A Survey on Concept Drift Adaptation” [1].
- Bifet et al., “Mining Massive Data Streams” [2].
- Rabanser et al., “Failing Loudly: Dataset Shift Detection” [3].
- Widmer & Kubat, “Learning in the Presence of Concept Drift” [4].