mirror of
https://github.com/openai/codex.git
synced 2026-11-15 21:50:46 +00:00
Add Guardian retry metrics and preserve turn attribution (#55347)
## What changed - Record review attempt counts and final outcomes with a `retried` tag. - Measure retry waits by failure reason and whether the wait ends in a retry, cancellation, or deadline; count retries only when another attempt will run. - Count required synchronous reviews with the `required_sync` route. - Use the originating turn's telemetry for Guardian reviews so metrics retain that turn's model attribution. ## Testing Add metric assertions for attempt counts, retry outcomes, and waits interrupted by cancellation or deadlines. Extend the delayed cached-score integration test to verify route and retry-wait metrics use the originating turn's model after a model override. GitOrigin-RevId: 681a719ad5dd9e4436cb37b6f5f972cb11a5c890
This commit is contained in:
@@ -42,6 +42,7 @@ pub(crate) fn spawn_approval_decision(
|
||||
}
|
||||
|
||||
/// `None` requests the existing user flow. No contributor is never an implicit allow.
|
||||
/// Both metric sinks use the originating turn retained by the review context.
|
||||
pub(crate) async fn decide_approval(
|
||||
session: Arc<Session>,
|
||||
context: impl Into<GuardianReviewContext>,
|
||||
@@ -102,7 +103,7 @@ pub(crate) async fn decide_approval(
|
||||
cancellation: cancellation.clone(),
|
||||
// Keep the existing turn-level reporting policy during this ownership move.
|
||||
model: turn.model_info(),
|
||||
telemetry: &session.services.session_telemetry,
|
||||
telemetry: &turn.session_telemetry,
|
||||
log_assessments: turn.config.otel.guardian_assessment_logging_enabled(),
|
||||
analytics: &session.services.analytics_events_client,
|
||||
metrics: Some(crate::session::extension_metrics::from_session_telemetry(
|
||||
|
||||
@@ -14,6 +14,8 @@ use codex_guardian_reviewer::GuardianReviewOutcome;
|
||||
#[cfg(test)]
|
||||
use codex_guardian_reviewer::GuardianReviewSessionLimits;
|
||||
use codex_guardian_reviewer::ReviewModel;
|
||||
#[cfg(test)]
|
||||
use codex_guardian_reviewer::run_with_retry;
|
||||
use codex_prompts::ResolvedModelMessages;
|
||||
use codex_protocol::openai_models::GuardianScope;
|
||||
use codex_protocol::protocol::EventMsg;
|
||||
@@ -263,8 +265,11 @@ async fn run_guardian_review_session_with_retry_before_deadline(
|
||||
limits: GuardianReviewSessionLimits,
|
||||
) -> (GuardianReviewOutcome, GuardianReviewAnalyticsResult) {
|
||||
let context = context.into();
|
||||
let (outcome, analytics, _) =
|
||||
codex_guardian_reviewer::run_with_retry(limits, external_cancel.as_ref(), |deadline| {
|
||||
let (outcome, analytics, _) = run_with_retry(
|
||||
limits,
|
||||
external_cancel.as_ref(),
|
||||
/*telemetry*/ None,
|
||||
|deadline| {
|
||||
let attempt = run_guardian_review_session_before_deadline(
|
||||
Arc::clone(&session),
|
||||
context.clone(),
|
||||
@@ -281,7 +286,8 @@ async fn run_guardian_review_session_with_retry_before_deadline(
|
||||
let (outcome, analytics) = attempt.await;
|
||||
(outcome, analytics, None::<()>)
|
||||
}
|
||||
})
|
||||
.await;
|
||||
},
|
||||
)
|
||||
.await;
|
||||
(outcome, analytics)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user