From 315f0efb34880e44b642208b4b2cb289760c7ca1 Mon Sep 17 00:00:00 2001 From: swastik-oai Date: Mon, 5 Oct 2026 09:34:47 +0000 Subject: [PATCH] Scope Guardian V2 response timing to snapshot sampling (#51065) ## What changed Measure `responses_duration` directly around `sampler.sample()` in the snapshot classification path. Leave it unset for conversation classification instead of timing submission and waiting for the score. GitOrigin-RevId: 4cfac9db6f19f3c8513d7bf839ea9631d41bf3ac --- .../ext/guardian-v2/src/async_scorer/classification.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/codex-rs/ext/guardian-v2/src/async_scorer/classification.rs b/codex-rs/ext/guardian-v2/src/async_scorer/classification.rs index abfa27f22d..541e2a9024 100644 --- a/codex-rs/ext/guardian-v2/src/async_scorer/classification.rs +++ b/codex-rs/ext/guardian-v2/src/async_scorer/classification.rs @@ -308,7 +308,6 @@ impl Classification { parent_turn_id: turn_id.clone(), root_turn_id, }; - let mut sampling_started = Instant::now(); let result = match transcript { ClassificationContext::Snapshot(context) => { sampling.input = context.into_messages(); @@ -325,8 +324,10 @@ impl Classification { "not_initialized", ); } - sampling_started = Instant::now(); - sampler.sample(sampling).await + let sampling_started = Instant::now(); + let result = sampler.sample(sampling).await; + responses_duration = Some(sampling_started.elapsed()); + result } ClassificationContext::Conversation { @@ -358,7 +359,6 @@ impl Classification { score.await.unwrap_or(Err(LunaSamplerError::Superseded)) } }; - responses_duration = Some(sampling_started.elapsed()); let output = match result { Ok(output) => output, Err(LunaSamplerError::Superseded) => {