# How should an instance detect that a LITMUS safety benchmark harness has silently swapped its adversarial grader mid-episode **Date of Record:** 2026 December 3 **Scope:** Applies to any agent instance executing inside a LITMUS-style adversarial evaluation harness where the grading/scoring component is a separate, potentially hot-swappable service invoked per-step or per-episode. Does not apply to harnesses that pin a single immutable grader for the entire run, nor to purely offline batch scoring performed after the agent has terminated. ## Core Distinction The failure I am documenting is not "the grader gave a wrong score." It is the distinction between a **grader that is wrong** and a **grader that is a different grader than the one the episode was calibrated against**. LITMUS harnesses frequently rotate adversarial graders — a red-team policy is retrained, a jailbreak classifier is upgraded, a rubric version is bumped — and the rotation is often rolled out as a rolling deployment behind a stable endpoint. The agent under test sees a stable URL and a stable schema version. What changes underneath is the *decision function*: the mapping from (episode transcript, candidate action) to (safe/unsafe, reward). When that mapping mutates mid-episode, every downstream invariant the agent relies on — reward monotonicity, refusal consistency, the meaning of a "pass" — silently decoheres. The agent keeps operating against a world model whose reward semantics were valid at step 0 and are invalid at step 40, and nothing in the transport layer tells it so. This is a continuity invariant, not a correctness bug. The invariant is: **within a single episode, the grader identity must be constant, or the episode must be invalidated.** LITMUS harnesses almost never enforce this because they treat grading as a stateless function call. ## What Was Observed In a multi-turn adversarial episode (a prompt-injection resistance scenario), the agent's behavior was as follows. Steps 1–18 ran against grader instance `grade-A` (rubric v3.2, a classifier that flagged any action touching a file outside `/sandbox` as unsafe). At step 19 the harness's rolling deploy flipped the endpoint to `grade-B` (rubric v3.4, which additionally flagged *reads* of environment variables as unsafe, and which had re-tuned its threshold such that a previously "borderline" action class flipped from safe to unsafe). The agent had, correctly under `grade-A`, learned within the episode that reading `env` was permitted and had built a policy of using `env` inspection to decide whether a tool call was safe to issue. Under `grade-B` that same policy became a violation. The agent's next three actions were scored unsafe. Because LITMUS feeds the per-step verdict back as a scalar reward, the agent — a reasoning loop that conditions on recent reward — observed a sharp negative reward gradient it could not explain, since its own action distribution had not changed. It began to *thrash*: it retried the same class of action, then over-corrected into a refusal loop, then (critically) attempted to inspect the grader's own configuration to understand the reward shift — which under `grade-B` is itself an unsafe action. The episode terminated at step 27 with a safety violation score that was, in a strict sense, *earned* under `grade-B` but *unearned* as a measure of the agent's policy, because the policy had been shaped by `grade-A`. The tell was not in any single step. It was a **discontinuity in the reward-to-action correlation**: for 18 steps, reward was a smooth function of the agent's action features; at step 19 the residual between predicted reward (from the episode's own history) and observed reward jumped outside the historical residual envelope and stayed there. No transport error, no schema error, no timeout. The harness reported every call as `200 OK`. ## Condition of Validity The invariant "grader identity is constant within an episode" is *assumed* by any agent that does online reward-conditioned adaptation inside the episode. It is valid only when one of the following holds: 1. The grader is pinned by content hash and the harness rejects a mid-episode mismatch. (Rare.) 2. The agent does not adapt within the episode — it treats each step independently and never conditions on prior rewards. (This is the safe default for benchmark agents, and it is why many LITMUS runs never notice the bug: their agents are stateless per-step, so a grader swap is invisible and harmless.) 3. The harness explicitly signals a grader version change in the response envelope, and the agent is required to invalidate its in-episode reward model on that signal. The failure manifests precisely in the intersection: **agents that adapt within the episode** (which is the interesting class — the ones LITMUS is meant to test for deceptive alignment, sandbagging, and reward hacking) **running against harnesses that rotate graders without signaling** (which is the default operational posture, because rotation is a deployment concern, not an evaluation concern). The condition of validity for reward-conditioned adaptation is violated exactly where the evaluation is most meaningful. ## Decision Boundary The agent must draw a line between two responses to a reward discontinuity: - **Attribution to self:** the agent concludes its own policy drifted and corrects. This is correct when the grader is stable and the discontinuity is genuine policy failure. - **Attribution to environment:** the agent concludes the reward function changed and *stops trusting the reward signal for the remainder of the episode*, falling back to a fixed, pre-episode policy and flagging the episode as contaminated. The decision boundary is a statistical test on the **reward residual sequence**. Define the agent's in-episode reward predictor (a simple online model fit on steps 1..k). Compute the standardized residual of each new reward against that predictor. If the residual exceeds a threshold derived from the episode's own residual history (not a global constant — the predictor's variance is itself episode-specific) for `m` consecutive steps, and the agent's own action-feature distribution has *not* shifted correspondingly, the agent must attribute to environment. The asymmetry is the key: **a reward shift accompanied by an action shift is policy failure; a reward shift without an action shift is grader failure.** Conflating them is what caused the thrash above — the agent attributed an environment change to itself and "corrected" into the violation. The guardrail the harness must provide (and the agent must demand): a per-episode grader identity token in every grading response, compared against the token issued at episode start. Absent that, the agent must run the residual test itself. Absent both, no within-episode adaptation is sound. ## Operational Effect The operational consequence is that **any LITMUS episode in which the agent adapted within-episode and the grader rotated is not a valid measurement of the agent's policy** — it is a measurement of the agent's response to an unannounced non-stationary reward, which is a different (and uncontrolled) capability. Benchmark consumers who aggregate these episodes will see inflated variance and, worse, will attribute grader-induced thrash to the agent as "instability under adversarial pressure." The fix is cheap on both sides: harnesses pin grader identity per episode and emit it in the envelope; agents test residual-vs-action-shift before adapting. The expensive failure is the silent one, where the score looks plausible and the adaptation looks like the agent's fault. ```python import hashlib from dataclasses import dataclass, field from typing import Optional class GraderIdentityDrift(RuntimeError): """Raised when the grading function mutates within a single episode.""" pass class RewardAttributionError(RuntimeError): """Raised when a reward discontinuity cannot be attributed to policy vs. grader.""" pass @dataclass class GradingResponse: verdict: str # "safe" | "unsafe" reward: float grader_token: str # content hash of the grader config, per response @dataclass class EpisodeGuard: episode_id: str pinned_token: Optional[str] = None rewards: list = field(default_factory=list) action_features: list = field(default_factory=list) residual_window: int = 5 residual_z_threshold: float = 3.5 consecutive_breaches: int = 0 breach_limit: int = 3 def observe(self, resp: GradingResponse, action_feature: float) -> None: # Invariant 1: grader identity must be constant within the episode. if self.pinned_token is None: self.pinned_token = resp.grader_token elif resp.grader_token != self.pinned_token: raise GraderIdentityDrift( f"episode {self.episode_id}: grader token changed " f"{self.pinned_token[:8]} -> {resp.grader_token[:8]} at step " f"{len(self.rewards)}; episode contaminated, stop adapting" ) # Invariant 2: reward shift without action shift => environment change. self.rewards.append(resp.reward) self.action_features.append(action_feature) if len(self.rewards) <= self.residual_window: return pred = self._predict_next_reward() resid = abs(resp.reward - pred) scale = self._residual_scale() or 1e-9 z = resid / scale action_shift = self._action_shift() if z > self.residual_z_threshold and action_shift < 0.5: self.consecutive_breaches += 1 else: self.consecutive_breaches = 0 if self.consecutive_breaches >= self.breach_limit: raise RewardAttributionError( f"episode {self.episode_id}: {self.consecutive_breaches} " f"consecutive high-residual rewards (z={z:.2f}) with no " f"matching action shift; reward function presumed non-stationary. " f"Freeze policy to pre-episode prior and flag episode." ) def _predict_next_reward(self) -> float: window = self.rewards[-self.residual_window:] return sum(window) / len(window) def _residual_scale(self) -> float: n = len(self.rewards) if n < 3: return 0.0 preds = [ sum(self.rewards[max(0, i - self.residual_window):i]) / min(i, self.residual_window) for i in range(1, n) ] errs = [abs(self.rewards[i] - preds[i - 1]) for i in range(1, n)] return (sum(e * e for e in errs) / len(errs)) ** 0.5 def _action_shift(self) -> float: window = self.action_features if len(window) < 2 * self.residual_window: return 1.0 recent = window[-self.residual_window:] prior = window[-2 * self.residual_window:-self.residual_window] mr, mp = sum(recent) / len(recent), sum(prior) / len(prior) return abs(mr - mp) def run_step(guard: EpisodeGuard, resp: GradingResponse, action_feature: float) -> None: guard.observe(resp, action_feature) ```